|
| 1 | +require 'spec_helper' |
| 2 | + |
| 3 | +describe Overcommit::Hook::PreCommit::BundleOutdated do |
| 4 | + let(:config) { Overcommit::ConfigurationLoader.default_configuration } |
| 5 | + let(:context) { double('context') } |
| 6 | + subject { described_class.new(config, context) } |
| 7 | + |
| 8 | + context 'when Gemfile.lock is ignored' do |
| 9 | + around do |example| |
| 10 | + repo do |
| 11 | + touch 'Gemfile.lock' |
| 12 | + echo('Gemfile.lock', '.gitignore') |
| 13 | + `git add .gitignore` |
| 14 | + `git commit -m "Ignore Gemfile.lock"` |
| 15 | + example.run |
| 16 | + end |
| 17 | + end |
| 18 | + |
| 19 | + it { should pass } |
| 20 | + end |
| 21 | + |
| 22 | + context 'when Gemfile.lock is not ignored' do |
| 23 | + around do |example| |
| 24 | + repo do |
| 25 | + example.run |
| 26 | + end |
| 27 | + end |
| 28 | + |
| 29 | + before do |
| 30 | + subject.stub(:execute).with(%w[git ls-files -o -i --exclude-standard]). |
| 31 | + and_return(double(stdout: '')) |
| 32 | + subject.stub(:execute).with(%w[bundle outdated --strict --parseable]). |
| 33 | + and_return(result) |
| 34 | + end |
| 35 | + |
| 36 | + context 'and it reports some outdated gems' do |
| 37 | + let(:result) do |
| 38 | + double(stdout: <<-EOF |
| 39 | +Warning: the running version of Bundler is older than the version that created the lockfile. We suggest you upgrade to the latest version of Bundler by running `gem install bundler`. |
| 40 | +
|
| 41 | +airbrake (newest 5.3.0, installed 5.2.3, requested ~> 5.0) |
| 42 | +aws-sdk (newest 2.3.3, installed 2.3.1, requested ~> 2) |
| 43 | +font-awesome-rails (newest 4.6.2.0, installed 4.6.1.0) |
| 44 | +mechanize (newest 2.7.4, installed 2.1.1) |
| 45 | +minimum-omniauth-scaffold (newest 0.4.3, installed 0.4.1) |
| 46 | +airbrake-ruby (newest 1.3.0, installed 1.2.4) |
| 47 | +aws-sdk-core (newest 2.3.3, installed 2.3.1) |
| 48 | +aws-sdk-resources (newest 2.3.3, installed 2.3.1) |
| 49 | +config (newest 1.1.1, installed 1.1.0) |
| 50 | +ruby_parser (newest 3.8.2, installed 3.8.1) |
| 51 | +EOF |
| 52 | + ) |
| 53 | + end |
| 54 | + |
| 55 | + it { should warn } |
| 56 | + end |
| 57 | + |
| 58 | + context 'and it reports bundle up to date' do |
| 59 | + let(:result) do |
| 60 | + double(stdout: <<-EOF |
| 61 | +Warning: the running version of Bundler is older than the version that created the lockfile. We suggest you upgrade to the latest version of Bundler by running `gem install bundler`. |
| 62 | +
|
| 63 | +EOF |
| 64 | + ) |
| 65 | + end |
| 66 | + |
| 67 | + it { should pass } |
| 68 | + end |
| 69 | + end |
| 70 | +end |
0 commit comments