Sha256: 6f95cbc717370aad8087b2ed5d765408610b293aa2584d7ba8d909698256e908

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

require 'spec_helper'

def form_params(p)
  if Rails::VERSION::MAJOR > 4
    {params: p}
  else
    p
  end
end

describe Apress::Documentation::SwaggerController, type: :controller do
  describe '#show' do
    it 'response with 200' do
      get :show

      expect(response).to have_http_status(:ok)
    end

    context 'with params' do
      it 'response ok' do
        get :show, form_params(module: 'somemodule')

        expect(response).to have_http_status(:ok)
      end
    end

    context 'with cache' do
      around do |example|
        begin
          Rails.application.config.action_controller.perform_caching = true
          example.run
        ensure
          Rails.application.config.action_controller.perform_caching = false
        end
      end

      it 'caches documentation json' do
        spy = Apress::Documentation::SwaggerJsonBuilder.new(nil)
        allow(Apress::Documentation::SwaggerJsonBuilder).to receive(:new).and_return(spy)
        expect(spy).to receive(:call).once.and_call_original
        get :show
        get :show
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
apress-documentation-0.4.0 spec/app/controllers/swagger_controller_spec.rb