Sha256: f862b2be02267e2bced0ac65fb6e6b155fe7e8a335037197ff154415388d5863
Contents?: true
Size: 673 Bytes
Versions: 2
Compression:
Stored size: 673 Bytes
Contents
# encoding: UTF-8 require File.expand_path(File.join(File.dirname(__FILE__), "test_helper")) class Tag < Ohm::Model attribute :name end class HashKeyTest < Test::Unit::TestCase setup do Ohm.flush end test "using a new record as a hash key" do tag = Tag.new hash = { tag => "Ruby" } assert_equal "Ruby", hash[tag] assert_nil hash[Tag.new] end test "on a persisted model" do tag = Tag.create(:name => "Ruby") assert_equal "Ruby", { tag => "Ruby" }[tag] end test "on a reloaded model" do tag = Tag.create(:name => "Ruby") hash = { tag => "Ruby" } tag = Tag[tag.id] assert_equal "Ruby", hash[tag] end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ohm-0.1.0.rc5 | test/hash_key_test.rb |
ohm-0.1.0.rc4 | test/hash_key_test.rb |