Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Allow configuration of jruby invocation to allow easy use of, e.g., RVM

  • Loading branch information...
commit 2c784f4db41642af74fd723cfe787a1437c57de9 1 parent 7c0a629
@fidothe fidothe authored langalex committed
Showing with 30 additions and 5 deletions.
  1. +7 −3 lib/culerity.rb
  2. +23 −2 spec/culerity_spec.rb
View
10 lib/culerity.rb
@@ -32,12 +32,16 @@ def self.celerity_invocation
"require '#{culerity_root}/lib/culerity/celerity_server'; Culerity::CelerityServer.new(STDIN, STDOUT)"
end
- def self.jruby_path
- "jruby"
+ def self.jruby_invocation
+ @jruby_invocation ||= "jruby"
+ end
+
+ def self.jruby_invocation=(invocation)
+ @jruby_invocation = invocation
end
def self.run_server
- IO.popen(%{#{jruby_path} -e "#{celerity_invocation}"}, 'r+').extend(ServerCommands)
+ IO.popen(%{#{jruby_invocation} -e "#{celerity_invocation}"}, 'r+').extend(ServerCommands)
end
def self.run_rails(options = {})
View
25 spec/culerity_spec.rb
@@ -60,6 +60,10 @@ def stub_rails_root!
IO.stub!(:popen)
end
+ after(:each) do
+ Culerity.jruby_invocation = nil
+ end
+
it "knows where it is located" do
Culerity.culerity_root.should == File.expand_path(File.dirname(__FILE__) + '/../')
end
@@ -70,8 +74,16 @@ def stub_rails_root!
Culerity.celerity_invocation.should == "require '/path/to/culerity/lib/culerity/celerity_server'; Culerity::CelerityServer.new(STDIN, STDOUT)"
end
- it "knows which JRuby to invoke" do
- Culerity.jruby_path.should == 'jruby'
+ describe "invoking JRuby" do
+ it "knows how to invoke it" do
+ Culerity.jruby_invocation.should == 'jruby'
+ end
+
+ it "allows for the invocation to be overridden" do
+ Culerity.jruby_invocation = '/opt/local/bin/jruby'
+
+ Culerity.jruby_invocation.should == '/opt/local/bin/jruby'
+ end
end
it "shells out and sparks up jruby with the correct invocation" do
@@ -81,5 +93,14 @@ def stub_rails_root!
Culerity.run_server
end
+
+ it "allows a more complex situation, e.g. using RVM + named gemset" do
+ Culerity.stub!(:celerity_invocation).and_return('CORRECT INVOCATION')
+
+ IO.should_receive(:popen).with('rvm jruby@culerity -e "CORRECT INVOCATION"', 'r+')
+
+ Culerity.jruby_invocation = "rvm jruby@culerity"
+ Culerity.run_server
+ end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.