Skip to content

Commit d2f797a

Browse files
swelthernickcharlton
authored andcommitted
Allow "ruby file:" syntax in Gemfile
This allows the use of the `ruby file:` syntax in Gemfiles, e.g.: ```ruby ruby file: "../.ruby-version" … ``` Previously, Appraisal would fail with `wrong number of arguments (given 0, expected 1) (ArgumentError)` ``` …/appraisal-2.5.0/lib/appraisal/bundler_dsl.rb:66:in `ruby': wrong number of arguments (given 0, expected 1) (ArgumentError) from …/appraisal-2.5.0/lib/appraisal/gemfile.rb:27:in `run' from …/appraisal-2.5.0/lib/appraisal/gemfile.rb:19:in `instance_eval' from …/appraisal-2.5.0/lib/appraisal/gemfile.rb:19:in `run' from …/appraisal-2.5.0/lib/appraisal/gemfile.rb:25:in `block in dup' … ```
1 parent 602cdd9 commit d2f797a

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

lib/appraisal/bundler_dsl.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,9 @@ def source(source, &block)
6565
end
6666
end
6767

68-
def ruby(ruby_version)
68+
def ruby(ruby_version = nil, **kwargs)
6969
@ruby_version = ruby_version
70+
@ruby_version = kwargs unless ruby_version
7071
end
7172

7273
def git(source, options = {}, &block)

spec/appraisal/gemfile_spec.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,4 +440,17 @@
440440
expect(gemfile.load(tmpfile.path)).to include(File.dirname(tmpfile.path))
441441
end
442442
end
443+
444+
it "supports the ruby file: syntax" do
445+
gemfile = Appraisal::Gemfile.new
446+
447+
gemfile.ruby file: ".ruby-version"
448+
gemfile.source "one"
449+
450+
expect(gemfile.to_s).to eq <<-GEMFILE.strip_heredoc.strip
451+
source "one"
452+
453+
ruby {:file=>".ruby-version"}
454+
GEMFILE
455+
end
443456
end

0 commit comments

Comments
 (0)