Sha256: 304b43a3a94a2e36cb32b36c06555b1cfe1d2b259f38ab81de30b06e95681798

Contents?: true

Size: 1 KB

Versions: 8

Compression:

Stored size: 1 KB

Contents

require 'spec_helper'

module EndState
  module Finalizers
    describe Persistence do
      subject(:finalizer) { Persistence.new(object, state, params) }
      let(:object) { double :object, save: nil }
      let(:state) { :b }
      let(:params) { {} }

      describe '#call' do
        it 'calls save on the object' do
          finalizer.call
          expect(object).to have_received(:save)
        end

        context 'when the object does not respond to save' do
          let(:object) { Object.new }

          it 'returns false' do
            expect(finalizer.call).to be_false
          end
        end
      end

      describe '#rollback' do
        it 'calls save on the object' do
          finalizer.rollback
          expect(object).to have_received(:save)
        end

        context 'when the object does not respond to save' do
          let(:object) { Object.new }

          it 'returns true' do
            expect(finalizer.rollback).to be_true
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
end_state-0.4.0 spec/end_state/finalizers/persistence_spec.rb
end_state-0.3.2 spec/end_state/finalizers/persistence_spec.rb
end_state-0.3.1 spec/end_state/finalizers/persistence_spec.rb
end_state-0.3.0 spec/end_state/finalizers/persistence_spec.rb
end_state-0.2.0 spec/end_state/finalizers/persistence_spec.rb
end_state-0.1.0 spec/end_state/finalizers/persistence_spec.rb
end_state-0.0.2 spec/end_state/finalizers/persistence_spec.rb
end_state-0.0.1 spec/end_state/finalizers/persistence_spec.rb