Sha256: 71d7cce2a85b14aa15c9f792794d726284af33551d7e22fd4449d5b6014a4623

Contents?: true

Size: 923 Bytes

Versions: 4

Compression:

Stored size: 923 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', '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

4 entries across 4 versions & 1 rubygems

Version Path
rom-http-0.4.0 spec/unit/rom/http/relation_spec.rb
rom-http-0.3.0 spec/unit/rom/http/relation_spec.rb
rom-http-0.2.0 spec/unit/rom/http/relation_spec.rb
rom-http-0.2.0.beta1 spec/unit/rom/http/relation_spec.rb