0

I am following Michael Hartls tutorial on rspec and I am getting this error

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::ExampleGroups::StaticPages::HomePage:0x007fdddbdf6a90>
     # ./spec/requests/static_pages_spec.rb:6:in `block (3 levels) in <top (required)>'

Finished in 0.00052 seconds (files took 0.1562 seconds to load)
1 example, 1 failure

Failed examples:

rspec ./spec/requests/static_pages_spec.rb:5 # Static pages Home page should have the content 'Sample App'

for the rspec test.

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

I don't believe that the reason I am getting this error is the test case is failing but rather this:

NoMethodError:
           undefined method `visit' for #<RSpec:....

I am not sure why there is an undefined method visit

Liondancer
  • 15,721
  • 51
  • 149
  • 255

1 Answers1

0

maybe you just missed:

config.include Capybara::DSL

also you could look to the same qestion here

Community
  • 1
  • 1
Igor Guzak
  • 2,155
  • 1
  • 13
  • 20