Sha256: a0d6db4a11656924110d64636674900f184287d183810ad5b5a1b2cfd120389c

Contents?: true

Size: 1.14 KB

Versions: 16

Compression:

Stored size: 1.14 KB

Contents

require 'spec_helper'
require 'rack/test'
require 'tempfile'

module Pact
  module Consumer

    describe MockService do

      include Rack::Test::Methods

      def app
        MockService.new(log_file: temp_file)
      end

      let(:temp_file) { Tempfile.new('log') }

      after do
        temp_file.close
        temp_file.unlink
      end

      context "when a StandardError is encountered" do
        let(:response) { JSON.parse(last_response.body)}
        let(:interaction_replay) { double(InteractionReplay, :match? => true)}

        before do
          InteractionReplay.stub(:new).and_return(interaction_replay)
          interaction_replay.stub(:respond).and_raise("an error")
        end

        subject { get "/" }

        it "returns a json error" do
          subject
          expect(last_response.content_type).to eq 'application/json'
        end

        it "includes the error message" do
          subject
          expect(response['message']).to eq "an error"
        end

        it "includes the backtrace" do
          subject
          expect(response['backtrace']).to be_instance_of Array
        end
      end

    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
pact-1.1.1 spec/lib/pact/consumer/mock_service/app_spec.rb
pact-1.1.0 spec/lib/pact/consumer/mock_service/app_spec.rb
pact-1.1.0.rc5 spec/lib/pact/consumer/mock_service/app_spec.rb
pact-1.1.0.rc4 spec/lib/pact/consumer/mock_service/app_spec.rb
pact-1.1.0.rc3 spec/lib/pact/consumer/mock_service/app_spec.rb
pact-1.0.39 spec/lib/pact/consumer/mock_service/app_spec.rb
pact-1.1.0.rc2 spec/lib/pact/consumer/mock_service/app_spec.rb
pact-1.0.38 spec/lib/pact/consumer/mock_service/app_spec.rb
pact-1.1.0.rc1 spec/lib/pact/consumer/mock_service/app_spec.rb
pact-1.0.37 spec/lib/pact/consumer/mock_service/app_spec.rb
pact-1.0.36 spec/lib/pact/consumer/mock_service/app_spec.rb
pact-1.0.35 spec/lib/pact/consumer/mock_service/app_spec.rb
pact-1.0.34 spec/lib/pact/consumer/mock_service/app_spec.rb
pact-1.0.33 spec/lib/pact/consumer/mock_service/app_spec.rb
pact-1.0.32 spec/lib/pact/consumer/mock_service/app_spec.rb
pact-1.0.31 spec/lib/pact/consumer/mock_service/app_spec.rb