spy 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/README.md +29 -31
- data/lib/spy.rb +23 -5
- data/lib/spy/agency.rb +1 -1
- data/lib/spy/api.rb +72 -0
- data/lib/spy/exceptions.rb +6 -31
- data/lib/spy/integration.rb +42 -0
- data/lib/spy/mock.rb +24 -25
- data/lib/spy/subroutine.rb +5 -4
- data/lib/spy/version.rb +1 -1
- data/test/integration/test_api.rb +40 -0
- data/test/spy/test_mock.rb +7 -5
- metadata +23 -34
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0b0de47cae4d5ee5cf4709bc537489dc137007b5
|
4
|
+
data.tar.gz: 4e6cff2b7b27e27c787ad93d5fb1af723f382739
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fed5be1346e1c658363827797fd9a20b1241f33724c4af92b8f1616887967a3ff44ea51409ec027a8187b9b95db606cd361972cbed323c7bb4ebdbf5c734d8d1
|
7
|
+
data.tar.gz: 65ce3667c4665ef8a396d0e6ab3248d88d57eaedff2b6393865d661813b4253c63e213990fa0f3e8684c5e7b882e92db44dd74c1e2cd1a7483611d1239e968a7
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -101,7 +101,7 @@ when the method is not stubbed. Spy will not let you stub a method that wasn't
|
|
101
101
|
on the mocked class. You can spy on the classes and call through to the original method.
|
102
102
|
|
103
103
|
```ruby
|
104
|
-
book = Spy.mock(Book)
|
104
|
+
book = Spy.mock(Book) # Must be a class
|
105
105
|
Spy.on(book, first_name: "Neil", last_name: "Gaiman")
|
106
106
|
Spy.on(book, :author).and_call_through
|
107
107
|
book.author #=> "Neil Gaiman"
|
@@ -113,7 +113,7 @@ book.title #=> Spy::NeverHookedError: 'title' was never hooked on mock spy.
|
|
113
113
|
To stub methods during instantiation just add arguments.
|
114
114
|
|
115
115
|
```ruby
|
116
|
-
book = Spy.mock(
|
116
|
+
book = Spy.mock(Book, :first_name, author: "Neil Gaiman")
|
117
117
|
```
|
118
118
|
|
119
119
|
### Arbitrary Handling
|
@@ -139,7 +139,7 @@ end
|
|
139
139
|
When you stub a method it returns a spy. A spy records what calls have been made to a given method.
|
140
140
|
|
141
141
|
```ruby
|
142
|
-
validator = Spy.
|
142
|
+
validator = Spy.mock(Validator)
|
143
143
|
validate_spy = Spy.on(validator, :validate)
|
144
144
|
validate_spy.has_been_called? #=> false
|
145
145
|
|
@@ -181,26 +181,30 @@ first_call.result #=> "hello world"
|
|
181
181
|
first_call.called_from #=> "file_name.rb:line_number"
|
182
182
|
```
|
183
183
|
|
184
|
-
|
184
|
+
## Test Framework Integration
|
185
185
|
|
186
|
-
|
186
|
+
### MiniTest/TestUnit
|
187
|
+
|
188
|
+
in your `test_helper.rb` add this line after you include your framework
|
187
189
|
|
188
190
|
```ruby
|
189
|
-
require
|
190
|
-
|
191
|
+
require 'spy/integration'
|
192
|
+
```
|
191
193
|
|
194
|
+
In your test file
|
192
195
|
|
193
|
-
|
196
|
+
```ruby
|
194
197
|
def test_title
|
195
|
-
book =
|
196
|
-
title_spy =
|
198
|
+
book = Book.new
|
199
|
+
title_spy = Spy.on(book, title)
|
197
200
|
book.title
|
198
201
|
book.title
|
199
202
|
|
203
|
+
assert_received book, :title
|
204
|
+
|
200
205
|
assert title_spy.has_been_called?
|
201
206
|
assert_equal 2, title_spy.calls.count
|
202
207
|
end
|
203
|
-
end
|
204
208
|
```
|
205
209
|
|
206
210
|
### Rspec
|
@@ -209,34 +213,28 @@ In `spec_helper.rb`
|
|
209
213
|
|
210
214
|
```ruby
|
211
215
|
require "rspec/autorun"
|
212
|
-
require "spy"
|
216
|
+
require "spy/integration"
|
213
217
|
RSpec.configure do |c|
|
214
|
-
c.
|
215
|
-
c.mock_with :absolutely_nothing # this is completely optional.
|
218
|
+
c.mock_with Spy::RspecAdapter
|
216
219
|
end
|
220
|
+
```
|
221
|
+
|
222
|
+
In your test
|
217
223
|
|
224
|
+
```ruby
|
218
225
|
describe Book do
|
219
226
|
it "title can be called" do
|
220
227
|
book = book.new
|
221
|
-
|
222
|
-
book.
|
223
|
-
book.
|
224
|
-
|
225
|
-
expect(title_spy).to have_been_called
|
226
|
-
expect(title_spy.calls.count).to eq(2)
|
227
|
-
end
|
228
|
-
end
|
229
|
-
```
|
228
|
+
page_spy = Spy.on(book, page)
|
229
|
+
book.page(1)
|
230
|
+
book.page(2)
|
230
231
|
|
231
|
-
|
232
|
+
expect(book).to have_received(:page)
|
233
|
+
expect(book).to have_received(:page).with(1)
|
234
|
+
expect(book).to have_received(:page).with(2)
|
232
235
|
|
233
|
-
|
234
|
-
|
235
|
-
class Test::Unit::TestCase
|
236
|
-
def teardown
|
237
|
-
# if you don't add super to every teardown then you will have to add this
|
238
|
-
# line to every file.
|
239
|
-
Spy.teardown
|
236
|
+
expect(page_spy).to have_been_called
|
237
|
+
expect(page_spy.calls.count).to eq(2)
|
240
238
|
end
|
241
239
|
end
|
242
240
|
```
|
data/lib/spy.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
|
+
require "spy/exceptions"
|
1
2
|
require "spy/core_ext/marshal"
|
2
3
|
require "spy/agency"
|
4
|
+
require "spy/api"
|
3
5
|
require "spy/base"
|
4
6
|
require "spy/call_log"
|
5
7
|
require "spy/constant"
|
6
|
-
require "spy/exceptions"
|
7
8
|
require "spy/mock"
|
8
9
|
require "spy/nest"
|
9
10
|
require "spy/subroutine"
|
@@ -41,7 +42,11 @@ module Spy
|
|
41
42
|
removed_spies.size > 1 ? removed_spies : removed_spies.first
|
42
43
|
end
|
43
44
|
|
44
|
-
#
|
45
|
+
# stubs the instance method of a given Class so all instance methods of this
|
46
|
+
# class will have the given method stubbed
|
47
|
+
# @param base_class [Class] The class you wish to stub the instance methods of
|
48
|
+
# @param method_names *[Symbol, Hash]
|
49
|
+
# @return [Spy,Array<Spy>]
|
45
50
|
def on_instance_method(base_class, *method_names)
|
46
51
|
spies = method_names.map do |method_name|
|
47
52
|
create_and_hook_spy(base_class, method_name, false)
|
@@ -50,13 +55,17 @@ module Spy
|
|
50
55
|
spies.size > 1 ? spies : spies.first
|
51
56
|
end
|
52
57
|
|
53
|
-
|
58
|
+
# remove the stub from given Class
|
59
|
+
# @param base_class [Class]
|
60
|
+
# @param method_names *[Symbol]
|
61
|
+
# @return [Spy]
|
62
|
+
def off_instance_method(base_class, *method_names)
|
54
63
|
removed_spies = method_names.map do |method_name|
|
55
|
-
spy = Subroutine.get(
|
64
|
+
spy = Subroutine.get(base_class, method_name, false)
|
56
65
|
if spy
|
57
66
|
spy.unhook
|
58
67
|
else
|
59
|
-
raise NoSpyError, "#{method_name} was not hooked on #{
|
68
|
+
raise NoSpyError, "#{method_name} was not hooked on #{base_class.inspect}."
|
60
69
|
end
|
61
70
|
end
|
62
71
|
|
@@ -108,6 +117,10 @@ module Spy
|
|
108
117
|
spies.size > 1 ? spies : spies.first
|
109
118
|
end
|
110
119
|
|
120
|
+
# Create a mock object from a given class
|
121
|
+
# @param klass [Class] class you wish to mock
|
122
|
+
# @param stubs *[Symbol, Hash] methods you with to stub
|
123
|
+
# @return [Object]
|
111
124
|
def mock(klass, *stubs)
|
112
125
|
new_mock = Mock.new(klass).new
|
113
126
|
if stubs.size > 0
|
@@ -116,6 +129,11 @@ module Spy
|
|
116
129
|
new_mock
|
117
130
|
end
|
118
131
|
|
132
|
+
# create a mock object from a given class with all the methods stubbed out
|
133
|
+
# and returning nil unless specified otherwise.
|
134
|
+
# @param klass [Class] class you wish to mock
|
135
|
+
# @param stubs *[Symbol, Hash] methods you with to stub
|
136
|
+
# @return [Object]
|
119
137
|
def mock_all(klass, *stubs)
|
120
138
|
mock_klass = Mock.new(klass)
|
121
139
|
new_mock = mock_klass.new
|
data/lib/spy/agency.rb
CHANGED
data/lib/spy/api.rb
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
module Spy
|
2
|
+
module API
|
3
|
+
DidNotReceiveError = Class.new(Spy::Error)
|
4
|
+
|
5
|
+
def assert_received(base_object, method_name)
|
6
|
+
assert Subroutine.get(base_object, method_name).has_been_called?,
|
7
|
+
"#{method_name} was not called on #{base_object.inspect}"
|
8
|
+
end
|
9
|
+
|
10
|
+
def assert_received_with(base_object, method_name, *args, &block)
|
11
|
+
assert Subroutine.get(base_object, method_name).has_been_called_with?(*args, &block),
|
12
|
+
"#{method_name} was not called on #{base_object.inspect} with #{args.inspect}"
|
13
|
+
end
|
14
|
+
|
15
|
+
def have_received(method_name)
|
16
|
+
HaveReceived.new(method_name)
|
17
|
+
end
|
18
|
+
|
19
|
+
class HaveReceived
|
20
|
+
attr_reader :method_name, :actual
|
21
|
+
|
22
|
+
def initialize(method_name)
|
23
|
+
@method_name = method_name
|
24
|
+
@with = nil
|
25
|
+
end
|
26
|
+
|
27
|
+
def matches?(actual)
|
28
|
+
@actual = actual
|
29
|
+
case @with
|
30
|
+
when Proc
|
31
|
+
spy.has_been_called_with?(&@with)
|
32
|
+
when Array
|
33
|
+
spy.has_been_called_with?(*@with)
|
34
|
+
else
|
35
|
+
spy.has_been_called?
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def with(*args)
|
40
|
+
@with = block_given? ? Proc.new : args
|
41
|
+
self
|
42
|
+
end
|
43
|
+
|
44
|
+
def failure_message_for_should
|
45
|
+
"expected #{actual.inspect} to have received #{method_name.inspect}#{args_message}"
|
46
|
+
end
|
47
|
+
|
48
|
+
def failure_message_for_should_not
|
49
|
+
"expected #{actual.inspect} to not have received #{method_name.inspect}#{args_message}, but did"
|
50
|
+
end
|
51
|
+
|
52
|
+
def description
|
53
|
+
"to have received #{method_name.inspect}#{args_message}"
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def args_message
|
59
|
+
case @with
|
60
|
+
when Array
|
61
|
+
" with #{@with.inspect}"
|
62
|
+
when Proc
|
63
|
+
" with given block"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def spy
|
68
|
+
@spy ||= Subroutine.get(@actual, @method_name)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
data/lib/spy/exceptions.rb
CHANGED
@@ -1,33 +1,8 @@
|
|
1
1
|
module Spy
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
end
|
9
|
-
|
10
|
-
class AlreadyHookedError < Error
|
11
|
-
def to_s
|
12
|
-
@mesg || "Spy is already hooked."
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
class NotHookedError < Error
|
17
|
-
def to_s
|
18
|
-
@mesg || "Spy was not hooked."
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
class NeverHookedError < Error
|
23
|
-
def to_s
|
24
|
-
@mesg || "Spy was never hooked."
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
class NoSpyError < Error
|
29
|
-
def to_s
|
30
|
-
@mesg || "Spy could not be found"
|
31
|
-
end
|
32
|
-
end
|
2
|
+
Error = Class.new(StandardError)
|
3
|
+
AlreadyStubbedError = Class.new(Error)
|
4
|
+
AlreadyHookedError = Class.new(Error)
|
5
|
+
NotHookedError = Class.new(Error)
|
6
|
+
NeverHookedError = Class.new(Error)
|
7
|
+
NoSpyError = Class.new(Error)
|
33
8
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'spy'
|
2
|
+
|
3
|
+
module Spy
|
4
|
+
if defined?(::MiniTest::Unit::TestCase)
|
5
|
+
class MiniTestAdapter
|
6
|
+
include API
|
7
|
+
def after_teardown
|
8
|
+
super
|
9
|
+
Spy.teardown
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
::MiniTest::Unit::TestCase.send(:include, MiniTestAdapter)
|
14
|
+
end
|
15
|
+
|
16
|
+
if defined?(::Test::Unit::TestCase) && !(defined?(::MiniTest::Unit::TestCase) && (::Test::Unit::TestCase < ::MiniTest::Unit::TestCase)) && !(defined?(::MiniTest::Spec) && (::Test::Unit::TestCase < ::MiniTest::Spec))
|
17
|
+
|
18
|
+
class TestUnitAdapter
|
19
|
+
include API
|
20
|
+
def self.included(mod)
|
21
|
+
mod.teardown :spy_teardown, :after => :append
|
22
|
+
end
|
23
|
+
|
24
|
+
def spy_teardown
|
25
|
+
Spy.teardown
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
::Test::Unit::TestCase.send(:include, TestUnitAdapter)
|
30
|
+
end
|
31
|
+
|
32
|
+
class RspecAdapter
|
33
|
+
include API
|
34
|
+
def setup_mocks_for_rspec
|
35
|
+
end
|
36
|
+
def verify_mocks_for_rspec
|
37
|
+
end
|
38
|
+
def teardown_mocks_for_rspec
|
39
|
+
Spy.teardown
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/spy/mock.rb
CHANGED
@@ -12,35 +12,32 @@ module Spy
|
|
12
12
|
Agency.instance.recruit(self)
|
13
13
|
end
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
alias :kind_of? :is_a?
|
20
|
-
|
15
|
+
# the only method that doesn't work correctly of a mock if inherited. We
|
16
|
+
# overwite for compatibility.
|
17
|
+
# @param other [Class]
|
18
|
+
# @return [Boolean]
|
21
19
|
def instance_of?(other)
|
22
20
|
other == self.class
|
23
21
|
end
|
24
22
|
|
23
|
+
# returns the original class method if the current method is a mock_method
|
24
|
+
# @param method_name [Symbol, String]
|
25
|
+
# @return [Method]
|
25
26
|
def method(method_name)
|
26
27
|
new_method = super
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
begin
|
31
|
-
_mock_class.send(:remove_method, method_name)
|
32
|
-
real_method = super
|
33
|
-
ensure
|
34
|
-
_mock_class.send(:define_method, method_name, new_method)
|
35
|
-
end
|
36
|
-
|
37
|
-
real_method
|
28
|
+
parameters = new_method.parameters
|
29
|
+
if parameters.size >= 1 && parameters.last.last == :mock_method
|
30
|
+
self.class.instance_method(method_name).bind(self)
|
38
31
|
else
|
39
32
|
new_method
|
40
33
|
end
|
41
34
|
end
|
42
35
|
|
43
36
|
class << self
|
37
|
+
# This will create a new Mock class with all the instance methods of given
|
38
|
+
# klass mocked out.
|
39
|
+
# @param klass [Class]
|
40
|
+
# @return [Class]
|
44
41
|
def new(klass)
|
45
42
|
mock_klass = Class.new(klass)
|
46
43
|
mock_klass.class_exec do
|
@@ -56,6 +53,8 @@ module Spy
|
|
56
53
|
mock_klass
|
57
54
|
end
|
58
55
|
|
56
|
+
private
|
57
|
+
|
59
58
|
def included(mod)
|
60
59
|
method_classes = classes_to_override_methods(mod)
|
61
60
|
|
@@ -65,13 +64,13 @@ module Spy
|
|
65
64
|
mocked_methods << method_name
|
66
65
|
args = args_for_method(mod.instance_method(method_name))
|
67
66
|
|
68
|
-
mod.class_eval <<-DEF_METHOD, __FILE__, __LINE__+1
|
67
|
+
mod.class_eval <<-DEF_METHOD, __FILE__, __LINE__ + 1
|
69
68
|
def #{method_name}(#{args})
|
70
69
|
raise ::Spy::NeverHookedError, "'#{method_name}' was never hooked on mock spy."
|
71
70
|
end
|
72
|
-
|
73
|
-
#{visibility} :#{method_name}
|
74
71
|
DEF_METHOD
|
72
|
+
|
73
|
+
mod.send(visibility, method_name)
|
75
74
|
end
|
76
75
|
end
|
77
76
|
|
@@ -80,8 +79,6 @@ module Spy
|
|
80
79
|
end
|
81
80
|
end
|
82
81
|
|
83
|
-
private
|
84
|
-
|
85
82
|
def classes_to_override_methods(mod)
|
86
83
|
method_classes = mod.ancestors
|
87
84
|
method_classes.shift
|
@@ -95,7 +92,7 @@ module Spy
|
|
95
92
|
|
96
93
|
def get_inherited_methods(klass_ancestors, visibility)
|
97
94
|
instance_methods = klass_ancestors.map do |klass|
|
98
|
-
|
95
|
+
klass.send("#{visibility}_instance_methods".to_sym, false)
|
99
96
|
end
|
100
97
|
instance_methods.flatten!
|
101
98
|
instance_methods.uniq!
|
@@ -103,7 +100,8 @@ module Spy
|
|
103
100
|
end
|
104
101
|
|
105
102
|
def args_for_method(method)
|
106
|
-
args = method.parameters
|
103
|
+
args = method.parameters
|
104
|
+
args.map! do |type,name|
|
107
105
|
name ||= :args
|
108
106
|
case type
|
109
107
|
when :req
|
@@ -113,7 +111,8 @@ module Spy
|
|
113
111
|
when :rest
|
114
112
|
"*#{name}"
|
115
113
|
end
|
116
|
-
end
|
114
|
+
end
|
115
|
+
args.compact!
|
117
116
|
args << "&mock_method"
|
118
117
|
args.join(",")
|
119
118
|
end
|
data/lib/spy/subroutine.rb
CHANGED
@@ -193,9 +193,8 @@ module Spy
|
|
193
193
|
# @return [Boolean]
|
194
194
|
def has_been_called_with?(*args)
|
195
195
|
raise NeverHookedError unless @was_hooked
|
196
|
-
|
197
|
-
|
198
|
-
end
|
196
|
+
match = block_given? ? Proc.new : proc { |call| call.args == args }
|
197
|
+
calls.any?(&match)
|
199
198
|
end
|
200
199
|
|
201
200
|
# invoke that the method has been called. You really shouldn't use this
|
@@ -331,7 +330,9 @@ module Spy
|
|
331
330
|
if base_object.respond_to?(method_name, true)
|
332
331
|
spied_method = base_object.method(method_name)
|
333
332
|
end
|
334
|
-
elsif (base_object.
|
333
|
+
elsif (base_object.public_instance_methods +
|
334
|
+
base_object.protected_instance_methods +
|
335
|
+
base_object.private_instance_methods).include?(method_name)
|
335
336
|
spied_method = base_object.instance_method(method_name)
|
336
337
|
end
|
337
338
|
|
data/lib/spy/version.rb
CHANGED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class TestApi < MiniTest::Unit::TestCase
|
4
|
+
include Spy::API
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@pen = Pen.new
|
8
|
+
Spy.on(@pen, :write)
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_assert_received
|
12
|
+
@pen.write(:hello)
|
13
|
+
assert_received(@pen, :write)
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_assert_received_with
|
17
|
+
@pen.write(:world)
|
18
|
+
assert_received_with(@pen, :write, :world)
|
19
|
+
assert_received_with(@pen, :write) do |call|
|
20
|
+
call.args == [:world]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_have_received
|
25
|
+
@pen.write(:foo)
|
26
|
+
matcher = have_received(:write)
|
27
|
+
assert matcher.matches?(@pen)
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_have_received_with
|
31
|
+
@pen.write(:bar)
|
32
|
+
matcher = have_received(:write).with(:bar)
|
33
|
+
assert matcher.matches?(@pen)
|
34
|
+
|
35
|
+
matcher = have_received(:write).with do |call|
|
36
|
+
call.args == [:bar]
|
37
|
+
end
|
38
|
+
assert matcher.matches?(@pen)
|
39
|
+
end
|
40
|
+
end
|
data/test/spy/test_mock.rb
CHANGED
@@ -76,11 +76,13 @@ module Spy
|
|
76
76
|
assert_equal pen_methods.sort, @pen_mock.mocked_methods.sort
|
77
77
|
end
|
78
78
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
79
|
+
buggy_methods = [:tap, :pretty_print_inspect]
|
80
|
+
methods_to_test = Object.instance_methods - buggy_methods
|
81
|
+
methods_to_test.each do |method_name|
|
82
|
+
object_method = Object.instance_method(method_name)
|
83
|
+
if object_method.arity == 0 || (RUBY_ENGINE != "jruby" && object_method.parameters == [])
|
84
|
+
define_method("test_base_class_method_#{method_name}_is_not_stubbed") do
|
85
|
+
@pen_mock.new.send(method_name)
|
84
86
|
end
|
85
87
|
end
|
86
88
|
end
|
metadata
CHANGED
@@ -1,110 +1,97 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.4.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Ryan Ong
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-05-08 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: pry
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: pry-nav
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - '>='
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - '>='
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: minitest
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - '>='
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: 4.5.0
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - '>='
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: 4.5.0
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: rspec-core
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- -
|
59
|
+
- - '>='
|
68
60
|
- !ruby/object:Gem::Version
|
69
61
|
version: '0'
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- -
|
66
|
+
- - '>='
|
76
67
|
- !ruby/object:Gem::Version
|
77
68
|
version: '0'
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: rspec-expectations
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
|
-
- -
|
73
|
+
- - '>='
|
84
74
|
- !ruby/object:Gem::Version
|
85
75
|
version: '0'
|
86
76
|
type: :development
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
|
-
- -
|
80
|
+
- - '>='
|
92
81
|
- !ruby/object:Gem::Version
|
93
82
|
version: '0'
|
94
83
|
- !ruby/object:Gem::Dependency
|
95
84
|
name: coveralls
|
96
85
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
86
|
requirements:
|
99
|
-
- -
|
87
|
+
- - '>='
|
100
88
|
- !ruby/object:Gem::Version
|
101
89
|
version: '0'
|
102
90
|
type: :development
|
103
91
|
prerelease: false
|
104
92
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
93
|
requirements:
|
107
|
-
- -
|
94
|
+
- - '>='
|
108
95
|
- !ruby/object:Gem::Version
|
109
96
|
version: '0'
|
110
97
|
description: A simple modern mocking library that uses the spy pattern and checks
|
@@ -125,11 +112,13 @@ files:
|
|
125
112
|
- Rakefile
|
126
113
|
- lib/spy.rb
|
127
114
|
- lib/spy/agency.rb
|
115
|
+
- lib/spy/api.rb
|
128
116
|
- lib/spy/base.rb
|
129
117
|
- lib/spy/call_log.rb
|
130
118
|
- lib/spy/constant.rb
|
131
119
|
- lib/spy/core_ext/marshal.rb
|
132
120
|
- lib/spy/exceptions.rb
|
121
|
+
- lib/spy/integration.rb
|
133
122
|
- lib/spy/mock.rb
|
134
123
|
- lib/spy/nest.rb
|
135
124
|
- lib/spy/subroutine.rb
|
@@ -151,6 +140,7 @@ files:
|
|
151
140
|
- spec/spy/stub_spec.rb
|
152
141
|
- spec/spy/to_ary_spec.rb
|
153
142
|
- spy.gemspec
|
143
|
+
- test/integration/test_api.rb
|
154
144
|
- test/integration/test_constant_spying.rb
|
155
145
|
- test/integration/test_instance_method.rb
|
156
146
|
- test/integration/test_mocking.rb
|
@@ -162,27 +152,26 @@ files:
|
|
162
152
|
homepage: https://github.com/ryanong/spy
|
163
153
|
licenses:
|
164
154
|
- MIT
|
155
|
+
metadata: {}
|
165
156
|
post_install_message:
|
166
157
|
rdoc_options: []
|
167
158
|
require_paths:
|
168
159
|
- lib
|
169
160
|
required_ruby_version: !ruby/object:Gem::Requirement
|
170
|
-
none: false
|
171
161
|
requirements:
|
172
|
-
- -
|
162
|
+
- - '>='
|
173
163
|
- !ruby/object:Gem::Version
|
174
164
|
version: 1.9.3
|
175
165
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
176
|
-
none: false
|
177
166
|
requirements:
|
178
|
-
- -
|
167
|
+
- - '>='
|
179
168
|
- !ruby/object:Gem::Version
|
180
169
|
version: '0'
|
181
170
|
requirements: []
|
182
171
|
rubyforge_project:
|
183
|
-
rubygems_version:
|
172
|
+
rubygems_version: 2.0.3
|
184
173
|
signing_key:
|
185
|
-
specification_version:
|
174
|
+
specification_version: 4
|
186
175
|
summary: Spy is a mocking library that was made for the modern age. It supports only
|
187
176
|
1.9.3+. Spy by default will raise an error if you attempt to stub a method that
|
188
177
|
doesn't exist or call the stubbed method with the wrong arity.
|
@@ -203,6 +192,7 @@ test_files:
|
|
203
192
|
- spec/spy/stub_implementation_spec.rb
|
204
193
|
- spec/spy/stub_spec.rb
|
205
194
|
- spec/spy/to_ary_spec.rb
|
195
|
+
- test/integration/test_api.rb
|
206
196
|
- test/integration/test_constant_spying.rb
|
207
197
|
- test/integration/test_instance_method.rb
|
208
198
|
- test/integration/test_mocking.rb
|
@@ -211,4 +201,3 @@ test_files:
|
|
211
201
|
- test/spy/test_subroutine.rb
|
212
202
|
- test/support/pen.rb
|
213
203
|
- test/test_helper.rb
|
214
|
-
has_rdoc:
|