Sha256: fdb853d4b3a0c1eb6ae4950ff45f0d5efa93cc2250628e969afc1ea9b620b464

Contents?: true

Size: 1.53 KB

Versions: 9

Compression:

Stored size: 1.53 KB

Contents

require 'spec_helper'
require 'pact/provider/pact_helper_locator'

module Pact::Provider

  describe PactHelperLocater do
    describe "pact_helper_path", :fakefs => true do

      subject { PactHelperLocater.pact_helper_path }

      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 File.join(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 File.join(Dir.pwd, '/spec/consumer/pact_helper.rb')
        end
      end

      context "when a file exists ending in pact_helper.rb" do
        it "is not identifed as a pact helper" do
          FileUtils.mkdir_p './spec'
          FileUtils.touch './spec/not_pact_helper.rb'
          expect { subject }.to raise_error /Please create a pact_helper.rb file/
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
pact-1.4.0.rc4 spec/lib/pact/provider/pact_helper_locator_spec.rb
pact-1.4.0.rc3 spec/lib/pact/provider/pact_helper_locator_spec.rb
pact-1.4.0.rc2 spec/lib/pact/provider/pact_helper_locator_spec.rb
pact-1.3.3 spec/lib/pact/provider/pact_helper_locator_spec.rb
pact-1.3.2 spec/lib/pact/provider/pact_helper_locator_spec.rb
pact-1.3.1 spec/lib/pact/provider/pact_helper_locator_spec.rb
pact-1.3.0 spec/lib/pact/provider/pact_helper_locator_spec.rb
pact-1.2.1.rc2 spec/lib/pact/provider/pact_helper_locator_spec.rb
pact-1.2.1.rc1 spec/lib/pact/provider/pact_helper_locator_spec.rb