hash_dealer 1.4.3 → 1.4.4

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.4.3
1
+ 1.4.4
data/hash_dealer.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "hash_dealer"
8
- s.version = "1.4.3"
8
+ s.version = "1.4.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Dan Langevin"]
@@ -46,6 +46,38 @@ end
46
46
  EOE
47
47
  end
48
48
 
49
+ class BooleanMatcher
50
+ attr_reader :instance
51
+ def initialize(instance)
52
+ @instance = instance
53
+ end
54
+ def ==(other)
55
+ return (other.is_a?(TrueClass) || other.is_a?(FalseClass) || other.is_a?(BooleanMatcher))
56
+ end
57
+ alias_method :eql?, :==
58
+ end
59
+
60
+ [TrueClass, FalseClass].each do |klass|
61
+ klass.class_eval <<-EOE, __FILE__, __LINE__ +1
62
+ def matcher(opts={})
63
+ BooleanMatcher.new(self)
64
+ end
65
+
66
+ alias_method :old_eql?, :eql?
67
+ alias_method :old_equals_equals, :==
68
+
69
+ def ==(other)
70
+ return other == self if other.is_a?(BooleanMatcher)
71
+ return self.old_equals_equals(other)
72
+ end
73
+
74
+ def eql?(other)
75
+ return other.eql?(self) if other.is_a?(BooleanMatcher)
76
+ return self.old_eql?(other)
77
+ end
78
+ EOE
79
+ end
80
+
49
81
  class Numeric
50
82
  def matcher(opts={})
51
83
  PathString.new(":#{self}")
@@ -48,4 +48,10 @@ describe "match_response Matcher" do
48
48
  Comparator.normalize_value({:x => [[{:y => "z"}]]})["x"].first.first["y"].should eql "z"
49
49
  end
50
50
 
51
+ it "should convert booleans to a matcher class that evaluates to either true or false" do
52
+ {"a" => true}.matcher.should match_response({"a" => false})
53
+ {"a" => {"b" => false}}.matcher.should match_response({"a" => {"b" => false}})
54
+ end
55
+
56
+
51
57
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: hash_dealer
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.4.3
5
+ version: 1.4.4
6
6
  platform: ruby
7
7
  authors:
8
8
  - Dan Langevin
@@ -153,7 +153,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
153
153
  requirements:
154
154
  - - ">="
155
155
  - !ruby/object:Gem::Version
156
- hash: -2331371851273189618
156
+ hash: -1396539003165277442
157
157
  segments:
158
158
  - 0
159
159
  version: "0"