Culerity Integration with RVM
If you wish to use an rvm-based ruby and jruby with Culerity, please follow the steps below. Please note that the first set of instructions but currently rely on you using recent versions which make this task a lot simpler.
Setting up jruby
Before you can start, you need to install jruby and celerity. In a nutshell, you need to:
-
Install jruby -
∴ rvm install jruby
-
Create a celerity gemset and use it -
∴ rvm use jruby@celerity --create
-
Install the celerity gem in this gemset -
∴ gem install celerity
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
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're on a recent version, you should be able to simply add the following to your 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 simplifying this on 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 handy google groups post by Matt Patterson announcing his patches with simplified 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