test/structure_test.rb in structure-0.22.0 vs test/structure_test.rb in structure-0.22.1
- old
+ new
@@ -68,16 +68,27 @@
other = Person.new(:name => 'Jane', :friends => [person])
assert_equal 'John', other.friends.first.name
end
+ def test_cant_change_sex_when_frozen
+ person = Person.new(:name => 'John')
+ person.freeze
+ assert_raises(TypeError) { person.name = 'Jane' }
+ end
+
def test_to_hash
person = Person.new(:name => 'John')
- person.friends << Person.new(:name => 'Jane')
- hash = person.to_hash
+ friend = Person.new(:name => 'Jane')
+ person.friends << friend
+ hsh = person.to_hash
- assert_equal 'John', hash[:name]
- assert_equal 'Jane', hash[:friends].first[:name]
+ assert_equal person.name, hsh[:name]
+ assert_equal friend.name, hsh[:friends].first[:name]
+
+ person.friends = [[friend]]
+ hsh = person.to_hash
+ assert_equal friend.name, hsh[:friends].first.first[:name]
end
def test_json
Person.send :include, Structure::JSON