thoughtbot / appraisal

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

Preserve conditional gems #147

Closed mlt closed 4 years ago

mlt commented 5 years ago

Here is the use case... I would like to test a gem versus Rails 4 and 5 on Travis using regular ruby and jruby. While I can hide some conditional stuff in dot gemspec file, there is no way to check whether Rails 4 or Rails 5 is being used. This is somewhat critical as while using jruby and rails 4, I need

gem 'activerecord-jdbc-adapter', '~> 1.3.25'
gem 'activerecord-jdbcsqlite3-adapter'

whereas for Rails 5 I need

gem 'activerecord-jdbc-adapter', '~> 52.1'
gem 'activerecord-jdbcsqlite3-adapter'

and plain

gem 'sqlite3'

for everything else. There is a sort of bug with activerecord-jdbc-adapter that allows to install incorrect version for Rails 4.2.10, but it is still a valid case as opposed to hand editing generated gemfiles.

Could we have, perhaps, a way to pass environment variables to set with appraise DSL in Appraisals file?

P.S. Also I see often in projects gem ... if ENV['CI'] that gets flattened out by appraisal.

bolshakov commented 5 years ago

@mlt it is achievable with current Appraisal:

[
  { rails: '4.2.11', activerecord-jdbc-adapter: '~> 1.3.25',  activerecord-jdbcsqlite3-adapter: ''},
  { rails: '5.2.2', activerecord-jdbc-adapter: '~>  52.1'',  activerecord-jdbcsqlite3-adapter: '', sqlite3: '' },
].each do |deps|
  appraise deps.map { |name, requirement| "#{name}-#{requirement}" }.join('_') do
    deps.each { |name, requirement| gem name, requirement }
  end
end
nickcharlton commented 4 years ago

I think this is something we can solve nicer if we solve #131. So I'm going to close this one. Please re-open if that wouldn't solve this particular case though.