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.75.0 spec/support/fixture_pact.rb
pact_broker-2.74.1 spec/support/fixture_pact.rb
pact_broker-2.74.0 spec/support/fixture_pact.rb
pact_broker-2.73.0 spec/support/fixture_pact.rb
pact_broker-2.72.0 spec/support/fixture_pact.rb
pact_broker-2.71.0 spec/support/fixture_pact.rb
pact_broker-2.70.0 spec/support/fixture_pact.rb
pact_broker-2.69.0 spec/support/fixture_pact.rb
pact_broker-2.68.1 spec/support/fixture_pact.rb
pact_broker-2.68.0 spec/support/fixture_pact.rb
pact_broker-2.67.0 spec/support/fixture_pact.rb
pact_broker-2.66.0 spec/support/fixture_pact.rb
pact_broker-2.65.0 spec/support/fixture_pact.rb
pact_broker-2.64.0 spec/support/fixture_pact.rb
pact_broker-2.63.0 spec/support/fixture_pact.rb
pact_broker-2.62.0 spec/support/fixture_pact.rb
pact_broker-2.61.0 spec/support/fixture_pact.rb
pact_broker-2.60.1 spec/support/fixture_pact.rb
pact_broker-2.60.0 spec/support/fixture_pact.rb
pact_broker-2.59.2 spec/support/fixture_pact.rb