Sha256: 806bc407e674711a057e2af5603d9531c20ee641fc02fcc8e18e35a43807cc5b

Contents?: true

Size: 1014 Bytes

Versions: 9

Compression:

Stored size: 1014 Bytes

Contents

require 'spec_helper'

describe VersionCake::VersionedResponseService do

  let(:config) { double(response_strategies: [VersionCake::ResponseStrategy::HttpHeaderStrategy.new]) }
  let(:service) { described_class.new(config)}

  describe '#inject_version' do
    let(:context) { double('content', version: 2) }
    let(:headers) { { } }

    before { service.inject_version(context, nil, headers, nil) }

    it { expect(headers['api-version']).to eq '2' }

    context 'when configured with multiple response strategies' do
      let(:headers) { { 'Content-Type' => 'application/vnd.api+json; charset=utf-8;' } }

      let(:config) do
        double(response_strategies: [
            VersionCake::ResponseStrategy::HttpHeaderStrategy.new,
            VersionCake::ResponseStrategy::HttpContentTypeStrategy.new
        ])
      end

      it { expect(headers['Content-Type']).to eq 'application/vnd.api+json; charset=utf-8; api_version=2' }
      it { expect(headers['api-version']).to eq '2' }
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
versioncake-4.1.1 spec/unit/versioned_response_service_spec.rb
versioncake-4.1.0 spec/unit/versioned_response_service_spec.rb
versioncake-4.0.2 spec/unit/versioned_response_service_spec.rb
versioncake-4.0.1 spec/unit/versioned_response_service_spec.rb
versioncake-4.0.0 spec/unit/versioned_response_service_spec.rb
versioncake-3.4.0 spec/unit/versioned_response_service_spec.rb
versioncake-3.3.0 spec/unit/versioned_response_service_spec.rb
versioncake-3.2.0 spec/unit/versioned_response_service_spec.rb
versioncake-3.1.0 spec/unit/versioned_response_service_spec.rb