Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added ability to map rvm versions to a specific version with config/a…

…ruba-rvm.yml
  • Loading branch information...
commit 989107a2dada87cab41910c2710e518e9d733b49 1 parent 4230210
@aslakhellesoy aslakhellesoy authored
View
1  History.txt
@@ -1,4 +1,5 @@
== In Git
+* Added ability to map rvm versions to a specific version with config/aruba-rvm.yml. (Aslak Hellesøy)
* Check for presence of files. (Aslak Hellesøy)
* Allow specification of rvm gemsets. (Aslak Hellesøy)
* Detect ruby commands and use current ruby when rvm is not explicitly used. (Aslak Hellesøy)
View
1  config/.gitignore
@@ -0,0 +1 @@
+aruba-rvm.yml
View
38 features/running_ruby.feature
@@ -4,22 +4,22 @@ Feature: Running ruby
I want to have control over what Ruby version is used,
possibly using a different Ruby than the one I launch Cucumber with.
- Scenario Outline: Specify a certain rvm
- Given I am using rvm "<rvm_ruby_version>"
+ Scenario: Run with ruby 1.9.1
+ Given I am using rvm "1.9.1"
When I run "ruby -e 'puts RUBY_VERSION'"
- Then I should see "<see>"
- And I should not see "<not_see>"
+ Then I should see "ruby-1.9.1-p378"
+ And I should not see "rvm usage"
- Examples:
- | rvm_ruby_version | see | not_see |
- | 1.9.1 | ruby-1.9.1-p378 | rvm usage |
- | jruby-1.4.0 | jruby 1.4.0 (ruby 1.8.7 patchlevel 174) | rvm usage |
- | bogus | Unrecognized command line argument | XX |
+ Scenario: Run with ruby JRuby
+ Given I am using rvm "jruby-1.4.0"
+ When I run "ruby -e 'puts JRUBY_VERSION'"
+ Then I should see "1.4.0"
+ And I should not see "rvm usage"
Scenario: Specify both rvm and gemset
Given I am using rvm "1.9.1"
- Given I am using rvm gemset "a-gemset-where-nothing-is-installed-except-default-rvm-gems"
- When I run "ruby -S gem list"
+ And I am using rvm gemset "a-gemset-where-nothing-is-installed-except-default-rvm-gems"
+ When I run "gem list"
Then I should see:
"""
@@ -28,6 +28,22 @@ Feature: Running ruby
"""
+ # I have trouble running rvm 1.8.7 in OS X Leopard, which is
+ # ruby-1.8.7-p249 (It segfaults rather often). However, a previous
+ # patchlevel of 1.8.7 runs fine for me: ruby-1.8.7-tv1_8_7_174
+ #
+ # In order to provide some level of flexibility (and readability)
+ # it should be possible to set up a mapping from a version specified
+ # in Gherkin to an *actual* version.
+ Scenario: Specify an alias for an rvm
+ Given I have a local file named "config/aruba-rvm.yml" with:
+ """
+ 1.8.7: ruby-1.8.7-tv1_8_7_174
+ """
+ And I am using rvm "1.8.7"
+ When I run "ruby --version"
+ Then I should see "patchlevel 174"
+
# To verify this, make sure current rvm is *not* JRuby and run:
#
# ~/.rvm/rubies/jruby-1.4.0/bin/jruby -S cucumber features/running_ruby.feature
View
4 features/support/step_definitions.rb
@@ -1,3 +1,7 @@
+Given /^I have a local file named "([^\"]*)" with:$/ do |filename, content|
+ File.open(filename, 'w') {|io| io.write(content)}
+end
+
Then /^I should see the JRuby version$/ do
Then %{I should see "#{JRUBY_VERSION}"}
end
View
19 lib/aruba/api.rb
@@ -63,7 +63,11 @@ def combined_output
end
def use_rvm(rvm_ruby_version)
- @rvm_ruby_version = rvm_ruby_version
+ if File.exist?('config/aruba-rvm.yml')
+ @rvm_ruby_version = YAML.load_file('config/aruba-rvm.yml')[rvm_ruby_version] || rvm_ruby_version
+ else
+ @rvm_ruby_version = rvm_ruby_version
+ end
end
def use_rvm_gemset(rvm_gemset)
@@ -90,13 +94,20 @@ def run(command, world=nil, announce=nil)
@last_stderr = IO.read(stderr_file.path)
end
+ RUBY_PATTERN = /^ruby\s/
+ RUBY_SCRIPTS_PATTERN = /^(?:gem|rake)\s/
+
def detect_ruby(command)
- if command =~ /^ruby\s/
+ ruby_command = command =~ RUBY_PATTERN
+ ruby_script = command =~ RUBY_SCRIPTS_PATTERN
+ if ruby_command || ruby_script
if @rvm_ruby_version
rvm_ruby_version_with_gemset = @rvm_gemset ? "#{@rvm_ruby_version}%#{@rvm_gemset}" : @rvm_ruby_version
- command.gsub(/^ruby\s/, "rvm #{rvm_ruby_version_with_gemset} ")
- else
+ command = "rvm #{rvm_ruby_version_with_gemset} #{command}"
+ elsif ruby_command
command.gsub(/^ruby\s/, "#{File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])} ")
+ else
+ "#{File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])} -S #{command}"
end
else
command
Please sign in to comment.
Something went wrong with that request. Please try again.