Sha256: f6de95a38a7c3cdc80697294904d9cb52e9b6475c8ce404ced88cf0fe6a58a59

Contents?: true

Size: 934 Bytes

Versions: 1

Compression:

Stored size: 934 Bytes

Contents

RSpec.describe ROM::HTTP::Relation do
  describe '#initialize' do
    let(:relation) { relation_klass.new(dataset) }
    let(:dataset) { ROM::HTTP::Dataset.new(nil, {}) }

    context 'when relation has schema' do
      let(:relation_klass) do
        Class.new(ROM::HTTP::Relation) do
          schema do
            attribute 'id', ROM::Types::Strict::Int
          end
        end
      end

      it 'sets the dataset response transformer' do
        expect(relation.dataset.response_transformer)
          .to be_a(ROM::HTTP::Dataset::ResponseTransformers::Schemad)
      end
    end

    context 'when relation does not have schema' do
      let(:relation_klass) do
        Class.new(ROM::HTTP::Relation)
      end

      it 'keeps the default (schemaless) transformer' do
        expect(relation.dataset.response_transformer)
          .to be_a(ROM::HTTP::Dataset::ResponseTransformers::Schemaless)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rom-http-0.5.0 spec/unit/rom/http/relation_spec.rb