Sha256: f21abd1e5782059967a4ab3ba4b3ff346e02f3b6b894503a1172cbcbcb663339

Contents?: true

Size: 842 Bytes

Versions: 4

Compression:

Stored size: 842 Bytes

Contents

RSpec::Matchers.define :match_definition do |expected_example|
  def extract_definition_comparable_json(path)
    if File.exist?(path)
      content = File.read(path) 
      json = JSON.parse(content)
      json.except('rabbit_version')
    else
      nil
    end
  end

  match do |actual_path|
    @actual_json = extract_definition_comparable_json(actual)
    expected_path = File.expand_path("../../fixtures/" + expected_example, __FILE__)
    @expected_json = extract_definition_comparable_json(expected_path)
  end

  failure_message do |actual_path|
    if @actual_json.nil?
      "'#{actual_path}' file does NOT exist"
    else
      "expected: \n#{@actual_json.pretty_inspect}\n\n to match definition: \n#{@expected_json.pretty_inspect}\n\n"
    end
  end

  description do
    "matches definition in '#{expected_example}'"
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rabbitmq-definition-0.1.3 spec/helpers/matchers.rb
rabbitmq-definition-0.1.2 spec/helpers/matchers.rb
rabbitmq-definition-0.1.1 spec/helpers/matchers.rb
rabbitmq-definition-0.1.0 spec/helpers/matchers.rb