Skip to content

@mchung /capybara+culerity.markdown
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Setting up Capybara (w/ @culerity support) using rvm-managed Rubies.

The following steps will setup ruby 1.8.7-p174 as well as the gems required for Capybara and Culerity support. It will also install Celerity using macports-managed JRuby. Note: sudo is not used.

Steps: $ rvm install 1.8.7-p174 $ rvm 1.8.7-p174 $ gem install rails cucumber capybara webrat rspec cucumber-rails email_spec database_cleaner rspec-rails factory_girl clearance formtastic sqlite3-ruby pg thin mongrel paperclip will_paginate ZenTest autotest-rails culerity $ rvm jruby-1.4.0 $ gem install celerity $ rvm 1.8.7-p174 $ cd your/rails/app

Add hooks.rb to your features/support/ directory. Make sure to update the paths. Now, when using Capybara, @culerity tagged scenarios will run correctly.

When you run rake features, ruby-1.8.7-p174 will launch your test suite. When cucumber sees a @culerity tagged scenario, it will shell out to jruby. hooks.rb is responsible for adjusting the various RubyGems environment variables so that jruby is found.

Initially, I used the JRuby from MacPorts, but since I was using an rvm managed Ruby, JRuby picked up on the RubyGems environment variables. This had the unpleasant side effect of causing JRuby to install gems into the gemdir managed by ruby-1.8.7-p174!

Did I mention this was a nasty hack?

Before("@culerity") do |scenario|
#################################
@rvm_jruby_string = "jruby-1.4.0"
#################################
@rvm_jruby_home = "#{ENV["rvm_path"]}/#{@rvm_jruby_string}"
@rvm_jruby_gem_path = "#{ENV["rvm_gem_path"]}/#{@rvm_jruby_string}"
@rvm_jruby_os_path = "#{@rvm_jruby_home}/bin:#{@rvm_jruby_gem_path}/bin"
@rvm_ruby_string = ENV["rvm_ruby_string"]
@rvm_ruby_home = "#{ENV["rvm_path"]}/#{@rvm_ruby_string}"
@rvm_ruby_gem_path = "#{ENV["rvm_gem_path"]}/#{@rvm_ruby_string}"
@os_path = ENV["PATH"]
ENV["GEM_HOME"] = @rvm_jruby_gem_path
ENV["GEM_PATH"] = @rvm_jruby_gem_path
ENV["MY_RUBY_HOME"] = @rvm_jruby_home
ENV["PATH"] = "#{@rvm_jruby_os_path}:#{ENV['PATH']}"
end
After("@culerity") do |scenario|
ENV["GEM_HOME"] = @rvm_ruby_gem_path
ENV["GEM_PATH"] = @rvm_ruby_gem_path
ENV["MY_RUBY_HOME"] = @rvm_ruby_home
ENV["PATH"] = @os_path
end
tonkatsu:~ mchung$ rvm jruby ; rvm --shebang inspect jruby
/Users/mchung/.rvm/jruby-1.4.0/bin/jruby:
#!/bin/bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.