spec/rake/funnel/tasks/paket_spec.rb in rake-funnel-0.18.0 vs spec/rake/funnel/tasks/paket_spec.rb in rake-funnel-0.19.0

- old
+ new

@@ -1,47 +1,47 @@ include Rake include Rake::Funnel::Support describe Rake::Funnel::Tasks::Paket do - before { + before do Task.clear - } + end describe 'defaults' do its(:name) { should == :paket } its(:paket) { should == '.paket/paket.exe' } its(:paket_args) { should == 'restore' } its(:bootstrapper) { should == '.paket/paket.bootstrapper.exe' } its(:bootstrapper_args) { should be_nil } end describe 'execution' do - before { + before do allow(subject).to receive(:sh) allow(Mono).to receive(:invocation).and_wrap_original do |_original_method, *args, &_block| args.compact end - } + end context 'overriding defaults' do - subject { + subject do described_class.new do |t| t.bootstrapper = 'custom bootstrapper.exe' t.bootstrapper_args = %w(arg1 arg2) t.paket = 'custom paket.exe' t.paket_args = %w(arg1 arg2) end - } + end - before { + before do allow(File).to receive(:exist?).and_return(false) allow(subject).to receive(:sh) - } + end - before { + before do Task[subject.name].invoke - } + end it 'should use custom bootstrapper' do expect(subject).to have_received(:sh).with(subject.bootstrapper, subject.bootstrapper_args) end @@ -49,13 +49,13 @@ expect(subject).to have_received(:sh).with(subject.paket, subject.paket_args) end end describe 'mono invocation' do - before { + before do Task[subject.name].invoke - } + end it 'should use mono invocation for bootstrapper' do expect(Mono).to have_received(:invocation).with(subject.bootstrapper, subject.bootstrapper_args) end @@ -63,19 +63,19 @@ expect(Mono).to have_received(:invocation).with(subject.paket, subject.paket_args) end end describe 'optional download' do - before { + before do allow(File).to receive(:exist?).with(subject.paket).and_return(paket_exists) allow(subject).to receive(:sh).with(subject.bootstrapper) - } + end context 'success' do - before { + before do Task[subject.name].invoke - } + end context 'paket.exe exists' do let(:paket_exists) { true } it 'should not run bootstrapper' do @@ -103,13 +103,13 @@ context 'failure' do context 'paket.exe exists' do let(:paket_exists) { true } context 'paket failed' do - before { + before do allow(subject).to receive(:sh).with(subject.paket, anything).and_raise - } + end it 'should fail' do expect { Task[subject.name].invoke }.to raise_error(RuntimeError) end end @@ -117,15 +117,19 @@ context 'paket.exe does not exist' do let(:paket_exists) { false } context 'bootstrapper failed' do - before { + before do allow(subject).to receive(:sh).with(subject.bootstrapper).and_raise - } + end it 'should not run paket' do - Task[subject.name].invoke rescue nil + begin + Task[subject.name].invoke + rescue + nil + end expect(subject).not_to have_received(:sh).with(subject.paket, subject.paket_args) end it 'should fail' do