require 'ostruct' require 'test_helper' require 'roar/representer/json/hal' class HalLinkTest < MiniTest::Spec let(:rpr) do Module.new do include Roar::Representer::JSON include Roar::Representer::JSON::HAL::Links link :self do "//songs" end end end subject { Object.new.extend(rpr) } describe "#to_json" do it "uses 'links' key" do assert_equal subject.to_json, "{\"links\":{\"self\":{\"href\":\"//songs\"}}}" end end describe "#from_json" do it "uses 'links' key" do subject.from_json("{\"links\":{\"self\":{\"href\":\"//lifer\"}}}").links.values.must_equal [link(:href => "//lifer", :rel => :self)] end end end