如何解决have_tag与Have_selector
| 我已经成功地将have_selector与RSpec(版本2.0.1)一起使用了。我最近在与RSpec 1.3.2关联的have_tag ... with_tag ...文档中找到了文档,并希望使用它,但是RSpec给了我错误:undefined method `has_tag?\' for #<ActionController::TestResponse:0x105584e80>
在以下几行:
response.should have_tag(\"div.breadcrumbs select\") do
with_tag(:option,:value => @brands.name)
with_tag(:option,:value => @marketsize.name)
end
我尝试用相同的语法将“ have_selector \”和“ with_selector”替换为“ have_tag \”和“ with_tag \”,在这种情况下,我得到了错误消息
undefined method `with_selector\' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_1::Nested_1::Nested_1:0x105379de8>
我还尝试过单独替换\“ with_tag \”,而没有成功地替换\“ have_selector \”。
解决方法
花了我一段时间才能在文档中找到它,但是正确的答案是
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将不包含have_tag。改用webrat \的have_selector匹配器。
http://groups.google.com/group/rspec/browse_thread/thread/1c254524d6859ba9
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。