test/integration_test.rb in roar-0.8.0 vs test/integration_test.rb in roar-0.8.1

- old
+ new

@@ -6,12 +6,12 @@ require 'roar/representer/feature/http_verbs' require 'roar/representer/feature/hypermedia' class RepresenterIntegrationTest < MiniTest::Spec module XML - class BandRepresenter < Roar::Representer::XML - self.representation_name = :band + class Band + include Roar::Representer::XML property :name property :label include Roar::Representer::Feature::HttpVerbs @@ -27,12 +27,12 @@ end end # TODO: inherit properly. module JSON - class BandRepresenter < Roar::Representer::JSON - self.representation_name = :band + class Band + include Roar::Representer::JSON property :name property :label include Roar::Representer::Feature::HttpVerbs @@ -53,11 +53,11 @@ require 'order_representers' describe "Representer as client" do describe "JSON" do it "allows a POST workflow" do # create representation with initial values: - @r = JSON::BandRepresenter.new(:name => "Bigwig") + @r = JSON::Band.from_attributes(:name => "Bigwig") assert_equal "Bigwig", @r.name @r = @r.post("http://localhost:9999/band", "application/band+json") assert_equal "n/a", @r.label @@ -68,11 +68,11 @@ end # TODO: implement me. it "allows an ordering workflow" do # create representation with initial values: - @o = ::JSON::Order.new(:client_id => 1) + @o = ::JSON::Order.from_attributes(:client_id => 1) assert_equal 1, @o.client_id @o.post!("http://localhost:9999/orders", "application/order+json") # check HATEOAS: #@r.extend Roar::Representer::Feature::Hypermedia @@ -80,11 +80,11 @@ assert_equal "http://localhost:9999/orders/1/items", @o.links[:items] assert_equal "http://localhost:9999/orders/1", @o.links[:self] # manually POST item: - @i = ::JSON::Item.new(:article_id => "666-S", :amount => 1) + @i = ::JSON::Item.from_attributes(:article_id => "666-S", :amount => 1) @i.post!(@o.links[:items], "application/item+json") @o.get!(@o.links[:self], "application/order+json") # check if item is included in order: assert_equal 1, @o.items.size @@ -102,10 +102,10 @@ end describe "XML" do it "allows a POST workflow" do # create representation with initial values: - @r = XML::BandRepresenter.new(:name => "Bigwig") + @r = XML::Band.from_attributes(:name => "Bigwig") assert_equal "Bigwig", @r.name @r = @r.post("http://localhost:9999/band", "application/band+xml") assert_equal "n/a", @r.label