Sha256: f6e6b7184ce7d60f6eb079c2ecd37424e9e7fb7f8e70af28da45aa54511b9ae0
Contents?: true
Size: 586 Bytes
Versions: 7
Compression:
Stored size: 586 Bytes
Contents
require_relative "helper" class Tag < Sohm::Model include Sohm::AutoId attribute :name end test "using a new record as a hash key" do tag = Tag.new hash = { tag => "Ruby" } assert "Ruby" == hash[tag] assert hash[Tag.new].nil? end test "on a persisted model" do tag = Tag.create(:name => "Ruby") assert "Ruby" == { tag => "Ruby" }[tag] end test "on a reloaded model" do tag = Tag.create(:name => "Ruby") hash = { tag => "Ruby" } tag = Tag[tag.id] assert "Ruby" == hash[tag] end test "on attributes class method" do assert [:name] == Tag.attributes end
Version data entries
7 entries across 7 versions & 1 rubygems