test/nested_resource.rb in arrest-0.0.21 vs test/nested_resource.rb in arrest-0.0.23

- old
+ new

@@ -3,15 +3,16 @@ class NestedResourcesTest < Test::Unit::TestCase def setup Arrest::Source.source = nil + @scope = Arrest::ScopedRoot.new #Arrest::Source.debug = true end def test_instance_test - n = ANestedClass.new({:name => "foo", :underscore_name => "Bar"}) + n = ANestedClass.new(nil, {:name => "foo", :underscore_name => "Bar"}) assert_equal "foo", n.name assert_equal "Bar", n.underscore_name end def test_from_hash @@ -23,11 +24,11 @@ :underscore_name => 'foo', :bool => true } } - actual = WithNested.new(input) + actual = @scope.WithNested.new(input) assert_equal 'parent', actual.parent_name assert_equal false, actual.bool assert actual.respond_to? :nested_object, "The parent object should have an accessor for the nested object" assert_equal 'iamnested', actual.nested_object.name assert_equal true, actual.nested_object.bool @@ -42,11 +43,11 @@ :underscore_name => 'foo', :bool => true } } - actual = WithNested.new(input) + actual = @scope.WithNested.new(input) assert_equal_hashes input, actual.to_hash end @@ -63,18 +64,18 @@ :bool => false } ] } - actual = WithManyNested.new(input) + actual = @scope.WithManyNested.new(input) assert_equal_hashes input, actual.to_hash end def test_belongs_to_to_hash - new_zoo = Zoo.new({:name => "Foo"}) + new_zoo = @scope.Zoo.new({:name => "Foo"}) new_zoo.save input = { :parent_name => 'parent', :bool => false, @@ -83,33 +84,33 @@ :bool => true, :zoo_id => new_zoo.id } } - actual = WithNestedBelongingTo.new(input) + actual = @scope.WithNestedBelongingTo.new(input) assert_equal_hashes input, actual.to_hash zoo = actual.nested_object.zoo assert_equal "Foo", zoo.name end def test_custom_belongs_to - new_zoo = Zoo.new({:name => "Foo"}) + new_zoo = @scope.Zoo.new({:name => "Foo"}) new_zoo.save - c = CustomNamedBelongsTo.new({:name => 'Bar', :schinken => new_zoo.id, :batzen => new_zoo.id}) + c = @scope.CustomNamedBelongsTo.new({:name => 'Bar', :schinken => new_zoo.id, :batzen => new_zoo.id}) c.save assert_not_nil c.id, "Persisted object should have id" assert_equal "Foo", c.zoo_thing.name assert_equal "Foo", c.zoo.name assert_not_nil c.id, "Persisted zoo should have id" - c_reloaded = CustomNamedBelongsTo.all.first + c_reloaded = @scope.CustomNamedBelongsTo.all.first assert_equal "Foo", c_reloaded.zoo_thing.name assert_equal "Foo", c_reloaded.zoo.name end