Sha256: 52c9aeae24723d53caa883adde2a02e2900b5fc44bfff93afaae29c6591818cd

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

require_relative "../pact_helper"
require "user_app/message_builder"

module UserApp
  describe MessageBuilder, pact: true do
    subject { described_class.build(subscribed_status) }

    describe ".build" do
      context "subscribed" do
        let(:subscribed_status) { true }
        let(:user_contract) do
          Pact::Messages.get_message_contract("Message Provider", "Message Consumer", "User subscribed")
        end

        it "matches the contract" do
          diff = Pact::JsonDiffer.call(user_contract, subject)
          puts Pact::Matchers::UnixDiffFormatter.call(diff) if diff.any? # Print a pretty diff if we fail
          expect(diff).to be_empty
        end
      end

      context "unsubscribed" do
        let(:subscribed_status) { false }
        let(:user_contract) do
          Pact::Messages.get_message_contract("Message Provider", "Message Consumer", "User unsubscribed")
        end

        it "matches the contract" do
          diff = Pact::JsonDiffer.call(user_contract, subject)
          puts Pact::Matchers::UnixDiffFormatter.call(diff) if diff.any? # Print a pretty diff if we fail
          expect(diff).to be_empty
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pact-messages-0.2.0 example/user-app/spec/service_providers/message_builder_spec.rb