muack 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/CHANGES.md +6 -0
- data/lib/muack/satisfy.rb +8 -1
- data/lib/muack/version.rb +1 -1
- data/muack.gemspec +4 -4
- data/test/test_from_readme.rb +4 -5
- data/test/test_satisfy.rb +23 -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: f7434ef1baf3aaeb9f7772ce6a8eedeb431132ba
|
4
|
+
data.tar.gz: e55ae09a1166fcd29e2cf50379af01a2d1e508fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc8ef5fffdfba3f044999cb2afb9e6ac612f2b0fa04db224590e9bbf6d720d4e73f418b509510e61d89a80819dfbfc8d56cef3ed40e1bb1009e48e2b83509ec9
|
7
|
+
data.tar.gz: 3b1181888ebc6130e215caa86c66e11c083b8dbbb7f6198c64b53fa93efc4a866fbcd7c3ebac8261bc86359eb15a37f9d7da1fd4b309b68b2b6818685a0780dc
|
data/.travis.yml
CHANGED
data/CHANGES.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# CHANGES
|
2
2
|
|
3
|
+
## Muack 1.0.3 -- 2014-03-11
|
4
|
+
|
5
|
+
* From now on, `Muack::API.hash_including` could accept `Muack::Satisfy` as
|
6
|
+
values. That means we could now use `hash_including(:key => is_a(String))`
|
7
|
+
or `hash_including(:url => match(/^https/))` and so on so forth.
|
8
|
+
|
3
9
|
## Muack 1.0.2 -- 2014-01-17
|
4
10
|
|
5
11
|
* Fixed a bug where spies do not really verify against actual arguments,
|
data/lib/muack/satisfy.rb
CHANGED
@@ -66,7 +66,14 @@ module Muack
|
|
66
66
|
class HashIncluding < Satisfy
|
67
67
|
def initialize hash
|
68
68
|
super lambda{ |actual_arg|
|
69
|
-
actual_arg.values_at(*hash.keys)
|
69
|
+
actual_arg.values_at(*hash.keys).zip(hash.values).all? do |(av, ev)|
|
70
|
+
if ev.kind_of?(Satisfy)
|
71
|
+
ev.match(av)
|
72
|
+
else
|
73
|
+
ev == av
|
74
|
+
end
|
75
|
+
end
|
76
|
+
}, [hash]
|
70
77
|
end
|
71
78
|
end
|
72
79
|
|
data/lib/muack/version.rb
CHANGED
data/muack.gemspec
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: muack 1.0.
|
2
|
+
# stub: muack 1.0.3 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "muack"
|
6
|
-
s.version = "1.0.
|
6
|
+
s.version = "1.0.3"
|
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 = "2014-
|
11
|
+
s.date = "2014-03-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 = [
|
@@ -46,7 +46,7 @@ Gem::Specification.new do |s|
|
|
46
46
|
"test/test_stub.rb"]
|
47
47
|
s.homepage = "https://github.com/godfat/muack"
|
48
48
|
s.licenses = ["Apache License 2.0"]
|
49
|
-
s.rubygems_version = "2.2.
|
49
|
+
s.rubygems_version = "2.2.2"
|
50
50
|
s.summary = "Muack -- A fast, small, yet powerful mocking library."
|
51
51
|
s.test_files = [
|
52
52
|
"test/test_any_instance_of.rb",
|
data/test/test_from_readme.rb
CHANGED
@@ -9,13 +9,12 @@ describe 'from README.md' do
|
|
9
9
|
after{ Muack.reset }
|
10
10
|
|
11
11
|
Context = Module.new{
|
12
|
-
def
|
13
|
-
|
14
|
-
end
|
12
|
+
def results; @results ||= []; end
|
13
|
+
def p res ; results << res ; end
|
15
14
|
|
16
15
|
def verify expects
|
17
|
-
return
|
18
|
-
|
16
|
+
return if results.empty?
|
17
|
+
results.zip(expects).each do |(res, exp)|
|
19
18
|
next if exp == 'ok'
|
20
19
|
if exp.start_with?('raise')
|
21
20
|
res.should.kind_of eval(exp.sub('raise', ''))
|
data/test/test_satisfy.rb
CHANGED
@@ -115,6 +115,13 @@ describe Muack::Satisfy do
|
|
115
115
|
Muack::EnsureReset.call
|
116
116
|
end
|
117
117
|
|
118
|
+
should 'satisfy with satisfy' do
|
119
|
+
mock(Str).say(hash_including(:b => is_a(Fixnum))){ |arg| arg[:b] }
|
120
|
+
Str.say(:a => 1, :b => 2).should.eq 2
|
121
|
+
Muack.verify.should.eq true
|
122
|
+
Muack::EnsureReset.call
|
123
|
+
end
|
124
|
+
|
118
125
|
should 'raise Unexpected error if passing unexpected argument' do
|
119
126
|
mock(Obj).say(hash_including(:b => 2)){ 'boo' }
|
120
127
|
begin
|
@@ -129,6 +136,22 @@ describe Muack::Satisfy do
|
|
129
136
|
Muack::EnsureReset.call
|
130
137
|
end
|
131
138
|
end
|
139
|
+
|
140
|
+
should 'raise Unexpected error if passing unsatisfied argument' do
|
141
|
+
mock(Obj).say(hash_including(:b => is_a(String))){ 'boo' }
|
142
|
+
begin
|
143
|
+
Obj.say(:b => 1)
|
144
|
+
'never'.should.eq 'reach'
|
145
|
+
rescue Muack::Unexpected => e
|
146
|
+
e.expected.should.eq \
|
147
|
+
'obj.say(Muack::API.hash_including({:b=>Muack::API.is_a(String)}))'
|
148
|
+
e.was .should.eq 'obj.say({:b=>1})'
|
149
|
+
e.message .should.eq "\nExpected: #{e.expected}\n but was: #{e.was}"
|
150
|
+
ensure
|
151
|
+
Muack.reset
|
152
|
+
Muack::EnsureReset.call
|
153
|
+
end
|
154
|
+
end
|
132
155
|
end
|
133
156
|
|
134
157
|
describe Muack::Including 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.0.
|
4
|
+
version: 1.0.3
|
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: 2014-
|
11
|
+
date: 2014-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |-
|
14
14
|
Muack -- A fast, small, yet powerful mocking library.
|
@@ -76,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
76
|
version: '0'
|
77
77
|
requirements: []
|
78
78
|
rubyforge_project:
|
79
|
-
rubygems_version: 2.2.
|
79
|
+
rubygems_version: 2.2.2
|
80
80
|
signing_key:
|
81
81
|
specification_version: 4
|
82
82
|
summary: Muack -- A fast, small, yet powerful mocking library.
|