much-stub 0.1.6 → 0.1.10
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/.l.yml +8 -0
- data/.rubocop.yml +3 -0
- data/.ruby-version +1 -0
- data/.t.yml +6 -0
- data/Gemfile +3 -1
- data/README.md +40 -35
- data/lib/much-stub/call_spy.rb +26 -25
- data/lib/much-stub/version.rb +1 -1
- data/lib/much-stub.rb +80 -59
- data/much-stub.gemspec +20 -12
- data/test/helper.rb +1 -1
- data/test/system/much-stub_tests.rb +113 -77
- data/test/unit/call_spy_tests.rb +3 -2
- data/test/unit/call_tests.rb +2 -2
- data/test/unit/much-stub_tests.rb +198 -124
- metadata +24 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4887423991f0a75b904ee6509aba48b42fc38e29917a273f15d63a839b37447f
|
4
|
+
data.tar.gz: 2cb8b33d23ed1b1ecd392edd48ecf39a3e100dfbb717e8f8be9a046882b06904
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ba31f8668fbff8601a7ff632067c8e67a5b071fce5df440cf29231b569abca9b98f88c1c2c1578fde4527249d4f7e156be1c1c2f249cc2a659e25aed1cb14a3
|
7
|
+
data.tar.gz: fac22cf5adabf21a7ea87032cd3b8ed6337ad57dacca019a30053798248b265a2e06935863f81a09f729687b265c38a4c976cfa01c6b4a358a5f73e312cb1332
|
data/.l.yml
ADDED
data/.rubocop.yml
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.0.2
|
data/.t.yml
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -16,15 +16,16 @@ Note: this was originally implemented in and extracted from [Assert](https://git
|
|
16
16
|
```ruby
|
17
17
|
# Given this object/API
|
18
18
|
|
19
|
-
my_class =
|
20
|
-
|
21
|
-
|
19
|
+
my_class =
|
20
|
+
Class.new do
|
21
|
+
def my_method
|
22
|
+
"my-method"
|
23
|
+
end
|
24
|
+
|
25
|
+
def my_value(value)
|
26
|
+
value
|
27
|
+
end
|
22
28
|
end
|
23
|
-
|
24
|
-
def my_value(value)
|
25
|
-
value
|
26
|
-
end
|
27
|
-
end
|
28
29
|
my_object = my_class.new
|
29
30
|
|
30
31
|
my_object.my_method
|
@@ -95,15 +96,16 @@ my_object.my_value(456)
|
|
95
96
|
```ruby
|
96
97
|
# Given this object/API
|
97
98
|
|
98
|
-
my_class =
|
99
|
-
|
100
|
-
value
|
101
|
-
|
99
|
+
my_class =
|
100
|
+
Class.new do
|
101
|
+
def basic_method(value)
|
102
|
+
value
|
103
|
+
end
|
102
104
|
|
103
|
-
|
104
|
-
|
105
|
+
def iterator_method(items, &block)
|
106
|
+
items.each(&block)
|
107
|
+
end
|
105
108
|
end
|
106
|
-
end
|
107
109
|
my_object = my_class.new
|
108
110
|
|
109
111
|
# Store method call arguments/blocks for spying.
|
@@ -189,11 +191,12 @@ basic_method_calls.first.args
|
|
189
191
|
```ruby
|
190
192
|
# Given this object/API ...
|
191
193
|
|
192
|
-
my_class =
|
193
|
-
|
194
|
-
|
194
|
+
my_class =
|
195
|
+
Class.new do
|
196
|
+
def build_thing(thing_value);
|
197
|
+
Thing.new(value)
|
198
|
+
end
|
195
199
|
end
|
196
|
-
end
|
197
200
|
my_object = my_class.new
|
198
201
|
|
199
202
|
# ... and this Test Double.
|
@@ -223,11 +226,12 @@ Use the `.tap` method to spy on method calls while preserving the original metho
|
|
223
226
|
```ruby
|
224
227
|
# Given this object/API
|
225
228
|
|
226
|
-
my_class =
|
227
|
-
|
228
|
-
value
|
229
|
+
my_class =
|
230
|
+
Class.new do
|
231
|
+
def basic_method(value)
|
232
|
+
value.to_s
|
233
|
+
end
|
229
234
|
end
|
230
|
-
end
|
231
235
|
my_object = my_class.new
|
232
236
|
|
233
237
|
# Normal stubs override the original behavior and return value...
|
@@ -275,11 +279,12 @@ class Thing
|
|
275
279
|
end
|
276
280
|
end
|
277
281
|
|
278
|
-
my_class =
|
279
|
-
|
280
|
-
|
282
|
+
my_class =
|
283
|
+
Class.new do
|
284
|
+
def thing(value)
|
285
|
+
Thing.new(value)
|
286
|
+
end
|
281
287
|
end
|
282
|
-
end
|
283
288
|
my_object = my_class.new
|
284
289
|
|
285
290
|
# Use `MuchStub.tap` to stub any thing instances created by `my_object.thing`
|
@@ -306,16 +311,16 @@ Use the `.spy` method to spy on method calls. This is especially helpful for spy
|
|
306
311
|
```ruby
|
307
312
|
# Given this object/API
|
308
313
|
|
309
|
-
myclass =
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
end
|
314
|
+
myclass =
|
315
|
+
Class.new do
|
316
|
+
def one; self; end
|
317
|
+
def two(val); self; end
|
318
|
+
def three; self; end
|
319
|
+
def ready?; false; end
|
320
|
+
end
|
315
321
|
myobj = myclass.new
|
316
322
|
|
317
|
-
spy =
|
318
|
-
MuchStub.spy(myobj :one, :two, :three, ready?: true)
|
323
|
+
spy = MuchStub.spy(myobj :one, :two, :three, ready?: true)
|
319
324
|
|
320
325
|
assert_equal spy, myobj.one
|
321
326
|
assert_equal spy, myobj.two("a")
|
data/lib/much-stub/call_spy.rb
CHANGED
@@ -6,14 +6,14 @@ module MuchStub
|
|
6
6
|
class CallSpy < ::BasicObject
|
7
7
|
METHOD_NAME_REPLACEMENTS = {
|
8
8
|
"!" => "_bang",
|
9
|
-
"?" => "_predicate"
|
9
|
+
"?" => "_predicate",
|
10
10
|
}.freeze
|
11
11
|
|
12
12
|
def initialize(**return_values)
|
13
|
-
@call_spy_return_values = return_values.transform_keys
|
14
|
-
@call_spy_method_calls = ::Hash.new
|
13
|
+
@call_spy_return_values = return_values.transform_keys(&:to_s)
|
14
|
+
@call_spy_method_calls = ::Hash.new{ |hash, key| hash[key] = [] }
|
15
15
|
@call_spy_method_return_values =
|
16
|
-
::Hash.new
|
16
|
+
::Hash.new{ |hash, key| hash[key] = call_spy_return_value_proc(key) }
|
17
17
|
end
|
18
18
|
|
19
19
|
def call_spy_tap
|
@@ -22,23 +22,23 @@ module MuchStub
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def ==(other)
|
25
|
-
|
25
|
+
equal?(other)
|
26
26
|
end
|
27
27
|
|
28
28
|
def ===(other)
|
29
|
-
|
29
|
+
equal?(other)
|
30
30
|
end
|
31
31
|
|
32
32
|
def eql?(other)
|
33
|
-
|
33
|
+
equal?(other)
|
34
34
|
end
|
35
35
|
|
36
36
|
def equal?(other)
|
37
|
-
|
37
|
+
__id__ == other.__id__
|
38
38
|
end
|
39
39
|
|
40
40
|
def hash
|
41
|
-
|
41
|
+
__id__
|
42
42
|
end
|
43
43
|
|
44
44
|
def respond_to?(*)
|
@@ -46,7 +46,7 @@ module MuchStub
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def inspect
|
49
|
-
"#<MuchStub::CallSpy:#{"0x0%x" % (
|
49
|
+
"#<MuchStub::CallSpy:#{"0x0%x" % (__id__ << 1)}>"
|
50
50
|
end
|
51
51
|
|
52
52
|
private
|
@@ -56,14 +56,14 @@ module MuchStub
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def call_spy_return_value_proc(method_name)
|
59
|
-
value = @call_spy_return_values.fetch(method_name, ::Proc.new
|
60
|
-
value.respond_to?(:call) ? value : ::Proc.new
|
59
|
+
value = @call_spy_return_values.fetch(method_name, ::Proc.new{ self })
|
60
|
+
value.respond_to?(:call) ? value : ::Proc.new{ value }
|
61
61
|
end
|
62
62
|
|
63
63
|
def call_spy_normalize_method_name(name)
|
64
|
-
METHOD_NAME_REPLACEMENTS.reduce(name.to_s)
|
64
|
+
METHOD_NAME_REPLACEMENTS.reduce(name.to_s) do |acc, (source, replacement)|
|
65
65
|
acc.gsub(source, replacement)
|
66
|
-
|
66
|
+
end
|
67
67
|
end
|
68
68
|
|
69
69
|
def call_spy_define_spied_method(name)
|
@@ -79,7 +79,9 @@ module MuchStub
|
|
79
79
|
spied_method_name = query_method_match[1]
|
80
80
|
query_method_suffix = query_method_match[2]
|
81
81
|
method_name = call_spy_normalize_method_name(spied_method_name)
|
82
|
-
call_spy_define_metaclass_method(
|
82
|
+
call_spy_define_metaclass_method(
|
83
|
+
"#{method_name}#{query_method_suffix}",
|
84
|
+
) do
|
83
85
|
yield(method_name) if ::Kernel.block_given?
|
84
86
|
end
|
85
87
|
end
|
@@ -89,36 +91,35 @@ module MuchStub
|
|
89
91
|
metaclass.define_method(name, &block)
|
90
92
|
end
|
91
93
|
|
94
|
+
def respond_to_missing?(_name, *_args)
|
95
|
+
false
|
96
|
+
end
|
97
|
+
|
92
98
|
def method_missing(name, *args, &block)
|
93
99
|
if (match = name.match(/(\w+)(_calls)\z/))
|
94
100
|
call_spy_define_query_method(match) do |method_name|
|
95
101
|
@call_spy_method_calls[method_name]
|
96
102
|
end
|
97
|
-
self.__send__(name, *args, &block)
|
98
103
|
elsif (match = name.match(/(\w+)(_last_called_with)\z/))
|
99
104
|
call_spy_define_query_method(match) do |method_name|
|
100
|
-
|
105
|
+
__send__("#{method_name}_calls").last
|
101
106
|
end
|
102
|
-
self.__send__(name, *args, &block)
|
103
107
|
elsif (match = name.match(/(\w+)(_called_with)\z/))
|
104
108
|
call_spy_define_query_method(match) do |method_name|
|
105
|
-
|
109
|
+
__send__("#{method_name}_last_called_with")
|
106
110
|
end
|
107
|
-
self.__send__(name, *args, &block)
|
108
111
|
elsif (match = name.match(/(\w+)(_call_count)\z/))
|
109
112
|
call_spy_define_query_method(match) do |method_name|
|
110
|
-
|
113
|
+
__send__("#{method_name}_calls").size
|
111
114
|
end
|
112
|
-
self.__send__(name, *args, &block)
|
113
115
|
elsif (match = name.match(/(\w+)(_called\?)\z/))
|
114
116
|
call_spy_define_query_method(match) do |method_name|
|
115
|
-
|
117
|
+
__send__("#{method_name}_call_count") > 0
|
116
118
|
end
|
117
|
-
self.__send__(name, *args, &block)
|
118
119
|
else
|
119
120
|
call_spy_define_spied_method(name)
|
120
|
-
self.__send__(name, *args, &block)
|
121
121
|
end
|
122
|
+
__send__(name, *args, &block)
|
122
123
|
end
|
123
124
|
end
|
124
125
|
end
|
data/lib/much-stub/version.rb
CHANGED
data/lib/much-stub.rb
CHANGED
@@ -15,66 +15,70 @@ module MuchStub
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def self.arity_matches?(method, args)
|
18
|
-
|
19
|
-
return true if method.arity
|
20
|
-
|
18
|
+
# mandatory args
|
19
|
+
return true if method.arity == args.size
|
20
|
+
# variable args
|
21
|
+
return true if method.arity < 0 && args.size >= (method.arity + 1).abs
|
22
|
+
|
23
|
+
false
|
21
24
|
end
|
22
25
|
|
23
26
|
def self.stub(obj, meth, &block)
|
24
|
-
key =
|
25
|
-
|
26
|
-
|
27
|
+
key = stub_key(obj, meth)
|
28
|
+
stubs[key] ||= MuchStub::Stub.new(obj, meth, caller_locations)
|
29
|
+
stubs[key].tap{ |s| s.do = block }
|
27
30
|
end
|
28
31
|
|
29
32
|
def self.call(*args, &block)
|
30
|
-
|
33
|
+
stub(*args, &block)
|
31
34
|
end
|
32
35
|
|
33
36
|
def self.stub_on_call(*args, &on_call_block)
|
34
|
-
|
37
|
+
stub(*args).on_call(&on_call_block)
|
35
38
|
end
|
36
39
|
|
37
40
|
def self.on_call(*args, &on_call_block)
|
38
|
-
|
41
|
+
stub_on_call(*args, &on_call_block)
|
39
42
|
end
|
40
43
|
|
41
44
|
def self.unstub(obj, meth)
|
42
|
-
key =
|
43
|
-
(
|
45
|
+
key = stub_key(obj, meth)
|
46
|
+
(stubs.delete(key) || MuchStub::NullStub.new).teardown
|
44
47
|
end
|
45
48
|
|
46
49
|
def self.unstub!
|
47
|
-
|
50
|
+
stubs.keys.each{ |key| stubs.delete(key).teardown }
|
48
51
|
end
|
49
52
|
|
50
|
-
def self.stub_send(obj, meth, *
|
53
|
+
def self.stub_send(obj, meth, *pargs, **kargs, &block)
|
51
54
|
orig_caller = caller_locations
|
52
|
-
stub =
|
53
|
-
|
54
|
-
|
55
|
-
|
55
|
+
stub =
|
56
|
+
stubs.fetch(MuchStub::Stub.key(obj, meth)) do
|
57
|
+
raise NotStubbedError, "`#{meth}` not stubbed.", orig_caller.map(&:to_s)
|
58
|
+
end
|
59
|
+
stub.call_method(*pargs, **kargs, &block)
|
56
60
|
end
|
57
61
|
|
58
62
|
def self.tap(obj, meth, &tap_block)
|
59
|
-
|
60
|
-
|
61
|
-
tap_block
|
62
|
-
|
63
|
-
|
63
|
+
stub(obj, meth) do |*pargs, **kargs, &block|
|
64
|
+
stub_send(obj, meth, *pargs, **kargs, &block).tap do |value|
|
65
|
+
tap_block&.call(value, *pargs, **kargs, &block)
|
66
|
+
end
|
67
|
+
end
|
64
68
|
end
|
65
69
|
|
66
70
|
def self.tap_on_call(obj, meth, &on_call_block)
|
67
|
-
|
68
|
-
on_call_block
|
69
|
-
|
71
|
+
tap(obj, meth) do |value, *pargs, **kargs, &block|
|
72
|
+
on_call_block&.call(value, MuchStub::Call.new(*pargs, **kargs, &block))
|
73
|
+
end
|
70
74
|
end
|
71
75
|
|
72
76
|
def self.spy(obj, *meths, **return_values)
|
73
77
|
MuchStub::CallSpy.new(**return_values).call_spy_tap do |spy|
|
74
78
|
meths.each do |meth|
|
75
|
-
|
76
|
-
spy.__send__(meth, *
|
77
|
-
|
79
|
+
stub(obj, meth) do |*pargs, **kargs, &block|
|
80
|
+
spy.__send__(meth, *pargs, **kargs, &block)
|
81
|
+
end
|
78
82
|
end
|
79
83
|
end
|
80
84
|
end
|
@@ -104,35 +108,41 @@ module MuchStub
|
|
104
108
|
@do = block || @do
|
105
109
|
end
|
106
110
|
|
107
|
-
def call_method(
|
108
|
-
@method.call(*
|
111
|
+
def call_method(*pargs, **kargs, &block)
|
112
|
+
@method.call(*pargs, **kargs, &block)
|
109
113
|
end
|
110
114
|
|
111
|
-
def call(
|
115
|
+
def call(*pargs, orig_caller: nil, **kargs, &block)
|
112
116
|
orig_caller ||= caller_locations
|
117
|
+
args = combined_args(pargs, kargs)
|
113
118
|
unless MuchStub.arity_matches?(@method, args)
|
114
119
|
raise(
|
115
120
|
StubArityError.new(
|
116
121
|
@method,
|
117
122
|
args,
|
118
123
|
method_name: @method_name,
|
119
|
-
backtrace: orig_caller
|
124
|
+
backtrace: orig_caller,
|
125
|
+
),
|
126
|
+
)
|
120
127
|
end
|
121
|
-
lookup(
|
128
|
+
lookup(pargs, kargs, orig_caller).call(*pargs, **kargs, &block)
|
122
129
|
rescue NotStubbedError
|
123
130
|
@lookup.rehash
|
124
|
-
lookup(
|
131
|
+
lookup(pargs, kargs, orig_caller).call(*pargs, **kargs, &block)
|
125
132
|
end
|
126
133
|
|
127
|
-
def with(*
|
134
|
+
def with(*pargs, **kargs, &block)
|
128
135
|
orig_caller = caller_locations
|
136
|
+
args = combined_args(pargs, kargs)
|
129
137
|
unless MuchStub.arity_matches?(@method, args)
|
130
138
|
raise(
|
131
139
|
StubArityError.new(
|
132
140
|
@method,
|
133
141
|
args,
|
134
142
|
method_name: @method_name,
|
135
|
-
backtrace: orig_caller
|
143
|
+
backtrace: orig_caller,
|
144
|
+
),
|
145
|
+
)
|
136
146
|
end
|
137
147
|
@lookup[args] = block
|
138
148
|
self
|
@@ -140,12 +150,12 @@ module MuchStub
|
|
140
150
|
|
141
151
|
def on_call(&on_call_block)
|
142
152
|
stub_block =
|
143
|
-
->(*
|
144
|
-
on_call_block
|
153
|
+
->(*pargs, **kargs, &block){
|
154
|
+
on_call_block&.call(MuchStub::Call.new(*pargs, **kargs, &block))
|
145
155
|
}
|
146
156
|
if @lookup.empty?
|
147
157
|
@do = stub_block
|
148
|
-
elsif @lookup.
|
158
|
+
elsif @lookup.value?(nil)
|
149
159
|
@lookup.transform_values!{ |value| value.nil? ? stub_block : value }
|
150
160
|
end
|
151
161
|
self
|
@@ -159,7 +169,7 @@ module MuchStub
|
|
159
169
|
end
|
160
170
|
|
161
171
|
def inspect
|
162
|
-
"#<#{self.class}:#{"0x0%x"
|
172
|
+
"#<#{self.class}:#{format("0x0%x", (object_id << 1))}" \
|
163
173
|
" @method_name=#{@method_name.inspect}" \
|
164
174
|
">"
|
165
175
|
end
|
@@ -171,7 +181,7 @@ module MuchStub
|
|
171
181
|
msg = "#{object.inspect} does not respond to `#{@method_name}`"
|
172
182
|
raise StubError, msg, orig_caller.map(&:to_s)
|
173
183
|
end
|
174
|
-
is_constant = object.
|
184
|
+
is_constant = object.is_a?(Module)
|
175
185
|
local_object_methods = object.methods(false).map(&:to_s)
|
176
186
|
all_object_methods = object.methods.map(&:to_s)
|
177
187
|
if (is_constant && !local_object_methods.include?(@method_name)) ||
|
@@ -182,33 +192,39 @@ module MuchStub
|
|
182
192
|
method
|
183
193
|
end
|
184
194
|
|
185
|
-
|
195
|
+
# already stubbed
|
196
|
+
unless local_object_methods.include?(@name)
|
186
197
|
@metaclass.send(:alias_method, @name, @method_name)
|
187
198
|
end
|
188
199
|
@method = object.method(@name)
|
189
200
|
|
190
201
|
MuchStub.instance_variable_set(@ivar_name, self)
|
191
202
|
@metaclass.class_eval <<-stub_method
|
192
|
-
def #{@method_name}(*
|
193
|
-
MuchStub
|
203
|
+
def #{@method_name}(*pargs, **kargs, &block)
|
204
|
+
MuchStub
|
205
|
+
.instance_variable_get("#{@ivar_name}")
|
206
|
+
.call(*pargs, orig_caller: caller_locations, **kargs, &block)
|
194
207
|
end
|
195
208
|
stub_method
|
196
209
|
end
|
197
210
|
|
198
|
-
def lookup(
|
199
|
-
|
200
|
-
|
211
|
+
def lookup(pargs, kargs, orig_caller)
|
212
|
+
args = combined_args(pargs, kargs)
|
213
|
+
@lookup.fetch(args) do
|
214
|
+
self.do ||
|
215
|
+
begin
|
201
216
|
msg = "#{inspect_call(args)} not stubbed."
|
202
217
|
inspect_lookup_stubs.tap do |stubs|
|
203
|
-
msg += "\nStubs:\n#{stubs}"
|
218
|
+
msg += "\nStubs:\n#{stubs}" unless stubs.empty?
|
204
219
|
end
|
205
220
|
raise NotStubbedError, msg, orig_caller.map(&:to_s)
|
206
221
|
end
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
222
|
+
end ||
|
223
|
+
raise(
|
224
|
+
StubError,
|
225
|
+
"#{inspect_call(args)} stubbed with no block.",
|
226
|
+
orig_caller.map(&:to_s),
|
227
|
+
)
|
212
228
|
end
|
213
229
|
|
214
230
|
def inspect_lookup_stubs
|
@@ -218,6 +234,10 @@ module MuchStub
|
|
218
234
|
def inspect_call(args)
|
219
235
|
"`#{@method_name}(#{args.map(&:inspect).join(",")})`"
|
220
236
|
end
|
237
|
+
|
238
|
+
def combined_args(pargs, kargs)
|
239
|
+
pargs + [(kargs.empty? ? nil : kargs)].compact
|
240
|
+
end
|
221
241
|
end
|
222
242
|
|
223
243
|
StubError = Class.new(ArgumentError)
|
@@ -244,9 +264,12 @@ module MuchStub
|
|
244
264
|
end
|
245
265
|
end
|
246
266
|
|
247
|
-
NullStub =
|
248
|
-
|
249
|
-
|
267
|
+
NullStub =
|
268
|
+
Class.new do
|
269
|
+
def teardown
|
270
|
+
# no-op
|
271
|
+
end
|
272
|
+
end
|
250
273
|
|
251
274
|
module ParameterList
|
252
275
|
LETTERS = ("a".."z").to_a.freeze
|
@@ -254,13 +277,11 @@ module MuchStub
|
|
254
277
|
def self.new(object, method_name)
|
255
278
|
arity = get_arity(object, method_name)
|
256
279
|
params = build_params_from_arity(arity)
|
257
|
-
params << "*
|
280
|
+
params << "*pargs, **kargs" if arity < 0
|
258
281
|
params << "&block"
|
259
282
|
params.join(", ")
|
260
283
|
end
|
261
284
|
|
262
|
-
private
|
263
|
-
|
264
285
|
def self.get_arity(object, method_name)
|
265
286
|
object.method(method_name).arity
|
266
287
|
rescue NameError
|
data/much-stub.gemspec
CHANGED
@@ -1,24 +1,32 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
2
4
|
lib = File.expand_path("../lib", __FILE__)
|
3
5
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
6
|
require "much-stub/version"
|
5
7
|
|
6
8
|
Gem::Specification.new do |gem|
|
7
|
-
gem.name
|
8
|
-
gem.version
|
9
|
-
gem.authors
|
10
|
-
gem.email
|
11
|
-
|
12
|
-
gem.
|
13
|
-
|
14
|
-
gem.
|
15
|
-
|
16
|
-
|
9
|
+
gem.name = "much-stub"
|
10
|
+
gem.version = MuchStub::VERSION
|
11
|
+
gem.authors = ["Kelly Redding", "Collin Redding"]
|
12
|
+
gem.email = ["kelly@kellyredding.com", "collin.redding@me.com"]
|
13
|
+
|
14
|
+
gem.summary =
|
15
|
+
"Stubbing API for replacing method calls on objects in test runs."
|
16
|
+
gem.description =
|
17
|
+
"Stubbing API for replacing method calls on objects in test runs."
|
18
|
+
|
19
|
+
gem.homepage = "https://github.com/redding/much-stub"
|
20
|
+
gem.license = "MIT"
|
21
|
+
|
22
|
+
gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
23
|
+
|
17
24
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
18
25
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
19
26
|
gem.require_paths = ["lib"]
|
20
27
|
|
21
|
-
gem.required_ruby_version = "
|
28
|
+
gem.required_ruby_version = ">= 2.5"
|
22
29
|
|
23
|
-
gem.add_development_dependency("assert",
|
30
|
+
gem.add_development_dependency("assert", ["~> 2.19.7"])
|
31
|
+
gem.add_development_dependency("much-style-guide", ["~> 0.6.7"])
|
24
32
|
end
|
data/test/helper.rb
CHANGED
@@ -14,7 +14,7 @@ require "test/support/factory"
|
|
14
14
|
# 1.8.7 backfills
|
15
15
|
|
16
16
|
# Array#sample
|
17
|
-
if !(a =
|
17
|
+
if !(a = []).respond_to?(:sample) && a.respond_to?(:choice)
|
18
18
|
class Array
|
19
19
|
alias_method :sample, :choice
|
20
20
|
end
|