Sha256: 032bfb247f4e3afb469e906a1979352f438a24193bbaf1a84133e8594e908143

Contents?: true

Size: 1.28 KB

Versions: 5

Compression:

Stored size: 1.28 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 # evaluate

    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
alf-0.12.2 spec/unit/alf-core/tools/test_tuple_handle.rb
alf-0.12.1 spec/unit/alf-core/tools/test_tuple_handle.rb
alf-0.12.0 spec/unit/alf-core/tools/test_tuple_handle.rb
alf-0.11.1 spec/unit/alf-core/tools/test_tuple_handle.rb
alf-0.11.0 spec/unit/alf-core/tools/test_tuple_handle.rb