test/json_representer_test.rb in roar-0.9.0 vs test/json_representer_test.rb in roar-0.9.1

- old
+ new

@@ -6,10 +6,11 @@ class JsonRepresenterTest < MiniTest::Spec class Order include Roar::Representer::JSON property :id property :pending + attr_accessor :id, :pending end describe "JsonRepresenter" do before do @@ -74,12 +75,14 @@ class JsonHypermediaTest describe "Hypermedia API" do before do @c = Class.new do + include AttributesContructor include Roar::Representer::JSON include Roar::Representer::Feature::Hypermedia + attr_accessor :id, :self, :next property :id link :self do "http://self" end link :next do "http://next/#{id}" end @@ -94,14 +97,14 @@ it "extracts links from JSON" do @r = @c.from_json({:links => [{:rel => "self", :href => "http://self"}]}.to_json) assert_equal 1, @r.links.size - assert_equal({"rel"=>"self", "href"=>"http://self"}, @r.links.first.to_attributes) + assert_equal(["self", "http://self"], [@r.links.first.rel, @r.links.first.href]) end it "renders link: correctly in JSON" do - assert_equal "{\"id\":1,\"links\":[{\"rel\":\"self\",\"href\":\"http://self\"},{\"rel\":\"next\",\"href\":\"http://next/1\"}]}", @c.from_attributes(:id => 1).to_json + assert_equal "{\"id\":1,\"links\":[{\"rel\":\"self\",\"href\":\"http://self\"},{\"rel\":\"next\",\"href\":\"http://next/1\"}]}", @c.new(:id => 1).to_json end end end