Sha256: a6c2a1de4f27d9f59dc3b134db4d33840cd67254ab2c386923b8f6424b367adb

Contents?: true

Size: 1.17 KB

Versions: 14

Compression:

Stored size: 1.17 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
          expect(InteractionReplay).to receive(:new).and_return(interaction_replay)
          expect(interaction_replay).to receive(: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

14 entries across 14 versions & 2 rubygems

Version Path
pact-mock_service-0.2.2 spec/lib/pact/consumer/mock_service/app_spec.rb
pact-mock_service-0.2.1 spec/lib/pact/consumer/mock_service/app_spec.rb
pact-mock_service-0.2.0 spec/lib/pact/consumer/mock_service/app_spec.rb
pact-1.4.0.rc4 spec/lib/pact/consumer/mock_service/app_spec.rb
pact-mock_service-0.1.0 spec/lib/pact/consumer/mock_service/app_spec.rb
pact-1.4.0.rc3 spec/lib/pact/consumer/mock_service/app_spec.rb
pact-1.4.0.rc2 spec/lib/pact/consumer/mock_service/app_spec.rb
pact-mock_service-0.0.1 spec/lib/pact/consumer/mock_service/app_spec.rb
pact-1.3.3 spec/lib/pact/consumer/mock_service/app_spec.rb
pact-1.3.2 spec/lib/pact/consumer/mock_service/app_spec.rb
pact-1.3.1 spec/lib/pact/consumer/mock_service/app_spec.rb
pact-1.3.0 spec/lib/pact/consumer/mock_service/app_spec.rb
pact-1.2.1.rc2 spec/lib/pact/consumer/mock_service/app_spec.rb
pact-1.2.1.rc1 spec/lib/pact/consumer/mock_service/app_spec.rb