Sha256: a1ef4dd0dc575bae0febf82a20266b0a5131612ac5c9a1f0a57ead929bd80fba

Contents?: true

Size: 937 Bytes

Versions: 12

Compression:

Stored size: 937 Bytes

Contents

require 'cooperator'

class ImplicitSuccess
  prepend Cooperator

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

class ExplicitSuccess
  prepend Cooperator

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

prepare do
  $before = false
  $after = false
end

subject Cooperator

scope 'implicit success' do
  spec '.perform runs until #success! is called' do
    ImplicitSuccess.perform

    assert $before
    assert $after
  end

  spec '.perform returns a success context' do
    context = ImplicitSuccess.perform

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

scope 'explicit success' do
  spec '.perform runs until #success! is called' do
    ExplicitSuccess.perform

    assert $before
    refute $after
  end

  spec '.perform returns a success context' do
    context = ExplicitSuccess.perform

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

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
cooperator-0.3.3 spec/success.rb
cooperator-0.3.2 spec/success.rb
cooperator-0.3.1 spec/success.rb
cooperator-0.2.5 spec/success.rb
cooperator-0.2.4 spec/success.rb
cooperator-0.2.3 spec/success.rb
cooperator-0.2.2 spec/success.rb
cooperator-0.2.1 spec/success.rb
cooperator-0.2.0 spec/success.rb
cooperator-0.1.2 spec/success.rb
cooperator-0.1.1 spec/success.rb
cooperator-0.1.0 spec/success.rb