Sha256: b7c1b3d400f41555faeb9a00b0acfdf8967892d4e3f2af1fdcde416ccd628a6e

Contents?: true

Size: 847 Bytes

Versions: 4

Compression:

Stored size: 847 Bytes

Contents

require 'test_helper'

require 'roar/json/collection'
require 'roar/client'

class JsonCollectionTest < MiniTest::Spec
  class Band < OpenStruct; end

  class BandRepresenter < Roar::Decorator
    include Roar::JSON

    property :name
    property :label
  end

  class BandsRepresenter < Roar::Decorator
    include Roar::JSON::Collection
    include Roar::Client

    items extend: BandRepresenter, class: Band
  end

  class Bands < Array
    include Roar::JSON::Collection
  end

  let(:bands) { Bands.new }

  # "[{\"name\":\"Slayer\",\"label\":\"Canadian Maple\"},{\"name\":\"Nirvana\",\"label\":\"Sub Pop\"}])"
  it 'fetches lonely collection of existing bands' do
    BandsRepresenter.new(bands).get(uri: 'http://localhost:4567/bands', as: 'application/json')
    bands.size.must_equal(2)
    bands[0].name.must_equal('Slayer')
  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/integration/json_collection_test.rb
roar-1.2.0 test/integration/json_collection_test.rb
roar-1.1.1 test/integration/json_collection_test.rb
roar-1.1.0 test/integration/json_collection_test.rb