Sha256: 46c489a7efad10684b07fc0964aeed2763d6ce53e70ae93673b39becbabc77d9
Contents?: true
Size: 1.13 KB
Versions: 3
Compression:
Stored size: 1.13 KB
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 return a LazyCover object" do @value.class.must_equal SmokeMonster::LazyCover 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 return a LazyCover object" do @value.class.must_equal SmokeMonster::LazyCover 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
3 entries across 3 versions & 1 rubygems