File: spec_helper.rb

package info (click to toggle)
ruby-autoparse 0.3.3-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 364 kB
  • sloc: ruby: 2,250; makefile: 5
file content (30 lines) | stat: -rw-r--r-- 648 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
spec_dir = File.expand_path(File.dirname(__FILE__))
lib_dir = File.expand_path(File.join(spec_dir, '../lib'))

$:.unshift(lib_dir)
$:.uniq!

require 'autoparse'
require 'json'

module JSONMatchers
  class EqualsJson
    def initialize(expected)
      @expected = JSON.parse(expected)
    end
    def matches?(target)
      @target = JSON.parse(target)
      @target.eql?(@expected)
    end
    def failure_message
      "expected #{@target.inspect} to be #{@expected}"
    end
    def negative_failure_message
      "expected #{@target.inspect} not to be #{@expected}"
    end
  end
  
  def be_json(expected)
    EqualsJson.new(expected)
  end
end