spec/unit/rom/http/dataset/response_transformers/schemad_spec.rb in rom-http-0.4.0 vs spec/unit/rom/http/dataset/response_transformers/schemad_spec.rb in rom-http-0.5.0

- old
+ new

@@ -1,13 +1,12 @@ RSpec.describe ROM::HTTP::Dataset::ResponseTransformers::Schemad do - let(:transformer) { ROM::HTTP::Dataset::ResponseTransformers::Schemad.new(schema) } + subject(:transformer) { ROM::HTTP::Dataset::ResponseTransformers::Schemad.new(schema) } + let(:schema) do - ROM::Plugins::Relation::Schema::Schema.create do - attribute :id, 'form.int' - attribute :name, 'strict.string' - attribute :active, 'form.bool' - end + { id: ROM::Types::Form::Int, + name: ROM::Types::Strict::String, + active: ROM::Types::Form::Bool } end describe '#call' do let(:response) do [ @@ -21,32 +20,26 @@ end let(:dataset) do double('ROM::HTTP::Dataset', projections: projections) end - subject! { transformer.call(response, dataset) } - context 'with no projections' do let(:projections) { [] } - it do - is_expected.to eq([ - id: 1, - name: 'Jill', - active: true - ]) + it 'returns original tuples' do + result = transformer.call(response, dataset) + + expect(result).to eql([id: 1, name: 'Jill', active: true]) end end context 'with projections' do let(:projections) { [:id, :name, :active] } - it do - is_expected.to eq([ - id: 1, - name: 'Jill', - active: true - ]) + it 'returns projected relation tuples' do + result = transformer.call(response, dataset) + + expect(result).to eql([id: 1, name: 'Jill', active: true]) end end end end