Sha256: 0f34cec037db4f231d5c83be4702259db76c0b3f081d9bd0353074433adc2c43

Contents?: true

Size: 1.02 KB

Versions: 32

Compression:

Stored size: 1.02 KB

Contents

require 'spec/helper'

Point = Ramaze::Struct.new(:x,:y)

describe "Ramaze::Struct" do
  describe '#values_at' do
    @point = Point.new(1,2)

    it "should access a single value" do
      @point.values_at(:x).should == [1]
    end

    it "should access multiple values" do
      @point.values_at(:x,:y).should == [1,2]
    end

    it "should access values regardless of order" do
      @point.values_at(:y,:x).should == [2,1]
    end

    it "should get same value twice" do
      @point.values_at(:x,:x).should == [1,1]
    end

    it "should raise on wrong value" do
      should.raise(NameError){
        @point.values_at(:k)
      }
    end

    it "should work with strings" do
      @point.values_at('x').should == [1]
    end

    it "should work with numbers (ruby compat)" do
      @point.values_at(0).should == [1]
    end

    should 'work with ranges' do
      @point.values_at(0..1).should == [1,2]
    end

    should 'work with multiple ranges' do
      @point.values_at(0..1, 0..1).should == [1,2,1,2]
    end
  end
end

Version data entries

32 entries across 32 versions & 5 rubygems

Version Path
Pistos-ramaze-2008.09 spec/ramaze/struct.rb
Pistos-ramaze-2008.12 spec/ramaze/struct.rb
Pistos-ramaze-2009.01 spec/ramaze/struct.rb
Pistos-ramaze-2009.02 spec/ramaze/struct.rb
Pistos-ramaze-2009.04.08 spec/ramaze/struct.rb
manveru-ramaze-2008.09 spec/ramaze/struct.rb
manveru-ramaze-2008.10 spec/ramaze/struct.rb
manveru-ramaze-2008.12 spec/ramaze/struct.rb
manveru-ramaze-2009.01 spec/ramaze/struct.rb
manveru-ramaze-2009.04.01 spec/ramaze/struct.rb
manveru-ramaze-2009.04.08 spec/ramaze/struct.rb
manveru-ramaze-2009.04.18 spec/ramaze/struct.rb
manveru-ramaze-2009.04.22 spec/ramaze/struct.rb
manveru-ramaze-2009.04 spec/ramaze/struct.rb
manveru-ramaze-2009.05.08 spec/ramaze/struct.rb
manveru-ramaze-2009.05 spec/ramaze/struct.rb
manveru-ramaze-2009.06.04 spec/ramaze/struct.rb
manveru-ramaze-2009.06.12 spec/ramaze/struct.rb
manveru-ramaze-2009.06 spec/ramaze/struct.rb
ptomato-ramaze-2009.02.1 spec/ramaze/struct.rb