How can I test the page title with Capybara 2.0?

后端 未结 6 858
北荒
北荒 2020-11-27 05:32

Trying to test that page contains My Title with:

# spec/features/reports_spec.rb
require \'spec_helper\'

feature \"A         


        
6条回答
  •  情歌与酒
    2020-11-27 06:00

    I had this problem only when using 'shared_examples_for', maybe because of other changes. I also noticed that when I placed

    My Title
    in the body of the page (where it doesn't belong and won't render), the test passed. Not a good thing!

    This worked:

    it{should have_title("My Title")}

    (capybara 2.1.0, launchy 2.3.0, nokogiri 1.5.9, rspec 2.13)

提交回复
热议问题