ling@ling-Lenovo-N480:~/rails_projects/sample_app$ bundle exec rspec spec/requests/static_pages_spec.rb
F
Failures:
1) Static pages Home page should have the content 'Sample App'
Failure/Error: visit '/static_pages/home'
NoMethodError:
undefined method `visit' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_1:0x00000004ab4ad8>
# ./spec/requests/static_pages_spec.rb:8:in `block (3 levels) in <top (required)>'
Finished in 0.0014 seconds
1 example, 1 failure
在stackoverflow上面找到了答案,其实是需要一个simulated browser,解决办法:
1.在Gemfile中添加 gem 'capybara'
2.bundle install
3.在spec_helper中添加 require 'capybara/rspec'
如果有其它问题,可以参见rspec的文档:
http://rubydoc.info/gems/rspec-rails/frames
原文转载自 http://www.cnblogs.com/angestudy/archive/2012/11/04/2754150.html