Sha256: 7f99554aa3cc5e3e5af881a177199a4693b59fdd9d5b8da8396561e756319a8c

Contents?: true

Size: 1.46 KB

Versions: 3

Compression:

Stored size: 1.46 KB

Contents

require 'spec_helper'

describe Apipie::ResponseDescription do
  let(:resource_description) do
    Apipie::ResourceDescription.new(PetsController, 'pets')
  end

  let(:method_description) do
    Apipie::MethodDescription.new(
      'create',
      resource_description,
      ActionController::Base.send(:_apipie_dsl_data_init)
    )
  end

  let(:response_description_dsl) { proc {} }
  let(:options) { {} }

  let(:response_description) do
    described_class.new(
      method_description,
      204,
      options,
      PetsController,
      response_description_dsl,
      nil
    )
  end

  describe '#to_json' do
    let(:to_json) { response_description.to_json }

    describe 'headers' do
      subject(:headers) { to_json[:headers] }

      it { is_expected.to be_blank }

      context 'when response has headers' do
        let(:response_description_dsl) do
          proc do
            header 'Current-Page', Integer, 'The current page in the pagination', required: true
          end
        end

        it 'returns the header' do
          expect(headers).to contain_exactly({
                                               name: 'Current-Page',
                                               description: 'The current page in the pagination',
                                               validator: 'integer',
                                               options: { required: true }
                                             })
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
apipie-rails-1.4.2 spec/lib/apipie/response_description_spec.rb
apipie-rails-1.4.1 spec/lib/apipie/response_description_spec.rb
apipie-rails-1.4.0 spec/lib/apipie/response_description_spec.rb