Sha256: d0b5414226d8ce0568f41cb847e03dc0298cc311d9218e1dfe1cd19f1cd1fe2e

Contents?: true

Size: 862 Bytes

Versions: 85

Compression:

Stored size: 862 Bytes

Contents

module Pact
  module Fixture

    def self.fixtures
      @@fixtures ||= []
    end

    def self.clear_fixtures
      @@fixtures = []
    end

    def register_fixture name
      source = caller.first
      thing = yield
      Fixture.fixtures << OpenStruct.new(name: name, thing: thing, source: source)
      thing
    end

    def self.check_fixtures
      fixtures.group_by(&:name).each do | name, fixture_group |
        if fixture_group.size == 1
          puts "WARN: Nothing to compare #{name} to."
        else
          if fixture_group.collect(&:thing).uniq.length != 1
            desc = fixture_group.collect do | fixture |
              "#{fixture.thing} from #{fixture.source}\n"
            end.join("\n")
            raise "These fixtures don't match #{fixture_group.first.name}:\n #{desc}"
          end
        end
      end
    end
  end
end

Version data entries

85 entries across 85 versions & 1 rubygems

Version Path
pact_broker-2.89.1 spec/support/fixture_pact.rb
pact_broker-2.89.0 spec/support/fixture_pact.rb
pact_broker-2.88.0 spec/support/fixture_pact.rb
pact_broker-2.87.0 spec/support/fixture_pact.rb
pact_broker-2.86.0 spec/support/fixture_pact.rb
pact_broker-2.85.1 spec/support/fixture_pact.rb
pact_broker-2.85.0 spec/support/fixture_pact.rb
pact_broker-2.84.0 spec/support/fixture_pact.rb
pact_broker-2.83.0 spec/support/fixture_pact.rb
pact_broker-2.82.0 spec/support/fixture_pact.rb
pact_broker-2.81.0 spec/support/fixture_pact.rb
pact_broker-2.80.0 spec/support/fixture_pact.rb
pact_broker-2.79.1 spec/support/fixture_pact.rb
pact_broker-2.79.0 spec/support/fixture_pact.rb
pact_broker-2.78.1 spec/support/fixture_pact.rb
pact_broker-2.78.0 spec/support/fixture_pact.rb
pact_broker-2.77.0 spec/support/fixture_pact.rb
pact_broker-2.76.2 spec/support/fixture_pact.rb
pact_broker-2.76.1 spec/support/fixture_pact.rb
pact_broker-2.76.0 spec/support/fixture_pact.rb