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 +1 -1
- data/hash_dealer.gemspec +1 -1
- data/lib/core_extensions.rb +32 -0
- data/spec/lib/matcher_spec.rb +6 -0
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.4.
|
1
|
+
1.4.4
|
data/hash_dealer.gemspec
CHANGED
data/lib/core_extensions.rb
CHANGED
@@ -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}")
|
data/spec/lib/matcher_spec.rb
CHANGED
@@ -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.
|
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: -
|
156
|
+
hash: -1396539003165277442
|
157
157
|
segments:
|
158
158
|
- 0
|
159
159
|
version: "0"
|