Skip to content

Instantly share code, notes, and snippets.

@wbrady
Last active December 22, 2015 20:19
Show Gist options
  • Save wbrady/6525744 to your computer and use it in GitHub Desktop.
Save wbrady/6525744 to your computer and use it in GitHub Desktop.
Spec to test that your Gemfile locks all of its gems
# 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
@jcalvert
Copy link

Nice find.

@jcalvert
Copy link

gemnasium doesn't seem to play well with ruby 1.8 though.

Probably just as well to regex the gemfile manually.

@wbrady
Copy link
Author

wbrady commented Sep 11, 2013

Oops didn't check 1.8

@wbrady
Copy link
Author

wbrady commented Sep 11, 2013

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