Sha256: 38aa7ed2d999a8d0590f1e4e4969ff221c7971554dca3efbb69b4b4df75a6abb

Contents?: true

Size: 1.5 KB

Versions: 5

Compression:

Stored size: 1.5 KB

Contents

require 'spec_helper'

describe Apipie::Generator::Swagger::WarningWriter do
  let(:writer) { described_class.clone.instance }

  let(:warning) do
    Apipie::Generator::Swagger::Warning.for_code(
      Apipie::Generator::Swagger::Warning::INFERRING_BOOLEAN_CODE,
      'SampleController#action',
      { parameter: 'some-param' }
    )
  end

  before do
    Apipie.configuration.swagger_suppress_warnings = false
    Singleton.__init__(described_class)
  end

  describe '#warn' do
    subject { writer.warn(warning) }

    it 'outputs the warning' do
      expect { subject }.to output(warning.warning_message).to_stderr
    end

    context 'when Apipie.configuration.swagger_suppress_warnings is true' do
      before { Apipie.configuration.swagger_suppress_warnings = true }

      it { is_expected.to be_falsey }
    end

    context 'when Apipie.configuration.swagger_suppress_warnings includes warning code' do
      before do
        Apipie.configuration.swagger_suppress_warnings =
          Array(Apipie::Generator::Swagger::Warning::INFERRING_BOOLEAN_CODE)
      end

      it { is_expected.to be_falsey }
    end

    context 'when a warning already been logged' do
      before { writer.warn(warning) }

      it { is_expected.to be_falsey }
    end
  end

  describe '#issued_warnings?' do
    subject { writer.issued_warnings? }

    it { is_expected.to be_falsey }

    context 'when a warning already been logged' do
      before { writer.warn(warning) }

      it { is_expected.to be_truthy }
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
apipie-rails-0.9.4 spec/lib/apipie/generator/swagger/warning_writer_spec.rb
apipie-rails-0.9.3 spec/lib/apipie/generator/swagger/warning_writer_spec.rb
apipie-rails-0.9.2 spec/lib/generator/swagger/warning_writer_spec.rb
apipie-rails-0.9.1 spec/lib/generator/swagger/warning_writer_spec.rb
apipie-rails-0.9.0 spec/lib/generator/swagger/warning_writer_spec.rb