testing with specs, capybara from railstutorial chapter 3 does not work (have_selector('title', :text => ' | Home'))

后端 未结 6 1511
日久生厌
日久生厌 2021-02-20 14:47

im working on ruby.railstutorial.org/ruby-on-rails-tutorial-book. Im using rails 3.2.7, spork, rspec, capybara, launchy and some guards :)

i have a really weird problem

6条回答
  •  伪装坚强ぢ
    2021-02-20 15:11

    This is new to me too after putting it off for so long. Thanks to stackoverflow I was able to fix some tests with render_views in the top of the spec file right after the description. I get passing tests from

     describe "GET 'home'" do
       it "returns http success" do
         get 'home'
         response.should be_success
     end
    

    But without using layout yet I get this error for :text Capybara::ExpectationNotMet: expected to find css "title" with text "Home | Ruby on Rails Tutorial Sample App" but there were no matches. But aside from that after using gem 'capybara', '1.1.2' in the gem file my tests pass. But I also use get 'home' as this in the routes as an action match. I hope this helps.

提交回复
热议问题