have_tag vs. have_selector
I've been using have_selector with RSpec (version 2.0.1) successfully. I recently found documentation on have_tag ... with_tag ... associated with RSpec 1.3.2 and would like to use it, but RSpec gives me the error:
undefined method `has_tag?' for #<ActionController::TestResponse:0x105584e80>
on the following lines:
response.should have_tag("div.breadcrumbs select") do
with_tag(:option, :value => @brands.name)
with_tag(:option, :value => @marketsize.name)
end
I've tried the same syntax substituting "have_selector" and "with_selector for "have_tag" and "with_tag", in which case I get the error message
undefined method `with_selector' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_1::Nested_1::Nested_1:0x105379de8>
I've also tried leavin开发者_开发技巧g the "with_tag" alone while substituting "have_selector" with no success.
Took me a while to find it in the documentation, but the correct answer is
response.should have_selector("div.breadcrumbs select") do |content|
content.should have_selector(:option, :value => @brands.name)
content.should have_selector(:option, :value => @marketsize.name)
end
RSpec-2 will not include have_tag. Use webrat's have_selector matcher instead.
http://groups.google.com/group/rspec/browse_thread/thread/1c254524d6859ba9
精彩评论