0

While following Michael Hartl's RonR tutorial im in the process of trying to get my Home page to pass my written test. Unfortunately im unable to figure out why I have a failure? Any help would be much appreciated..

spec/requests/static_pages_spec.rb

require spec helper
require 'minitest/autorun'

describe "Static pages" do
  describe "Home page" do

    it "should have the content 'Sample App'" do
      visit '/static_pages/home'
      expect(page).to have_content('Sample App')

    end
  end
end

app/views/static_pages/home.html.erb

<h1>Sample App</h1>
<p> This is the home page for the 
<a href="http://railstutorial.org/">Ruby on rails Tutorial</a>
sample application.
</p>

and so I run..

$bundle exec rspec spec/requests/static_pages_spec.rb

the outcome is...

Failures:

  1) Static pages Home page should have the content 'Sample App'
     ←[31mFailure/Error:←[0m ←[31mvisit '/static_pages/home' # Run the generator again with the --webrat flag if you want to use webrat m
ethods/matchers←[0m
     ←[31mNoMethodError←[0m:
       ←[31mundefined method `visit' for #<RSpec::Core::ExampleGroup::Nested_1::Nested_1:0x5ba9688>←[0m
←[36m     # ./spec/requests/static_pages_spec.rb:9:in `block (3 levels) in <top (required)>'←[0m

Finished in 0.002 seconds
←[31m1 example, 1 failure←[0m

Failed examples:

←[31mrspec ./spec/requests/static_pages_spec.rb:8←[0m ←[36m# Static pages Home page should have the content 'Sample App'←[0m
Uri Agassi
  • 36,848
  • 14
  • 76
  • 93
Billy
  • 2,823
  • 3
  • 16
  • 33
  • I think there might be something wrong with your Capybara setup - [this question](http://stackoverflow.com/questions/8862967/visit-method-not-found-in-my-rspec) seems to deal with the same issue – Rich Tolley May 31 '14 at 20:12
  • Thanks. Unfortunately I was unable to resolve this after many suggestions. Configuring Capybara settings did not work as mentioned by http://stackoverflow.com/users/703634/egezer. http://stackoverflow.com/users/2001618/steve-clarke mentioned something which im sure could help me but unfortunately due to inexperience im unable to solve this problem the way I would like. I've had to downgrade to rails 3.2 in the end. – Billy Jun 01 '14 at 14:43

0 Answers0