spec/zertico/organizer_spec.rb in zertico-1.3.0 vs spec/zertico/organizer_spec.rb in zertico-2.0.0.alpha.1
- old
+ new
@@ -4,31 +4,48 @@
let(:successful_organizer) { BuyProductOrganizer }
let(:failed_organizer) { RegisterOrganizer }
describe '.organize' do
it 'should set the interactors to organize' do
- successful_organizer.interactors_classes.should == [ CreateProductInteractor, CreateInvoiceInteractor ]
+ expect(successful_organizer.interactors_classes).to eq([ CreateProductInteractor, CreateInvoiceInteractor ])
end
+
+ it 'should initialize the performed interactors array' do
+ expect(successful_organizer.performed).to eq([])
+ end
+
+ it 'should initialize the instance objects hash' do
+ expect(successful_organizer.instances).to eq({})
+ end
end
describe '.perform' do
context 'with success' do
it 'should return true' do
- successful_organizer.perform({}).should be_true
+ expect(successful_organizer.perform({})).to eq(true)
end
+
+ before :each do
+ @organizer = successful_organizer
+ @organizer.perform({})
+ end
+
+ it 'should set the pass the instances to the interactors' do
+ expect(@organizer.performed.last.instance_variable_get('@product')).to be_an_instance_of(Product)
+ end
end
context 'with failure' do
it "should return a mapping with the interactor's rollback results" do
- failed_organizer.perform({}).should == [true]
+ expect(failed_organizer.perform({})).to eq([true])
end
end
end
describe '#rollback' do
context 'when it raise an exception' do
it "should return a mapping with the interactor's rollback results" do
- failed_organizer.rollback.should == [true]
+ expect(failed_organizer.rollback).to eq([true])
end
end
end
end
\ No newline at end of file