thoughtbot / appraisal

A Ruby library for testing your library against different versions of dependencies.
https://thoughtbot.com
MIT License
1.25k stars 107 forks source link

Fix support for `ruby file: …` Gemfile syntax #219

Closed tisba closed 4 months ago

tisba commented 4 months ago

I was looking for a way to use ruby file: '.ruby-version' in my gem for testing. Using this Appraisals file current yields an error:

appraise "foo" do
  ruby file: '../.ruby-version'

  gem "faraday-follow_redirects", "0.3.0"
end

After digging around a little, I noticed that Appraisal::BundlerDSL#ruby_version is emitting a block when the Gemfile DSL ruby method is used. Currently, this is emitted – notice that this is not a method argument, but a block 🐛:

ruby {:file=>"../.ruby-version"}

So instead, we have to add () to ensure the arguments stay arguments:

ruby({:file=>"../.ruby-version"})

~PS: I would like to add specs, but I'm unable to run specs (see https://github.com/thoughtbot/appraisal/issues/218).~

tisba commented 4 months ago

Hey @nickcharlton, maybe you can take a look at this one?

I copied the style of the acceptance test, so I'm not sure what do do about the hound bot comments 🤔

I opted to preserve the generated output when ruby is called with a String: I figured this was easy enough. If you feel differently about it, let me know. Same with testing this on the acceptance-level. Happy to move the spec elsewhere!

Locally the tests are all green as discussed in #218, using Bundler 2.3.27 via:

bundle install
bundle _2.3.27 _ update --bundler
bundle install
rspec
nickcharlton commented 4 months ago

Great, thanks for doing this! I tested it out locally, and it's working for me with Bundler 2.3.27.

I just deleted the Hound comments — I've been bit by bit moving to standard and this is on my list to do that here too. As it's copying existing styles anyway, I think it's fine.