Sha256: 7631ddd2dbcb29b65d52e8745f9167a52c36ef6867e4846ebb71b4f0b2bdf91d
Contents?: true
Size: 1.45 KB
Versions: 4
Compression:
Stored size: 1.45 KB
Contents
require 'spec_helper' describe Zertico::Organizer do let(:successful_organizer) { BuyProductOrganizer } let(:failed_organizer) { RegisterOrganizer } describe '.organize' do it 'should set the interactors to organize' do 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 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 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 expect(failed_organizer.rollback).to eq([true]) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems