← Back to Upcase

Error with homepage spec after adding Jasmine

(Matt Bjornson) #1

After adding Jasmine to the Gemfile and running the view_homepage_spec, I’m getting this error,

  1. View the homepage learn about the application
    Failure/Error: expect(page).to have_css ‘title’, text: 'Hashtag’
    expected css “title” with text “Hashtag” to return something
 # ./spec/integration/view_homepage_spec.rb:6:in `block (2 levels) in <top (required)>'
 # ./spec/support/searcher.rb:4:in `block (2 levels) in <top (required)>'

However my app/views/layouts/application.html.erb contains the following,


This is the only change in view_homepage_spec.rb

scenario 'learn about the application', js: true do

The spec passes fine without adding the js. What am I missing?


(Chris Toomey) #2

Hello @MattBjornson. I don’t think jasmine is the cause of the test failure. Jasmine
is used for javascript unit testing, not for integration tests. The integration
tests are run via Capyabra and Rspec. The js: true you reference will change
the driver that Capybara uses to allow it to execute Javascript, but this is
not related to Jasmine. You can read more about the various Capybara drivers in
the project Readme. You should only need to add the js: true flag when you are
testing a page with significant dynamic behavior provided by javascript.

Each of the Capybara drivers is expected to perform very similarly, but there are
small differences and it looks like you’ve found one.

In addition, the version of Capybara will effect how title can be interacted
with. Specifically, as of Capybara 2.1, additional methods have been added to
Capybara so you can make assertions against the title like:

expect(page).to have_title 'Hashtag'

Hope that all helps.