RoR - 失败/错误:response.should have.selector,集成测试失败
你好,我对 RoR 还很陌生,我正在尝试遵循 Michael Hartl 的教程,在集成测试期间我遇到了问题。
我尝试了这里给出的解决方案,为什么 Rspec 说“失败/错误:无法从回溯中找到匹配行”?。但我仍然收到错误。
所以当我运行 $ rspec spec/ 时,它显示,
1) LayoutLinks should have a Home page at '/'
Failure/Error: response.should have.selector('title', :content => "Home")
ArgumentError:
wrong number of arguments (0 for 1)
# ./spec/requests/layout_links_spec.rb:7:in `block (2 levels) in <top (required)>'
这是我的 gem 列表:
webrat (0.7.1)
xpath (0.1.4)
ZenTest (4.6.2)
rspec (2.8.0, 2.0.1)
rspec-core (2.8.0, 2.0.1)
rspec-expectations (2.8.0, 2.0.1)
rspec-mocks (2.8.0, 2.0.1)
rspec-rails (2.8.1, 2.8.0, 2.0.1, 2.0.0.beta.18)
rubyzip (0.9.5)
sass (3.1.12)
sass-rails (3.2.3, 3.1.5)
capybara (1.1.2)
childprocess (0.3.0)
coffee-rails (3.2.1, 3.1.1)
coffee-script (2.2.0)
coffee-script-source (1.2.0)
cucumber (1.1.4)
cucumber-rails (1.2.1)
factory_girl (2.4.2)
factory_girl_rails (1.5.0)
这是我的 gem 文件:
gem 'therubyracer'
gem 'sqlite3'
group :development do
gem 'rspec-rails'
end
group :test do
gem 'webrat', '0.7.1'
gem 'rspec'
end
Gems used only for assets and not required
in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.0'
gem 'uglifier', '>= 1.0.3'
end
我猜这是 webrat/capybara 问题,但我不知道如何解决这个问题。任何帮助将不胜感激。谢谢你!
Hi I'm pretty new in RoR, and I'm trying to follow Michael Hartl's tutorial where I got problem during integration test.
I tried the solution given here, Why is Rspec saying "Failure/Error: Unable to find matching line from backtrace"?. but still I get errors.
So when I run $ rspec spec/ , it shows,
1) LayoutLinks should have a Home page at '/'
Failure/Error: response.should have.selector('title', :content => "Home")
ArgumentError:
wrong number of arguments (0 for 1)
# ./spec/requests/layout_links_spec.rb:7:in `block (2 levels) in <top (required)>'
And here's my gem list:
webrat (0.7.1)
xpath (0.1.4)
ZenTest (4.6.2)
rspec (2.8.0, 2.0.1)
rspec-core (2.8.0, 2.0.1)
rspec-expectations (2.8.0, 2.0.1)
rspec-mocks (2.8.0, 2.0.1)
rspec-rails (2.8.1, 2.8.0, 2.0.1, 2.0.0.beta.18)
rubyzip (0.9.5)
sass (3.1.12)
sass-rails (3.2.3, 3.1.5)
capybara (1.1.2)
childprocess (0.3.0)
coffee-rails (3.2.1, 3.1.1)
coffee-script (2.2.0)
coffee-script-source (1.2.0)
cucumber (1.1.4)
cucumber-rails (1.2.1)
factory_girl (2.4.2)
factory_girl_rails (1.5.0)
And here's my gem file:
gem 'therubyracer'
gem 'sqlite3'
group :development do
gem 'rspec-rails'
end
group :test do
gem 'webrat', '0.7.1'
gem 'rspec'
end
Gems used only for assets and not required
in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.0'
gem 'uglifier', '>= 1.0.3'
end
My guess is it's webrat/capybara problem but I have no idea how to solve this. Any help will be much appreciated. Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
嗯,我对标题选择器和水豚也有同样的问题。这个代码对我来说效果很好,试试吧:
Well i have same problem with title selector and capybara. This one code works well for me, try it: