muack 1.3.1 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGES.md +5 -0
- data/lib/muack/satisfying.rb +18 -9
- data/lib/muack/version.rb +1 -1
- data/muack.gemspec +4 -4
- data/test/test_satisfying.rb +15 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa632f54941b0ba538198221b3d03ec320e9df35
|
4
|
+
data.tar.gz: 386833604c697560c445c7df2ec677f5a5159cf2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c3ea805f32a36c9ec6bc82af5a705bae2ff4cbb059ab71c3dd2c1ed638784ee84d98ea244de4c95b72558e9da2256944c5d853aa9c9ea72f4c98b47014909bc
|
7
|
+
data.tar.gz: ba26968d9d944c7263160bf6583d8a0cfdd1def6711122b90ef59d5af108c5696869d5f283ab40de9120602ca76b4a8c01408bc4fdcf882049a4cc8b26f8db18
|
data/CHANGES.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# CHANGES
|
2
2
|
|
3
|
+
## Muack 1.3.2 -- 2015-06-11
|
4
|
+
|
5
|
+
* Fixed a bug for `where`, `having`, and `allowing` which should distinguish
|
6
|
+
between `nil` and `undefined` (which does not have a key in a hash)
|
7
|
+
|
3
8
|
## Muack 1.3.1 -- 2015-05-27
|
4
9
|
|
5
10
|
* Fixed a bug for `where`, `having`, and `allowing` which would raise an
|
data/lib/muack/satisfying.rb
CHANGED
@@ -116,6 +116,7 @@ module Muack
|
|
116
116
|
end
|
117
117
|
|
118
118
|
class Where < Satisfying
|
119
|
+
None = Object.new
|
119
120
|
def initialize spec
|
120
121
|
super([spec])
|
121
122
|
end
|
@@ -134,7 +135,7 @@ module Muack
|
|
134
135
|
private
|
135
136
|
def match_hash actual_arg, spec
|
136
137
|
(spec.keys | actual_arg.keys).all? do |key|
|
137
|
-
match_value(actual_arg
|
138
|
+
match_value(actual_arg, spec, key)
|
138
139
|
end
|
139
140
|
end
|
140
141
|
|
@@ -144,16 +145,24 @@ module Muack
|
|
144
145
|
end
|
145
146
|
end
|
146
147
|
|
147
|
-
def match_value av, ev
|
148
|
-
|
148
|
+
def match_value av, ev, key=None
|
149
|
+
if key == None
|
150
|
+
a, e = av, ev
|
151
|
+
elsif av.key?(key) && ev.key?(key)
|
152
|
+
a, e = av[key], ev[key]
|
153
|
+
else
|
154
|
+
return false
|
155
|
+
end
|
156
|
+
|
157
|
+
case e
|
149
158
|
when Satisfying
|
150
|
-
|
159
|
+
e.match(a)
|
151
160
|
when Hash
|
152
|
-
|
161
|
+
a.kind_of?(Hash) && match_hash(a, e)
|
153
162
|
when Array
|
154
|
-
|
163
|
+
a.kind_of?(Array) && match_array(a, e)
|
155
164
|
else
|
156
|
-
|
165
|
+
e == a
|
157
166
|
end
|
158
167
|
end
|
159
168
|
end
|
@@ -166,7 +175,7 @@ module Muack
|
|
166
175
|
private
|
167
176
|
def match_hash actual_arg, subset
|
168
177
|
subset.each_key.all? do |key|
|
169
|
-
match_value(actual_arg
|
178
|
+
match_value(actual_arg, subset, key)
|
170
179
|
end
|
171
180
|
end
|
172
181
|
end
|
@@ -179,7 +188,7 @@ module Muack
|
|
179
188
|
private
|
180
189
|
def match_hash actual_arg, superset
|
181
190
|
actual_arg.each_key.all? do |key|
|
182
|
-
match_value(actual_arg
|
191
|
+
match_value(actual_arg, superset, key)
|
183
192
|
end
|
184
193
|
end
|
185
194
|
end
|
data/lib/muack/version.rb
CHANGED
data/muack.gemspec
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: muack 1.3.
|
2
|
+
# stub: muack 1.3.2 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "muack"
|
6
|
-
s.version = "1.3.
|
6
|
+
s.version = "1.3.2"
|
7
7
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
9
9
|
s.require_paths = ["lib"]
|
10
10
|
s.authors = ["Lin Jen-Shin (godfat)"]
|
11
|
-
s.date = "2015-
|
11
|
+
s.date = "2015-06-11"
|
12
12
|
s.description = "Muack -- A fast, small, yet powerful mocking library.\n\nInspired by [RR][], and it's 32x times faster (750s vs 23s) than RR\nfor running [Rib][] tests.\n\n[RR]: https://github.com/rr/rr\n[Rib]: https://github.com/godfat/rib"
|
13
13
|
s.email = ["godfat (XD) godfat.org"]
|
14
14
|
s.files = [
|
@@ -48,7 +48,7 @@ Gem::Specification.new do |s|
|
|
48
48
|
"test/test_stub.rb"]
|
49
49
|
s.homepage = "https://github.com/godfat/muack"
|
50
50
|
s.licenses = ["Apache License 2.0"]
|
51
|
-
s.rubygems_version = "2.4.
|
51
|
+
s.rubygems_version = "2.4.8"
|
52
52
|
s.summary = "Muack -- A fast, small, yet powerful mocking library."
|
53
53
|
s.test_files = [
|
54
54
|
"test/test_any_instance_of.rb",
|
data/test/test_satisfying.rb
CHANGED
@@ -229,6 +229,11 @@ describe Muack::Satisfying do
|
|
229
229
|
e.was .should.eq 'obj.say({:a=>0})'
|
230
230
|
e.message .should.eq "\nExpected: #{e.expected}\n but was: #{e.was}"
|
231
231
|
end
|
232
|
+
|
233
|
+
would 'respect all keys', :groups => [:only] do
|
234
|
+
mock(Obj).say(where(:a => 0)){ 'nnf' }
|
235
|
+
should.raise(Muack::Unexpected){Obj.say(:a => 0, :b => nil)}
|
236
|
+
end
|
232
237
|
end
|
233
238
|
|
234
239
|
describe Muack::Having do
|
@@ -274,6 +279,11 @@ describe Muack::Satisfying do
|
|
274
279
|
e.was .should.eq 'obj.say({:b=>1})'
|
275
280
|
e.message .should.eq "\nExpected: #{e.expected}\n but was: #{e.was}"
|
276
281
|
end
|
282
|
+
|
283
|
+
would 'respect all keys' do
|
284
|
+
mock(Obj).say(having(:a => 0, :b => nil)){ 'nnf' }
|
285
|
+
should.raise(Muack::Unexpected){Obj.say(:a => 0)}
|
286
|
+
end
|
277
287
|
end
|
278
288
|
|
279
289
|
describe Muack::Allowing do
|
@@ -319,6 +329,11 @@ describe Muack::Satisfying do
|
|
319
329
|
e.was .should.eq 'obj.say({:b=>"1", :c=>2})'
|
320
330
|
e.message .should.eq "\nExpected: #{e.expected}\n but was: #{e.was}"
|
321
331
|
end
|
332
|
+
|
333
|
+
would 'respect all keys' do
|
334
|
+
mock(Obj).say(allowing(:a => 0)){ 'nnf' }
|
335
|
+
should.raise(Muack::Unexpected){Obj.say(:a => 0, :b => nil)}
|
336
|
+
end
|
322
337
|
end
|
323
338
|
|
324
339
|
describe Muack::Satisfying do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: muack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lin Jen-Shin (godfat)
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |-
|
14
14
|
Muack -- A fast, small, yet powerful mocking library.
|
@@ -78,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
78
78
|
version: '0'
|
79
79
|
requirements: []
|
80
80
|
rubyforge_project:
|
81
|
-
rubygems_version: 2.4.
|
81
|
+
rubygems_version: 2.4.8
|
82
82
|
signing_key:
|
83
83
|
specification_version: 4
|
84
84
|
summary: Muack -- A fast, small, yet powerful mocking library.
|