test/nested_resource.rb in arrest-0.0.7 vs test/nested_resource.rb in arrest-0.0.8
- old
+ new
@@ -7,20 +7,22 @@
Arrest::Source.source = nil
#Arrest::Source.debug = true
end
def test_instance_test
- n = ANestedClass.new({:name => "foo"})
+ n = ANestedClass.new({:name => "foo", :underscore_name => "Bar"})
assert_equal "foo", n.name
+ assert_equal "Bar", n.underscore_name
end
def test_from_hash
input = {
:parent_name => 'parent',
:bool => false,
:nested_object => {
:name => 'iamnested',
+ :underscore_name => 'foo',
:bool => true
}
}
actual = WithNested.new(input)
@@ -35,28 +37,19 @@
input = {
:parent_name => 'parent',
:bool => false,
:nested_object => {
:name => 'iamnested',
+ :underscore_name => 'foo',
:bool => true
}
}
actual = WithNested.new(input)
- # we expect camel cased keys
- expected = {
- 'parentName' => 'parent',
- 'bool' => false,
- 'nestedObject' => {
- 'name' => 'iamnested',
- 'bool' => true
- }
- }
+ assert_equal_hashes input, actual.to_hash
- assert_equal_hashes expected, actual.to_hash
-
end
def test_many_to_hash
input = {
:parent_name => 'parent',
@@ -72,27 +65,12 @@
]
}
actual = WithManyNested.new(input)
- # we expect camel cased keys
- expected = {
- 'parentName' => 'parent',
- 'bool' => false,
- 'nestedObjects' => [
- {
- 'name' => 'iamnested_one',
- 'bool' => true
- },{
- 'name' => 'iamnested_two',
- 'bool' => false
- }
- ]
- }
+ assert_equal_hashes input, actual.to_hash
- assert_equal_hashes expected, actual.to_hash
-
end
def test_belongd_to_to_hash
new_zoo = Zoo.new({:name => "Foo"})
new_zoo.save
@@ -107,22 +85,10 @@
}
}
actual = WithNestedBelongingTo.new(input)
- # we expect camel cased keys
- expected = {
- 'parentName' => 'parent',
- 'bool' => false,
- 'nestedObject' => {
- 'name' => 'iamnested',
- 'bool' => true,
- 'zooId' => new_zoo.id
-
- }
- }
-
- assert_equal_hashes expected, actual.to_hash
+ assert_equal_hashes input, actual.to_hash
zoo = actual.nested_object.zoo
assert_equal "Foo", zoo.name
end