Sha256: eb72d7bb9cac2c749fe934abac6dd19a237935af31cf8c763a91aa74d6479223

Contents?: true

Size: 439 Bytes

Versions: 4

Compression:

Stored size: 439 Bytes

Contents

require 'rspec/expectations'

RSpec::Matchers.define :be_json_of do |fixture_name|
  path = File.join(File.dirname(__FILE__), '..', 'fixtures', "#{fixture_name.to_s}.json")
  expected_json = JSON.minify File.read path
  match do |actual|
    # return false unless actual.is_a?(String)
    actual.strip == expected_json.strip
  end
  failure_message do |actual|
    "Expecting '#{expected_json.strip}', but got '#{actual.strip}'"
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
kanade-0.1.1 spec/matchers/json_matcher.rb
kanade-0.1.0 spec/matchers/json_matcher.rb
kanade-0.1.0.beta2 spec/matchers/json_matcher.rb
kanade-0.1.0.beta1 spec/matchers/json_matcher.rb