Rspec :js => true issue (Rails 3)

Hey all,
I’m trying to get some Javascript test coverage in my app, so I
decided to implement Rspec and Capybara with Selenium. I follow Ryan
Bate’s Railscast episode 257 to a tee, but I still can’t get it to work.
Problems arise when I add :js => true. Without it, the following DOES
work. Here’s the spec:

describe “Info Page” do
describe “GET /premium” do
it “shows the info page”, :js => true do
visit ‘/premium’

Which, when executed, outputs the following (with --trace):


  1. Info Page GET /premium shows the info page
    Failure/Error: visit ‘/premium’
    Zip is not a module

    ./spec/requests/info_spec.rb:6:in `block (3 levels) in <top


Finished in 13.15 seconds
1 example, 1 failure

Failed examples:

rspec ./spec/requests/info_spec.rb:5 # Info Page GET /premium shows the
info page
rake aborted!
ruby /Users/loadeddesigns/.rvm/rubies/ruby-1.9.2-p290/bin/ruby -S rspec
./spec/requests/info_spec.rb failed
/Users/loadeddesigns/.rvm/gems/[email protected]/gems/rspec-core-2.7.1/lib/rspec/core/rake_task.rb:149:in
block (2 levels) in initialize' /Users/loadeddesigns/.rvm/gems/[email protected]/gems/rake-’
/Users/loadeddesigns/.rvm/gems/[email protected]/gems/rspec-core-2.7.1/lib/rspec/core/rake_task.rb:139:in
block in initialize' /Users/loadeddesigns/.rvm/gems/[email protected]/gems/rake-’
/Users/loadeddesigns/.rvm/gems/[email protected]/gems/rake-
block in execute' /Users/loadeddesigns/.rvm/gems/[email protected]/gems/rake-’
/Users/loadeddesigns/.rvm/gems/[email protected]/gems/rake-
execute' /Users/loadeddesigns/.rvm/gems/[email protected]/gems/rake- in invoke_with_call_chain’
mon_synchronize' /Users/loadeddesigns/.rvm/gems/[email protected]/gems/rake-’
/Users/loadeddesigns/.rvm/gems/[email protected]/gems/rake-
invoke' /Users/loadeddesigns/.rvm/gems/[email protected]/gems/rake-’
/Users/loadeddesigns/.rvm/gems/[email protected]/gems/rake-
block (2 levels) in top_level' /Users/loadeddesigns/.rvm/gems/[email protected]/gems/rake-’
/Users/loadeddesigns/.rvm/gems/[email protected]/gems/rake-
block in top_level' /Users/loadeddesigns/.rvm/gems/[email protected]/gems/rake-’
/Users/loadeddesigns/.rvm/gems/[email protected]/gems/rake-
top_level' /Users/loadeddesigns/.rvm/gems/[email protected]/gems/rake- in run’
/Users/loadeddesigns/.rvm/gems/[email protected]/gems/rake-
standard_exception_handling' /Users/loadeddesigns/.rvm/gems/[email protected]/gems/rake-’
/Users/loadeddesigns/.rvm/gems/[email protected]/gems/rake-
<top (required)>' /Users/loadeddesigns/.rvm/gems/[email protected]/bin/rake:19:inload’
/Users/loadeddesigns/.rvm/gems/[email protected]/bin/rake:19:in

I am having a really hard time trying to track down the cause of this…
Heck, the only reason why I am using RSpec and Capybara is for
Javascript support (other tests in the app use test unit).

Any and all help is appreciated!


  • Jeff


I got this working by using tips from the following blog:

I changed my gemfile to use the following gems:

For Testing w/ Javascript support.

Rspec needs to be in the development group to expose generators and

rake tasks without

having to type RAILS_ENV=test.

gem ‘rspec-rails’, ‘~> 2.7.0’, group: :development
gem ‘capybara-webkit’, ‘~> 0.7.2’

Debugging Tests

gem ‘launchy’

This allows for database transactions to refresh during testing with

capybara and selenium.

gem ‘database_cleaner’, ‘~> 0.6.7’

As a dependency of capybara-webkit, I also installed the QT libraries.

I still don’t know why I was getting the “Zip is not a module” error,
but I hope this helps someone in the future.


  • Jeff

Okay, maybe I spoke too soon. Can’t help but be hopeful, lol.

I have a bunch of “fill_in” statements for the page I’m testing, such

fill_in “shopper_first_name”, with: ‘Jeffrey’

etc… however, although I’m not getting an error anymore, it DOES NOT
fill in the text UNLESS I get rid of :js => true. I’m going to be
testing ajax, so I need this functionality…

This headache is turning into a migraine…



  • Jeff

headslam I just needed to RTFM more closely. I assumed the fields
weren’t being populated because I was using launchy to
save_and_open_page to see if it had done so. Capybara-webkit doesn’t
instantiate a browser though, it access the renderer (webkit) directly.

This is working now :stuck_out_tongue:

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs