Reputation: 12252
I am trying to follow TDD on Rails Tutorial which is available online here
While testing first app, I got an error.
My spec.rb code is this:
require 'spec_helper'
describe "Static pages" do
describe "Home page" do
it "should have the content 'Sample App'" do
visit '/static_pages/home'
page.should have_content('Sample App')
end
end
end
After running testing I got this error:
Failure/Error: visit '/static_pages/home'
NoMethodError:
undefined method `visit' for # <RSpec::Core::ExampleGroup::Nested_1::Nested_1:0xa833e5c># ./spec/requests/static_pages_spec.rb:8:in `block (3 levels) in <top (required)>'
I will really appreciate your help.
Upvotes: 1
Views: 1518
Reputation: 947
Try add:
require 'rails_helper'
require 'spec_helper'
to your spec.rb and:
require 'capybara'
RSpec.configure do |config|
config.include Capybara::DSL
....
to spec_helper.rb
and gem 'capybara', '2.2.0' to gemfile
Upvotes: 0