Sha256: c19703c1e962bc47675acd26bf9dad1bd35d53cdeaf761513bc301beb5d67245

Contents?: true

Size: 1.08 KB

Versions: 3

Compression:

Stored size: 1.08 KB

Contents

# -*- encoding : utf-8 -*-
require 'spec_helper'

module Pacto
  module Observers
    describe Stenographer do
      let(:pacto_request) { Fabricate(:pacto_request) }
      let(:pacto_response) { Fabricate(:pacto_response) }
      let(:contract) { Fabricate(:contract) }
      let(:citations) { %w(one two) }
      let(:investigation) { Pacto::Investigation.new(pacto_request, pacto_response, contract, citations) }

      subject(:stream) { StringIO.new }

      subject { described_class.new stream }

      it 'writes to the stenographer log stream' do
        subject.log_investigation investigation
        expected_log_line = "request #{contract.name.inspect}, values: {}, response: {status: #{pacto_response.status}} # #{citations.size} contract violations\n"
        expect(stream.string).to eq expected_log_line
      end

      context 'when the stenographer log stream is nil' do
        let(:stream) { nil }

        it 'does nothing' do
          # Would raise an error if it tried to write to stream
          subject.log_investigation investigation
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pacto-0.4.0.rc3 spec/unit/pacto/stubs/observers/stenographer_spec.rb
pacto-0.4.0.rc2 spec/unit/pacto/stubs/observers/stenographer_spec.rb
pacto-0.4.0.rc1 spec/unit/pacto/stubs/observers/stenographer_spec.rb