Sha256: aa7dde0f0a62442b1e7582f1c8432a8016468ec2f775d3b807231a2e75b42999

Contents?: true

Size: 1.21 KB

Versions: 1

Compression:

Stored size: 1.21 KB

Contents

require 'spec_helper'
require 'pact/provider/pact_spec_runner'

module Pact::Provider
  describe PactSpecRunner do
    describe "pact_helper_file", :fakefs => true do

      subject { PactSpecRunner.new({}).send(:pact_helper_file) }

      def make_pactfile dir
        FileUtils.mkdir_p ".#{dir}"
        FileUtils.touch ".#{dir}/pact_helper.rb"
      end

      PACT_HELPER_FILE_DIRS = [
        '/spec/blah/service-consumers',
        '/spec/consumers',
        '/spec/blah/service_consumers',
        '/spec/serviceconsumers',
        '/spec/consumer',
        '/spec',
        '/blah',
        '/blah/consumer',
        ''
      ]

      PACT_HELPER_FILE_DIRS.each do | dir |
        context "the pact_helper is stored in #{dir}" do
          it "finds the pact_helper" do
            make_pactfile dir
            expect(subject).to eq "#{Dir.pwd}#{dir}/pact_helper.rb"
          end
        end
      end

      context "when more than one pact_helper exists" do
        it "returns the one that matches the most explict search pattern" do
          make_pactfile '/spec/consumer'
          FileUtils.touch 'pact_helper.rb'
          expect(subject).to eq "#{Dir.pwd}/spec/consumer/pact_helper.rb"
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pact-1.0.5 spec/lib/pact/provider/pact_spec_runner_spec.rb