How can I get Capybara @javascript tags executing correctly in Cucumber on a Rails 3 project?

By : justsee
Source: Stackoverflow.com
Question!

I've swapped out Webrat for Capybara on a new Rails 3 project. I ran through Tim Riley's great post on it here ( http://openmonkey.com/articles/2010/04/javascript-testing-with-cucumber-capybara ), and also cloned his repository, executed the example cucumber feature, and saw the browser window fire open. So the whole Cucumber, Capybara, Selenium stack seems to work fine in that instance.

However if I create a new Rails 3 project, run through setting up a similar example project, and annotate a Scenario with @javascript the browser window does not fire, and the Cucumber Scenario just fails with the usual Command failed with status (1) event (which, in the instance of failing or pending steps, Cucumber triggers by design for the benefit of CI tools).

Apart from the @javascript functionality provided by Capybara, all other features work fine.

Am I missing something incredibly obvious? Is there a way for a BDD newcomer to look deeper into the issues (the stack trace just shows the standard rake error when Cucumber fails).

  • rvm 1.9.2-head
  • gem 'rails', '3.0.0.rc'
  • gem 'cucumber'
  • gem 'cucumber-rails'
  • gem 'capybara'
  • gem 'culerity'
  • gem 'celerity', :require => nil
By : justsee


Answers

Capybara is "lazy" in that it will open the browser window first when it is actually needed. If you're actually doing something that would require a browser, Capybara won't open one.

By : jnicklas


Maybe you have not installed the mongrel gem. The browser automation is somehow not working with webrick and i have experienced the same silent failing the you describe here.

Adding

gem 'mongrel', '>= 1.2.0.beta.1'

to my Gemfile solved it.



I made an example app on how to configure that: github.com/lailsonbm/contact_manager_app/



This video can help you solving your question :)
By: admin