Sha256: 675e2f02050cc6bade130358af0132374b4a8c19d75dadd7d7cbb4a88b0e1cb3

Contents?: true

Size: 948 Bytes

Versions: 6

Compression:

Stored size: 948 Bytes

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe "lambda to object" do

  describe "to_object on a lambda that returns nil" do
    before do
      @value = -> { nil }.to_object
    end

    it "should remember the original value is nil" do
      @value.the_original_subject.must_equal nil 
    end
  end

  describe "to_object on a lambda that returns an integer" do
    before do
      @value = -> { 1 }.to_object
    end

    it "should remember the original value is 1" do
      @value.the_original_subject.must_equal 1
    end

    it "should be able to use the value as an integer" do
      (@value + 1).must_equal 2
    end
  end

  describe "to_object on a lambda, but never accessing the variable" do
    before do
      @was_called = false
      @value = -> { raise 'it was called' }.to_object
    end

    it "should not be called" do
      #will throw an exception if it was called above 
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
subtle-0.3.8 spec/subtle/lambda_to_object_spec.rb
subtle-0.3.6 spec/subtle/lambda_to_object_spec.rb
subtle-0.3.5 spec/subtle/lambda_to_object_spec.rb
subtle-0.3.4 spec/subtle/lambda_to_object_spec.rb
smoke_monster-0.3.3 spec/smoke_monster/lambda_to_object_spec.rb
smoke_monster-0.3.2 spec/smoke_monster/lambda_to_object_spec.rb