Sha256: 69f1bb58408efa0636b5fb1ae5b0e49a8182bd1ac082221b3d7d84adf8cdde85

Contents?: true

Size: 916 Bytes

Versions: 4

Compression:

Stored size: 916 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(user_options: {links: false})
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/roar-1.2.0/test/client_test.rb
roar-1.2.0 test/client_test.rb
roar-1.1.1 test/client_test.rb
roar-1.1.0 test/client_test.rb