Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support gemspec in Appraisals #48

Closed
garysweaver opened this issue Apr 25, 2013 · 5 comments
Closed

Support gemspec in Appraisals #48

garysweaver opened this issue Apr 25, 2013 · 5 comments

Comments

@garysweaver
Copy link

Even though Appraisal supports gemspec in Gemfile, if you only want to include the gemspec for certain appraisals within the Appraisals file. Most of the time you want to run tests against the local gem, but sometimes you may have a set of tests that you want to run without the local gem, so you'd want something like this in Appraisals:

appraise "with gem" do
  gemspec
  # ...
end

appraise "without gem" do
  # ...
end

But currently that would result in an error, e.g.:

undefined local variable or method `gemspec' for #<Appraisal::Appraisal:0x007fd0dca4eb10>

This is probably an edge case, but it seems like Appraisals should work like like a more flexible Gemfile, and for it to do that, it seems like it should be able to support loading the gemspec by specifying Appraisals instead of Gemfile if that is required.

@sikachu
Copy link
Contributor

sikachu commented Apr 25, 2013

Yes, my plan is to make Appraisal file to works like a Gemfile. However, I'm curious on why would you want to load your gem's dependency in one appraisal and not in the other, though ...

Would you mind sharing a real-world example?

@garysweaver
Copy link
Author

This morning I setup Appraisals with strong_parameters project to run strong_parameters tests against each version of Rails. However, due to a gotcha in strong_parameters, the strong_parameters gem itself cannot be included when testing itself against Rails 4.0.0.beta1 because it is included. Trying to include the strong_parameters gem actually causes it to fail. I assumed I could just put gemspec in Appraisals for within appraise blocks for Rails 3.x (I had a loop that was checking the latest 3.1.x, 3.2.x against every possible strong params version that was capable of running with that version) and another appraise block for Rails 4.0.0.beta1 that would not include the gemspec (and I had removed gemspec from the Gemfile at the root and made some other alterations). I am not blocked by not having this feature, and I doubt that dhh or anyone else on that project would want strong_parameters appraised like that, but I was having trouble with something and wanted to build confidence and test it out.

BTW- Thanks so much for your work on Appraisals. I'm using it in a few projects now and it's awesome. I like not having to be dependent on travis or other CI just to run tests locally against various versions of gems.

@garysweaver
Copy link
Author

e.g.

appraise 'rails_4.0.0.beta1' do
  # no gemspec because it includes its own strong parameters and get errors if we include it
  gem 'rails', '4.0.0.beta1'
end

['0.1.3', '0.1.4', '0.1.5', '0.1.6', '0.2.0', 'edge'].each do |strong_parameters_version|
  appraise "rails_3.2.13_with_strong_parameters_#{strong_parameters_version}" do
    gemspec
    gem 'rails', '3.2.13'
    if strong_parameters_version == 'edge'
      gem 'strong_parameters', :git => 'git://github.com/rails/strong_parameters.git'
    else
      gem 'strong_parameters', strong_parameters_version
    end
  end
end

['0.1.5', '0.1.6', '0.2.0', 'edge'].each do |strong_parameters_version|
  appraise "rails_3.1.12_with_strong_parameters_#{strong_parameters_version}" do
    gemspec
    gem 'rails', '3.1.12'
    if strong_parameters_version == 'edge'
      gem 'strong_parameters', :git => 'git://github.com/rails/strong_parameters.git'
    else
      gem 'strong_parameters', strong_parameters_version
    end
  end
end

@sikachu
Copy link
Contributor

sikachu commented Apr 25, 2013

Got it. Thanks for the example. 👍

@garysweaver
Copy link
Author

👍 Thanks, @sikachu!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants