Skip to content

Commit

Permalink
add spec for issue 56
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshikischmitz committed Oct 7, 2014
1 parent 5d353a8 commit 6c0bc88
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions spec/service_spec.rb
Expand Up @@ -774,6 +774,30 @@ module OData
it { should eq @category }
end
end

describe "serializes nested collections" do
# Compy with oData Deep Insert capabilities
# http://docs.oasis-open.org/odata/odata-json-format/v4.0/os/odata-json-format-v4.0-os.html#_Toc372793073

before :each do
category = Category.new
category.Products = [Product.new(Name: "First"), Product.new(Name: "Last")]
@json = JSON.parse(category.to_json(type: :add))
end

it "should have an array for the Products key" do
@json["Products"].should be_a_kind_of Array
end

it "should have a hash for each product" do
@json["Products"].each{|x| x.should be_a_kind_of Hash}
end

it "should have the same data we put into the products" do
@json["Products"].first["Name"].should eq "First"
@json["Products"].last["Name"].should eq "Last"
end
end
end
end

Expand Down

0 comments on commit 6c0bc88

Please sign in to comment.