Sha256: 7c37d15d6774b2960a5c385aabc9a95e304e574af4c975581e777463db0de141

Contents?: true

Size: 598 Bytes

Versions: 5

Compression:

Stored size: 598 Bytes

Contents

require 'test_helper'

describe Configatron::Proc do

  let(:store) { Configatron::Store.new }
  let(:proc) { Configatron::Proc.new {rand} }

  describe '#call' do

    it 'executes the block and returns the results' do
      stubs(:rand).returns(4)
      proc.call.must_equal 4
    end

    it 'caches the result if finalize? return true' do
      proc.stubs(:finalize?).returns(true)
      proc.call.must_equal proc.call
    end

    it 'does not cache the result if finalize? returns false' do
      proc.stubs(:finalize?).returns(false)
      proc.call.wont_equal proc.call
    end

  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
configatron-3.2.0 test/configatron/proc_test.rb
configatron-3.1.3 test/configatron/proc_test.rb
configatron-3.1.2 test/configatron/proc_test.rb
configatron-3.1.1 test/configatron/proc_test.rb
configatron-3.1.0 test/configatron/proc_test.rb