Sha256: 901380b9b0b9bb699267ce24d63404b7746448e18f2d1b477a24bc22dbad5b46
Contents?: true
Size: 606 Bytes
Versions: 16
Compression:
Stored size: 606 Bytes
Contents
require_relative 'helper' class User < Ohm::Model end test "returns an empty hash if model doesn't have set attributes" do assert_equal Hash.new, User.new.to_hash end test "returns a hash with its id if model is persisted" do user = User.create assert_equal Hash[id: user.id], user.to_hash end class Person < Ohm::Model attribute :name def to_hash super.merge(name: name) end end test "returns additional attributes if the method is overrided" do person = Person.create(name: "John") expected = { id: person.id, name: person.name } assert_equal expected, person.to_hash end
Version data entries
16 entries across 16 versions & 3 rubygems