Last active
December 22, 2015 20:19
-
-
Save wbrady/6525744 to your computer and use it in GitHub Desktop.
Spec to test that your Gemfile locks all of its gems
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# In your Gemfile: | |
# | |
# group :test do | |
# gem 'gemnasium-parser', '0.1.9' | |
# end | |
# | |
require 'spec_helper' | |
describe 'Gemfile' do | |
it 'should lock all gems' do | |
gemfile = Gemnasium::Parser.gemfile(File.read(File.join(Rails.root, 'Gemfile'))) | |
non_specific_gems = gemfile.dependencies.reject{|dep| dep.requirement.requirements.first.first == '='} | |
msg = "#{non_specific_gems.map(&:name).join(', ')} #{non_specific_gems.size > 1 ? 'are' : 'is'} not locked" | |
non_specific_gems.should be_empty, msg | |
end | |
end |
gemnasium doesn't seem to play well with ruby 1.8 though.
Probably just as well to regex the gemfile manually.
Oops didn't check 1.8
Well if you don't need 1.8 support, this latest revision won't allow ~>
either
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice find.