Sha256: 88bc485a3b9bde178ac60739888dc23fe0fd6261d00bcc720c520a41136e8021

Contents?: true

Size: 699 Bytes

Versions: 16

Compression:

Stored size: 699 Bytes

Contents

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
      subject.to_json.must_equal "{\"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

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
roar-0.12.5 test/hal_links_test.rb
roar-0.12.4 test/hal_links_test.rb
roar-0.12.3 test/hal_links_test.rb
roar-0.12.2 test/hal_links_test.rb
roar-0.12.1 test/hal_links_test.rb
roar-0.12.0 test/hal_links_test.rb
roar-0.11.19 test/hal_links_test.rb
roar-0.11.18 test/hal_links_test.rb
roar-0.11.17 test/hal_links_test.rb
roar-0.11.16 test/hal_links_test.rb
roar-0.11.15 test/hal_links_test.rb
roar-0.11.14 test/hal_links_test.rb
roar-0.11.13 test/hal_links_test.rb
roar-0.11.12 test/hal_links_test.rb
roar-0.11.11 test/hal_links_test.rb
roar-0.11.10 test/hal_links_test.rb