Sha256: 3d321862f775a677386afb8e51cc90ce3d4fe961772b0bab23f9c8fef38967df

Contents?: true

Size: 829 Bytes

Versions: 8

Compression:

Stored size: 829 Bytes

Contents

require 'cooperator'

class First
  prepend Cooperator

  def perform
  end

  def rollback
    $first = true
  end
end

class Second
  prepend Cooperator

  def perform
  end

  def rollback
    $second = true
  end
end

class Third
  prepend Cooperator

  def perform
    failure!
  end

  def rollback
    $third = true
  end
end

class Interactor
  prepend Cooperator

  def perform
    cooperate First, Second, Third
  end
end

prepare do
  $first = false
  $second = false
  $third = false
end

spec 'third rollback is not called when a failure is encountered' do
  Interactor.perform

  refute $third
end

spec 'second rollback is called when a failure is encountered' do
  Interactor.perform

  assert $second
end

spec 'first rollback is called when a failure is encountered' do
  Interactor.perform

  assert $first
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
cooperator-0.3.3 spec/rollback.rb
cooperator-0.3.2 spec/rollback.rb
cooperator-0.3.1 spec/rollback.rb
cooperator-0.2.5 spec/rollback.rb
cooperator-0.2.4 spec/rollback.rb
cooperator-0.2.3 spec/rollback.rb
cooperator-0.2.2 spec/rollback.rb
cooperator-0.2.1 spec/rollback.rb