Sha256: a82dc3b6b6bae2dbc65335da7d08b7c7fa628cf25952031cdf4bb478ca0d2438

Contents?: true

Size: 1.41 KB

Versions: 10

Compression:

Stored size: 1.41 KB

Contents

require 'spec_helper'
require 'pact/consumer/request'
require 'pact/consumer_contract/request'

PACT_SPEC_DIR = "../pact-specification/testcases"
REQUEST_TEST_CASE_FOLDERS = Dir.glob("#{PACT_SPEC_DIR}/request/**")
REQUEST_TEST_CASE_FILES = Dir.glob("#{PACT_SPEC_DIR}/request/**/*.json")

TEST_DESCRIPTIONS = {true => "matches", false => "does not match"}

describe "Pact gem complicance with Pact Specification 1.0.0" do

  directories = Dir.glob("#{PACT_SPEC_DIR}/*")

  directories.each do | dir_name |

    describe File.basename(dir_name) do

      sub_directories = Dir.glob("#{dir_name}/*")

      sub_directories.each do | sub_dir_name |

        context File.basename(sub_dir_name) do
          testcases = Dir.glob("#{sub_dir_name}/**/*.json")

          testcases.each do | file_name |

            context File.basename(file_name).chomp(".json") do

              file_content = JSON.parse(File.read(file_name))
              expected = Pact::Request::Expected.from_hash(file_content["expected"])
              actual = Pact::Consumer::Request::Actual.from_hash(file_content["actual"])
              expected_result = file_content.fetch("match")
              comment = file_content["comment"]

              it "#{TEST_DESCRIPTIONS[expected_result]} - #{comment}" do
                expect(expected.matches?(actual)).to eq expected_result
              end

            end

          end
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
pact-1.4.0.rc4 spec/pact_specification/compliance-1.0.0.rb
pact-1.4.0.rc3 spec/pact_specification/compliance-1.0.0.rb
pact-1.4.0.rc2 spec/pact_specification/compliance-1.0.0.rb
pact-1.3.3 spec/pact_specification/compliance-1.0.0.rb
pact-1.3.2 spec/pact_specification/compliance-1.0.0.rb
pact-1.3.1 spec/pact_specification/compliance-1.0.0.rb
pact-1.3.0 spec/pact_specification/compliance-1.0.0.rb
pact-1.2.1.rc2 spec/pact_specification/compliance-1.0.0.rb
pact-1.2.1.rc1 spec/pact_specification/compliance-1.0.0.rb
pact-1.1.1 spec/pact_specification/compliance-1.0.0.rb