Sha256: 7a87d7435ab3bca43fd405ed4a33578d6a5bc072529ac580eac03225ff219027

Contents?: true

Size: 905 Bytes

Versions: 7

Compression:

Stored size: 905 Bytes

Contents

require 'test_helper'
require 'roar/client'

class ClientTest < MiniTest::Spec
  representer_for([Roar::Representer]) do
    property :name
    property :band
  end

  let(:song) { Object.new.extend(rpr).extend(Roar::Client) }

  it "adds accessors" do
    song.name = "Social Suicide"
    song.band = "Bad Religion"
    assert_equal "Social Suicide", song.name
    assert_equal "Bad Religion", song.band
  end

  describe "links" do
    representer_for([Roar::JSON, Roar::Hypermedia]) do
      property :name
      link(:self) { never_call_me! }
    end

    it "suppresses rendering" do
      song.name = "Silenced"
      song.to_json.must_equal %{{\"name\":\"Silenced\",\"links\":[]}}
    end

    # since this is considered dangerous, we test the mutuable options.
    it "adds links: false to options" do
      song.to_hash(options = {})
      options.must_equal({:links => false})
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
roar-1.0.4 test/client_test.rb
roar-1.0.3 test/client_test.rb
roar-1.0.2 test/client_test.rb
roar-1.0.1 test/client_test.rb
roar-1.0.0 test/client_test.rb
roar-1.0.0.beta2 test/client_test.rb
roar-1.0.0.beta1 test/client_test.rb