Sha256: 419b5bce736789023460f93d004df87cea08e62f7caa2f73f9c634b99839b0ae

Contents?: true

Size: 700 Bytes

Versions: 9

Compression:

Stored size: 700 Bytes

Contents

require 'cooperator'

class Failure
  prepend Cooperator

  def perform
    $before = true
    failure!
    $after = true
  end
end

class FailureWithErrors
  prepend Cooperator

  def perform
    failure! action: 'Failure!'
  end
end

prepare do
  $before = false
  $after = false
end

subject Cooperator

spec '.perform runs until #failure! is called' do
  Failure.perform

  assert $before
  refute $after
end

spec '.perform returns a failure context' do
  context = Failure.perform

  assert context, :failure?
  refute context, :success?
end

spec '.perform returns a failure with errors context' do
  context = FailureWithErrors.perform

  assert context.errors, :==, action: ['Failure!']
end

Version data entries

9 entries across 9 versions & 1 rubygems

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