Sha256: 361273a11fa4b8500792ac87ee9a6b8afb213fb8d219fcd1658b4a704bd7d51a

Contents?: true

Size: 1.32 KB

Versions: 2

Compression:

Stored size: 1.32 KB

Contents

require 'spec_helper'
module Alf
  module Tools
    describe TupleHandle do
  
      let(:handle){ TupleHandle.new }
  
      it "should install methods properly" do
        handle.set(:hello => "a", :world => "b")
        handle.should respond_to(:hello)
        handle.should respond_to(:world)
      end
  
      it "should behave correctly" do
        handle.set(:hello => "a", :world => "b")
        handle.hello.should == "a"
        handle.world.should == "b"
        handle.set(:hello => "c", :world => "d")
        handle.hello.should == "c"
        handle.world.should == "d"
      end
  
      it "should allow instance evaluating on exprs" do
        handle.set(:tested => 1)
        handle.instance_eval{ tested < 1 }.should be_false
      end
  
      it "should support an attribute called :path" do
        handle.set(:path => 1)
        handle.instance_eval{ path < 1 }.should be_false
      end
    
      describe "evaluate" do
        before{ handle.set(:a => 1, :b => 2) }
        
        it "should allow a String" do
          handle.evaluate("a").should == 1
        end
        
        it "should allow a Symbol" do
          handle.evaluate(:a).should == 1
        end
        
        it "should allow a Proc" do
          handle.evaluate(lambda{ a }).should == 1
        end
        
      end
  
    end   
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
alf-0.10.1 spec/unit/tools/test_tuple_handle.rb
alf-0.10.0 spec/unit/tools/test_tuple_handle.rb