Sha256: ed48bb5bdf2740745982cd1fd50251a5df939eee7a92f14a403d4640465ab767

Contents?: true

Size: 1.27 KB

Versions: 1

Compression:

Stored size: 1.27 KB

Contents

require 'spec_helper'
require 'tasks/gem/bump_task'
require 'git'
require 'anvil'

describe Gem::BumpTask do
  subject { Gem::BumpTask.new :major }

  describe '#task' do
    before  { subject.stub(:read_version).and_return('2.0.0') }

    it 'bumps the version and writes it' do
      expect(subject).to receive(:prepare_repo).and_return(true)
      expect(subject).to receive(:write_version).and_return(true)

      expect(subject.task).to eq('3.0.0')
    end
  end

  describe '#write_version' do
    it 'writes the file and push the changes' do
      expect(subject).to receive(:version_file).with('w+')
      expect(subject).to receive(:commit_and_tag)
    end

    after { subject.send :write_version, '2.0.0' }
  end

  describe '#prepare_repo' do
    context 'on a clean repo' do
      before do
        subject.stub(:clean?).and_return(true)
        subject.stub(:git).and_return(double)
      end

      it 'pulls' do
        expect(subject.send(:git)).to receive(:pull)
      end

      after { subject.send :prepare_repo }
    end

    context 'on a dirty repo' do
      before { subject.stub(:clean?).and_return(false) }

      it 'raises RepoNotClean' do
        expect do
          subject.send :prepare_repo
        end.to raise_error(Anvil::RepoNotClean)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
anvil-core-0.0.1.pre.alpha.3 spec/lib/tasks/gem/bump_task_spec.rb