Culerity Integration with RVM
If you wish to use an rvm-based ruby and jruby with Culerity, please follow the steps below. Note that the first set of instructions currently rely on you using recent versions.
Setting up jruby
Before you can start, you need to install jruby and celerity. In a nutshell, you need to:
- Install jruby:
- Create a celerity gemset and use it:
- Install the celerity gem in this gemset:
rvm install jruby
rvm use jruby@celerity --create
gem install celerity culerity
Which this done, you should be able to confirm that you have celerity by doing:
gem list | grep celerity
With this done, the next key step is to set up a wrapper for it. To do this, we run:
rvm wrapper jruby@celerity celerity jruby
You can set the path for culerity can now be set via environment variable in your .bash_profile or such:
export JRUBY_INVOCATION="$(readlink "$(which celerity_jruby)")"
Which should create the file ~/.rvm/bin/celerity_jruby, pointing to the correct ruby. You can verify this by doing:
celerity_jruby -S gem list | grep celerity
Assuming this is correct, you can move on to the next step.
Configuring Culerity to use your jruby Celerity
Once you've generated the wrapper, your next task is to tell Culerity which jruby to use. If you are on a recent version, you add the following code snippet to the project's features/support/env.rb file:
Culerity.jruby_invocation = File.expand_path("~/.rvm/bin/celerity_jruby")
Replacing ~/.rvm/bin with whatever "echo $rvm_bin_path" shows on your terminal if it fails (Thanks to Matt Patterson for making this more clear on the Culerity's side).
On older versions of Culerity, you need to manually specify hooks to toggle the env. In order to do this, you need to first get the location of the jruby wrappers dir. To find this, run the following in your Terminal and note the output:
dirname "$(readlink "$(which celerity_jruby)")"
Which should return something similar to "/Users/sutto/.rvm/wrappers/jruby-1.5.1@celerity" as an example. Next, you need to create features/support/culerity-hooks.rb containing the following code (with thanks to agibralter, mchung and ashleymoran):
# culerity-hooks.rb Before("@culerity,@celerity,@javascript") do |scenario| unless @original_path && @rvm_jruby_path @original_path = ENV['PATH'] @rvm_jruby_path = "/Users/sutto/.rvm/wrappers/jruby-1.5.1@celerity:" end ENV['PATH'] = @rvm_jruby_path end After("@culerity,@celerity,@javascript") do |scenario| ENV["PATH"] = @original_path end
Ensuring you replace "/Users/sutto/.rvm/wrappers/jruby-1.5.1@celerity" with the value you noted earlier.
Community Resources
- This Google Groups post by Matt Patterson announcing his patches with improved support.
- These awesome hooks from above exhibit proper scripting usage of RVM info as intended, awesomely done agibralter. correction by ashleymoran - Originally the preferred solution
- Original gist by mchung