Sha256: 87a3492005987e376507ae7e8988d19a903df804f1ceb4f7994341cd041e5f66

Contents?: true

Size: 714 Bytes

Versions: 7

Compression:

Stored size: 714 Bytes

Contents

# encoding: utf-8

require 'spec_helper'
require 'ice_nine/support/recursion_guard'

describe IceNine::RecursionGuard, '.guard' do
  subject { object.guard(object_id, &method(:block)) }

  let(:object)       { IceNine::RecursionGuard }
  let(:object_id)    { 1                       }
  let(:return_value) { stub('return_value')    }

  context 'when the block is not recursive' do
    def block
      return_value
    end

    it 'returns the expected value' do
      should equal(return_value)
    end
  end

  context 'when the block is recursive' do
    def block
      subject.should be_nil
      return_value
    end

    it 'returns the expected value' do
      should equal(return_value)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
ice_nine-0.8.0 spec/unit/ice_nine/recursion_guard/class_methods/guard_spec.rb
ice_nine-0.7.0 spec/unit/ice_nine/recursion_guard/class_methods/guard_spec.rb
ice_nine-0.6.0 spec/unit/ice_nine/recursion_guard/class_methods/guard_spec.rb
ice_nine-0.5.0 spec/unit/ice_nine/recursion_guard/class_methods/guard_spec.rb
ice_nine-0.4.0 spec/unit/ice_nine/recursion_guard/class_methods/guard_spec.rb
ice_nine-0.3.0 spec/unit/ice_nine/recursion_guard/class_methods/guard_spec.rb
ice_nine-0.2.0 spec/unit/ice_nine/recursion_guard/class_methods/guard_spec.rb