Sha256: 65aeb1fbefe47ff8994e2f9ee89a75c97ac57893236a65031aab2fcf7187b599

Contents?: true

Size: 1.17 KB

Versions: 15

Compression:

Stored size: 1.17 KB

Contents

require "#{::File.dirname(__FILE__)}/../../test_helper"

class TestHashClass < Test::Unit::TestCase
  context "hash_get" do
    setup do
      @hsh = {
        "10.0.0.3" => {"stuff" => "here"},
        "10.0.0.1" => {"stuff" => "here"},
        "10.0.0.2" => {"stuff" => "here"}
      }
    end
    should "should return 0.1 if we are 0.2" do
      assert @hsh.next_sorted_key("10.0.0.1"), "10.0.0.2"
      assert @hsh.next_sorted_key("10.0.0.2"), "10.0.0.3"
      assert @hsh.next_sorted_key("10.0.0.3"), "10.0.0.1"
      assert @hsh.next_sorted_key("10.0.0.1"), "10.0.0.2"
    end
    should "should return self if there is only 1 element" do
      k = {"10.0.0.2" => {"stuff" => "here"}}.next_sorted_key("10.0.0.2")
      assert k, "10.0.0.2"
    end
  end
  context "test method_missing" do
    should "should be able to call a key on the hash as a method" do
      {:first_name => "bob", :last_name => "frank"}.first_name.should == "bob"
    end
    should "should not return nil if there is no key set in the hash" do
      hsh = {:first_name => "bob", :last_name => "frank"}
      lambda {{:first_name => "bob", :last_name => "frank"}.neighbor}.should raise_error
    end
  end
  
  
end

Version data entries

15 entries across 15 versions & 3 rubygems

Version Path
auser-poolparty-1.1.6 test/poolparty/core/hash_test.rb
auser-poolparty-1.1.7 test/poolparty/core/hash_test.rb
auser-poolparty-1.2.0 test/poolparty/core/hash_test.rb
auser-poolparty-1.2.1 test/poolparty/core/hash_test.rb
auser-poolparty-1.2.10 test/poolparty/core/hash_test.rb
auser-poolparty-1.2.11 test/poolparty/core/hash_test.rb
auser-poolparty-1.2.12 test/poolparty/core/hash_test.rb
auser-poolparty-1.2.2 test/poolparty/core/hash_test.rb
auser-poolparty-1.2.3 test/poolparty/core/hash_test.rb
auser-poolparty-1.2.4 test/poolparty/core/hash_test.rb
auser-poolparty-1.2.7 test/poolparty/core/hash_test.rb
auser-poolparty-1.2.8 test/poolparty/core/hash_test.rb
auser-poolparty-1.2.9 test/poolparty/core/hash_test.rb
fairchild-poolparty-1.2.12 test/poolparty/core/hash_test.rb
poolparty-1.2.2 test/poolparty/core/hash_test.rb