much-stub 0.1.6 → 0.1.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a6dc9e4397c7c270a2678eac9f4761adb80bdd842e6708417844855639c6acfa
4
- data.tar.gz: 57f89b55ddaf3b17a2444f7bbd40d2e8f9b1ad3046d1634021412f8847df605b
3
+ metadata.gz: 15204360d9518246e4abaa703670f75489b26364a262f61397956bcd6292bb91
4
+ data.tar.gz: e53db7a648e52be63ea31d6dc930d7c009e65604d05a4e1e447edcfb3ef7b296
5
5
  SHA512:
6
- metadata.gz: b57f84be1092bba24dfd51ace398e8116941a16e17f8698436158309305672e55076b46bb4b5695763c97530f7cbfce6f974de6b331432336d7b0aad8a2ecfe0
7
- data.tar.gz: 4705afaee215d93ed0a998949dd70dd2d13f03aa5fac9a31093940be16799ad43b2878df7870a046b79a1a4e2c9625bb0f5195896c371c24728600445c18c55a
6
+ metadata.gz: 5892e22dc64f46400a115d42fb7b7da3d5b82387fda5b8c2ec5f807d6a9b47e4dca5a92d86a3a97898d5f6e85885808065d591e53aba7d78303afc1396fce4a4
7
+ data.tar.gz: 4476a777e7ee869f59080f5c0bc40d2d8736d77d01588f193ea6e826f424d3abf110ca49a60437267e7e16d5578c2f6f74bb24ce810940af82154ce0e08e7199
data/.l.yml ADDED
@@ -0,0 +1,8 @@
1
+ # https://github.com/redding/l.rb
2
+
3
+ linters:
4
+ - name: "Rubocop"
5
+ cmd: "bundle exec rubocop"
6
+ extensions:
7
+ - ".rb"
8
+ cli_abbrev: "u"
@@ -0,0 +1,3 @@
1
+ inherit_gem:
2
+ much-style-guide:
3
+ - "lib/much-style-guide/rubocop.yml"
@@ -0,0 +1 @@
1
+ 2.5.8
data/.t.yml ADDED
@@ -0,0 +1,6 @@
1
+ # https://github.com/redding/t.rb
2
+
3
+ default_cmd: bundle exec assert
4
+ test_dir: test
5
+ test_file_suffixes:
6
+ - "_tests.rb"
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source "https://rubygems.org"
2
4
 
3
5
  ruby "~> 2.5"
@@ -15,66 +15,69 @@ module MuchStub
15
15
  end
16
16
 
17
17
  def self.arity_matches?(method, args)
18
- return true if method.arity == args.size # mandatory args
19
- return true if method.arity < 0 && args.size >= (method.arity+1).abs # variable args
20
- return false
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 = self.stub_key(obj, meth)
25
- self.stubs[key] ||= MuchStub::Stub.new(obj, meth, caller_locations)
26
- self.stubs[key].tap{ |s| s.do = block }
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
- self.stub(*args, &block)
33
+ stub(*args, &block)
31
34
  end
32
35
 
33
36
  def self.stub_on_call(*args, &on_call_block)
34
- self.stub(*args).on_call(&on_call_block)
37
+ stub(*args).on_call(&on_call_block)
35
38
  end
36
39
 
37
40
  def self.on_call(*args, &on_call_block)
38
- self.stub_on_call(*args, &on_call_block)
41
+ stub_on_call(*args, &on_call_block)
39
42
  end
40
43
 
41
44
  def self.unstub(obj, meth)
42
- key = self.stub_key(obj, meth)
43
- (self.stubs.delete(key) || MuchStub::NullStub.new).teardown
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
- self.stubs.keys.each{ |key| self.stubs.delete(key).teardown }
50
+ stubs.keys.each{ |key| stubs.delete(key).teardown }
48
51
  end
49
52
 
50
53
  def self.stub_send(obj, meth, *args, &block)
51
54
  orig_caller = caller_locations
52
- stub = self.stubs.fetch(MuchStub::Stub.key(obj, meth)) do
55
+ stub = stubs.fetch(MuchStub::Stub.key(obj, meth)) do
53
56
  raise NotStubbedError, "`#{meth}` not stubbed.", orig_caller.map(&:to_s)
54
57
  end
55
58
  stub.call_method(args, &block)
56
59
  end
57
60
 
58
61
  def self.tap(obj, meth, &tap_block)
59
- self.stub(obj, meth) { |*args, &block|
60
- self.stub_send(obj, meth, *args, &block).tap { |value|
61
- tap_block.call(value, *args, &block) if tap_block
62
- }
63
- }
62
+ stub(obj, meth) do |*args, &block|
63
+ stub_send(obj, meth, *args, &block).tap do |value|
64
+ tap_block&.call(value, *args, &block)
65
+ end
66
+ end
64
67
  end
65
68
 
66
69
  def self.tap_on_call(obj, meth, &on_call_block)
67
- self.tap(obj, meth) { |value, *args, &block|
68
- on_call_block.call(value, MuchStub::Call.new(*args, &block)) if on_call_block
69
- }
70
+ tap(obj, meth) do |value, *args, &block|
71
+ on_call_block&.call(value, MuchStub::Call.new(*args, &block))
72
+ end
70
73
  end
71
74
 
72
75
  def self.spy(obj, *meths, **return_values)
73
76
  MuchStub::CallSpy.new(**return_values).call_spy_tap do |spy|
74
77
  meths.each do |meth|
75
- self.stub(obj, meth) { |*args, &block|
78
+ stub(obj, meth) do |*args, &block|
76
79
  spy.__send__(meth, *args, &block)
77
- }
80
+ end
78
81
  end
79
82
  end
80
83
  end
@@ -116,7 +119,9 @@ module MuchStub
116
119
  @method,
117
120
  args,
118
121
  method_name: @method_name,
119
- backtrace: orig_caller))
122
+ backtrace: orig_caller,
123
+ ),
124
+ )
120
125
  end
121
126
  lookup(args, orig_caller).call(*args, &block)
122
127
  rescue NotStubbedError
@@ -132,7 +137,9 @@ module MuchStub
132
137
  @method,
133
138
  args,
134
139
  method_name: @method_name,
135
- backtrace: orig_caller))
140
+ backtrace: orig_caller,
141
+ ),
142
+ )
136
143
  end
137
144
  @lookup[args] = block
138
145
  self
@@ -140,12 +147,12 @@ module MuchStub
140
147
 
141
148
  def on_call(&on_call_block)
142
149
  stub_block =
143
- ->(*args, &block) {
144
- on_call_block.call(MuchStub::Call.new(*args, &block)) if on_call_block
150
+ ->(*args, &block){
151
+ on_call_block&.call(MuchStub::Call.new(*args, &block))
145
152
  }
146
153
  if @lookup.empty?
147
154
  @do = stub_block
148
- elsif @lookup.has_value?(nil)
155
+ elsif @lookup.value?(nil)
149
156
  @lookup.transform_values!{ |value| value.nil? ? stub_block : value }
150
157
  end
151
158
  self
@@ -159,7 +166,7 @@ module MuchStub
159
166
  end
160
167
 
161
168
  def inspect
162
- "#<#{self.class}:#{"0x0%x" % (object_id << 1)}" \
169
+ "#<#{self.class}:#{format("0x0%x", (object_id << 1))}" \
163
170
  " @method_name=#{@method_name.inspect}" \
164
171
  ">"
165
172
  end
@@ -171,7 +178,7 @@ module MuchStub
171
178
  msg = "#{object.inspect} does not respond to `#{@method_name}`"
172
179
  raise StubError, msg, orig_caller.map(&:to_s)
173
180
  end
174
- is_constant = object.kind_of?(Module)
181
+ is_constant = object.is_a?(Module)
175
182
  local_object_methods = object.methods(false).map(&:to_s)
176
183
  all_object_methods = object.methods.map(&:to_s)
177
184
  if (is_constant && !local_object_methods.include?(@method_name)) ||
@@ -182,7 +189,8 @@ module MuchStub
182
189
  method
183
190
  end
184
191
 
185
- if !local_object_methods.include?(@name) # already stubbed
192
+ # already stubbed
193
+ unless local_object_methods.include?(@name)
186
194
  @metaclass.send(:alias_method, @name, @method_name)
187
195
  end
188
196
  @method = object.method(@name)
@@ -196,19 +204,21 @@ module MuchStub
196
204
  end
197
205
 
198
206
  def lookup(args, orig_caller)
199
- @lookup.fetch(args) {
200
- self.do || begin
207
+ @lookup.fetch(args) do
208
+ self.do ||
209
+ begin
201
210
  msg = "#{inspect_call(args)} not stubbed."
202
211
  inspect_lookup_stubs.tap do |stubs|
203
- msg += "\nStubs:\n#{stubs}" if !stubs.empty?
212
+ msg += "\nStubs:\n#{stubs}" unless stubs.empty?
204
213
  end
205
214
  raise NotStubbedError, msg, orig_caller.map(&:to_s)
206
215
  end
207
- } ||
208
- raise(
209
- StubError,
210
- "#{inspect_call(args)} stubbed with no block.",
211
- orig_caller.map(&:to_s))
216
+ end ||
217
+ raise(
218
+ StubError,
219
+ "#{inspect_call(args)} stubbed with no block.",
220
+ orig_caller.map(&:to_s),
221
+ )
212
222
  end
213
223
 
214
224
  def inspect_lookup_stubs
@@ -244,9 +254,12 @@ module MuchStub
244
254
  end
245
255
  end
246
256
 
247
- NullStub = Class.new do
248
- def teardown; end # no-op
249
- end
257
+ NullStub =
258
+ Class.new do
259
+ def teardown
260
+ # no-op
261
+ end
262
+ end
250
263
 
251
264
  module ParameterList
252
265
  LETTERS = ("a".."z").to_a.freeze
@@ -259,8 +272,6 @@ module MuchStub
259
272
  params.join(", ")
260
273
  end
261
274
 
262
- private
263
-
264
275
  def self.get_arity(object, method_name)
265
276
  object.method(method_name).arity
266
277
  rescue NameError
@@ -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{ |key| key.to_s }
14
- @call_spy_method_calls = ::Hash.new { |hash, key| hash[key] = [] }
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 { |hash, key| hash[key] = call_spy_return_value_proc(key) }
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
- self.equal?(other)
25
+ equal?(other)
26
26
  end
27
27
 
28
28
  def ===(other)
29
- self.equal?(other)
29
+ equal?(other)
30
30
  end
31
31
 
32
32
  def eql?(other)
33
- self.equal?(other)
33
+ equal?(other)
34
34
  end
35
35
 
36
36
  def equal?(other)
37
- self.__id__ == other.__id__
37
+ __id__ == other.__id__
38
38
  end
39
39
 
40
40
  def hash
41
- self.__id__
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" % (self.__id__ << 1)}>"
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 { self })
60
- value.respond_to?(:call) ? value : ::Proc.new { value }
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) { |acc, (source, replacement)|
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("#{method_name}#{query_method_suffix}") do
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
- self.__send__("#{method_name}_calls").last
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
- self.__send__("#{method_name}_last_called_with")
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
- self.__send__("#{method_name}_calls").size
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
- self.__send__("#{method_name}_call_count") > 0
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MuchStub
4
- VERSION = "0.1.6"
4
+ VERSION = "0.1.7"
5
5
  end
@@ -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 = "much-stub"
8
- gem.version = MuchStub::VERSION
9
- gem.authors = ["Kelly Redding", "Collin Redding"]
10
- gem.email = ["kelly@kellyredding.com", "collin.redding@me.com"]
11
- gem.summary = "Stubbing API for replacing method calls on objects in test runs."
12
- gem.description = "Stubbing API for replacing method calls on objects in test runs."
13
- gem.homepage = "https://github.com/redding/much-stub"
14
- gem.license = "MIT"
15
-
16
- gem.files = `git ls-files`.split($/)
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
28
  gem.required_ruby_version = "~> 2.5"
22
29
 
23
- gem.add_development_dependency("assert", ["~> 2.19.0"])
30
+ gem.add_development_dependency("assert", ["~> 2.19.2"])
31
+ gem.add_development_dependency("much-style-guide", ["~> 0.6.0"])
24
32
  end
@@ -14,7 +14,7 @@ require "test/support/factory"
14
14
  # 1.8.7 backfills
15
15
 
16
16
  # Array#sample
17
- if !(a = Array.new).respond_to?(:sample) && a.respond_to?(:choice)
17
+ if !(a = []).respond_to?(:sample) && a.respond_to?(:choice)
18
18
  class Array
19
19
  alias_method :sample, :choice
20
20
  end
@@ -57,15 +57,15 @@ module MuchStub
57
57
  end
58
58
 
59
59
  should "not allow stubbing methods with invalid arity" do
60
- assert_raises{ MuchStub.stub(subject, :noargs).with(1){ } }
60
+ assert_raises{ MuchStub.stub(subject, :noargs).with(1){} }
61
61
 
62
- assert_raises{ MuchStub.stub(subject, :withargs).with{ } }
63
- assert_raises{ MuchStub.stub(subject, :withargs).with(1, 2){ } }
62
+ assert_raises{ MuchStub.stub(subject, :withargs).with{} }
63
+ assert_raises{ MuchStub.stub(subject, :withargs).with(1, 2){} }
64
64
 
65
- assert_raises{ MuchStub.stub(subject, :minargs).with{ } }
66
- assert_raises{ MuchStub.stub(subject, :minargs).with(1){ } }
65
+ assert_raises{ MuchStub.stub(subject, :minargs).with{} }
66
+ assert_raises{ MuchStub.stub(subject, :minargs).with(1){} }
67
67
 
68
- assert_raises{ MuchStub.stub(subject, :withblock).with(1){ } }
68
+ assert_raises{ MuchStub.stub(subject, :withblock).with(1){} }
69
69
  end
70
70
 
71
71
  should "not allow calling methods with invalid arity" do
@@ -130,15 +130,15 @@ module MuchStub
130
130
  end
131
131
 
132
132
  should "not allow stubbing methods with invalid arity" do
133
- assert_raises{ MuchStub.stub(subject, :noargs).with(1){ } }
133
+ assert_raises{ MuchStub.stub(subject, :noargs).with(1){} }
134
134
 
135
- assert_raises{ MuchStub.stub(subject, :withargs).with{ } }
136
- assert_raises{ MuchStub.stub(subject, :withargs).with(1, 2){ } }
135
+ assert_raises{ MuchStub.stub(subject, :withargs).with{} }
136
+ assert_raises{ MuchStub.stub(subject, :withargs).with(1, 2){} }
137
137
 
138
- assert_raises{ MuchStub.stub(subject, :minargs).with{ } }
139
- assert_raises{ MuchStub.stub(subject, :minargs).with(1){ } }
138
+ assert_raises{ MuchStub.stub(subject, :minargs).with{} }
139
+ assert_raises{ MuchStub.stub(subject, :minargs).with(1){} }
140
140
 
141
- assert_raises{ MuchStub.stub(subject, :withblock).with(1){ } }
141
+ assert_raises{ MuchStub.stub(subject, :withblock).with(1){} }
142
142
  end
143
143
 
144
144
  should "not allow calling methods with invalid arity" do
@@ -203,15 +203,15 @@ module MuchStub
203
203
  end
204
204
 
205
205
  should "not allow stubbing methods with invalid arity" do
206
- assert_raises{ MuchStub.stub(subject, :noargs).with(1){ } }
206
+ assert_raises{ MuchStub.stub(subject, :noargs).with(1){} }
207
207
 
208
- assert_raises{ MuchStub.stub(subject, :withargs).with{ } }
209
- assert_raises{ MuchStub.stub(subject, :withargs).with(1, 2){ } }
208
+ assert_raises{ MuchStub.stub(subject, :withargs).with{} }
209
+ assert_raises{ MuchStub.stub(subject, :withargs).with(1, 2){} }
210
210
 
211
- assert_raises{ MuchStub.stub(subject, :minargs).with{ } }
212
- assert_raises{ MuchStub.stub(subject, :minargs).with(1){ } }
211
+ assert_raises{ MuchStub.stub(subject, :minargs).with{} }
212
+ assert_raises{ MuchStub.stub(subject, :minargs).with(1){} }
213
213
 
214
- assert_raises{ MuchStub.stub(subject, :withblock).with(1){ } }
214
+ assert_raises{ MuchStub.stub(subject, :withblock).with(1){} }
215
215
  end
216
216
 
217
217
  should "not allow calling methods with invalid arity" do
@@ -276,15 +276,15 @@ module MuchStub
276
276
  end
277
277
 
278
278
  should "not allow stubbing methods with invalid arity" do
279
- assert_raises{ MuchStub.stub(subject, :noargs).with(1){ } }
279
+ assert_raises{ MuchStub.stub(subject, :noargs).with(1){} }
280
280
 
281
- assert_raises{ MuchStub.stub(subject, :withargs).with{ } }
282
- assert_raises{ MuchStub.stub(subject, :withargs).with(1, 2){ } }
281
+ assert_raises{ MuchStub.stub(subject, :withargs).with{} }
282
+ assert_raises{ MuchStub.stub(subject, :withargs).with(1, 2){} }
283
283
 
284
- assert_raises{ MuchStub.stub(subject, :minargs).with{ } }
285
- assert_raises{ MuchStub.stub(subject, :minargs).with(1){ } }
284
+ assert_raises{ MuchStub.stub(subject, :minargs).with{} }
285
+ assert_raises{ MuchStub.stub(subject, :minargs).with(1){} }
286
286
 
287
- assert_raises{ MuchStub.stub(subject, :withblock).with(1){ } }
287
+ assert_raises{ MuchStub.stub(subject, :withblock).with(1){} }
288
288
  end
289
289
 
290
290
  should "not allow calling methods with invalid arity" do
@@ -350,15 +350,15 @@ module MuchStub
350
350
  end
351
351
 
352
352
  should "not allow stubbing methods with invalid arity" do
353
- assert_raises{ MuchStub.stub(subject, :noargs).with(1){ } }
353
+ assert_raises{ MuchStub.stub(subject, :noargs).with(1){} }
354
354
 
355
- assert_raises{ MuchStub.stub(subject, :withargs).with{ } }
356
- assert_raises{ MuchStub.stub(subject, :withargs).with(1, 2){ } }
355
+ assert_raises{ MuchStub.stub(subject, :withargs).with{} }
356
+ assert_raises{ MuchStub.stub(subject, :withargs).with(1, 2){} }
357
357
 
358
- assert_raises{ MuchStub.stub(subject, :minargs).with{ } }
359
- assert_raises{ MuchStub.stub(subject, :minargs).with(1){ } }
358
+ assert_raises{ MuchStub.stub(subject, :minargs).with{} }
359
+ assert_raises{ MuchStub.stub(subject, :minargs).with(1){} }
360
360
 
361
- assert_raises{ MuchStub.stub(subject, :withblock).with(1){ } }
361
+ assert_raises{ MuchStub.stub(subject, :withblock).with(1){} }
362
362
  end
363
363
 
364
364
  should "not allow calling methods with invalid arity" do
@@ -423,15 +423,15 @@ module MuchStub
423
423
  end
424
424
 
425
425
  should "not allow stubbing methods with invalid arity" do
426
- assert_raises{ MuchStub.stub(subject, :noargs).with(1){ } }
426
+ assert_raises{ MuchStub.stub(subject, :noargs).with(1){} }
427
427
 
428
- assert_raises{ MuchStub.stub(subject, :withargs).with{ } }
429
- assert_raises{ MuchStub.stub(subject, :withargs).with(1, 2){ } }
428
+ assert_raises{ MuchStub.stub(subject, :withargs).with{} }
429
+ assert_raises{ MuchStub.stub(subject, :withargs).with(1, 2){} }
430
430
 
431
- assert_raises{ MuchStub.stub(subject, :minargs).with{ } }
432
- assert_raises{ MuchStub.stub(subject, :minargs).with(1){ } }
431
+ assert_raises{ MuchStub.stub(subject, :minargs).with{} }
432
+ assert_raises{ MuchStub.stub(subject, :minargs).with(1){} }
433
433
 
434
- assert_raises{ MuchStub.stub(subject, :withblock).with(1){ } }
434
+ assert_raises{ MuchStub.stub(subject, :withblock).with(1){} }
435
435
  end
436
436
 
437
437
  should "not allow calling methods with invalid arity" do
@@ -497,15 +497,15 @@ module MuchStub
497
497
  end
498
498
 
499
499
  should "not allow stubbing methods with invalid arity" do
500
- assert_raises{ MuchStub.stub(subject, :noargs).with(1){ } }
500
+ assert_raises{ MuchStub.stub(subject, :noargs).with(1){} }
501
501
 
502
- assert_raises{ MuchStub.stub(subject, :withargs).with{ } }
503
- assert_raises{ MuchStub.stub(subject, :withargs).with(1, 2){ } }
502
+ assert_raises{ MuchStub.stub(subject, :withargs).with{} }
503
+ assert_raises{ MuchStub.stub(subject, :withargs).with(1, 2){} }
504
504
 
505
- assert_raises{ MuchStub.stub(subject, :minargs).with{ } }
506
- assert_raises{ MuchStub.stub(subject, :minargs).with(1){ } }
505
+ assert_raises{ MuchStub.stub(subject, :minargs).with{} }
506
+ assert_raises{ MuchStub.stub(subject, :minargs).with(1){} }
507
507
 
508
- assert_raises{ MuchStub.stub(subject, :withblock).with(1){ } }
508
+ assert_raises{ MuchStub.stub(subject, :withblock).with(1){} }
509
509
  end
510
510
 
511
511
  should "not allow calling methods with invalid arity" do
@@ -570,15 +570,15 @@ module MuchStub
570
570
  end
571
571
 
572
572
  should "allow stubbing methods with invalid arity" do
573
- assert_nothing_raised{ MuchStub.stub(subject, :noargs).with(1){ } }
573
+ assert_nothing_raised{ MuchStub.stub(subject, :noargs).with(1){} }
574
574
 
575
- assert_nothing_raised{ MuchStub.stub(subject, :withargs).with{ } }
576
- assert_nothing_raised{ MuchStub.stub(subject, :withargs).with(1, 2){ } }
575
+ assert_nothing_raised{ MuchStub.stub(subject, :withargs).with{} }
576
+ assert_nothing_raised{ MuchStub.stub(subject, :withargs).with(1, 2){} }
577
577
 
578
- assert_nothing_raised{ MuchStub.stub(subject, :minargs).with{ } }
579
- assert_nothing_raised{ MuchStub.stub(subject, :minargs).with(1){ } }
578
+ assert_nothing_raised{ MuchStub.stub(subject, :minargs).with{} }
579
+ assert_nothing_raised{ MuchStub.stub(subject, :minargs).with(1){} }
580
580
 
581
- assert_nothing_raised{ MuchStub.stub(subject, :withblock).with(1){ } }
581
+ assert_nothing_raised{ MuchStub.stub(subject, :withblock).with(1){} }
582
582
  end
583
583
 
584
584
  should "allow calling methods with invalid arity" do
@@ -643,15 +643,15 @@ module MuchStub
643
643
  end
644
644
 
645
645
  should "allow stubbing methods with invalid arity" do
646
- assert_nothing_raised{ MuchStub.stub(subject, :noargs).with(1){ } }
646
+ assert_nothing_raised{ MuchStub.stub(subject, :noargs).with(1){} }
647
647
 
648
- assert_nothing_raised{ MuchStub.stub(subject, :withargs).with{ } }
649
- assert_nothing_raised{ MuchStub.stub(subject, :withargs).with(1, 2){ } }
648
+ assert_nothing_raised{ MuchStub.stub(subject, :withargs).with{} }
649
+ assert_nothing_raised{ MuchStub.stub(subject, :withargs).with(1, 2){} }
650
650
 
651
- assert_nothing_raised{ MuchStub.stub(subject, :minargs).with{ } }
652
- assert_nothing_raised{ MuchStub.stub(subject, :minargs).with(1){ } }
651
+ assert_nothing_raised{ MuchStub.stub(subject, :minargs).with{} }
652
+ assert_nothing_raised{ MuchStub.stub(subject, :minargs).with(1){} }
653
653
 
654
- assert_nothing_raised{ MuchStub.stub(subject, :withblock).with(1){ } }
654
+ assert_nothing_raised{ MuchStub.stub(subject, :withblock).with(1){} }
655
655
  end
656
656
 
657
657
  should "allow calling methods with invalid arity" do
@@ -684,37 +684,73 @@ module MuchStub
684
684
  end
685
685
 
686
686
  class TestClass
687
- def self.noargs; end
688
- def self.withargs(a); end
689
- def self.anyargs(*args); end
690
- def self.minargs(a, b, *args); end
691
- def self.withblock(&block); end
692
-
693
- def noargs; end
694
- def withargs(a); end
695
- def anyargs(*args); end
696
- def minargs(a, b, *args); end
697
- def withblock(&block); end
687
+ def self.noargs
688
+ end
689
+
690
+ def self.withargs(a)
691
+ end
692
+
693
+ def self.anyargs(*args)
694
+ end
695
+
696
+ def self.minargs(a, b, *args)
697
+ end
698
+
699
+ def self.withblock(&block)
700
+ end
701
+
702
+ def noargs
703
+ end
704
+
705
+ def withargs(a)
706
+ end
707
+
708
+ def anyargs(*args)
709
+ end
710
+
711
+ def minargs(a, b, *args)
712
+ end
713
+
714
+ def withblock(&block)
715
+ end
698
716
  end
699
717
 
700
718
  module TestModule
701
- def self.noargs; end
702
- def self.withargs(a); end
703
- def self.anyargs(*args); end
704
- def self.minargs(a, b, *args); end
705
- def self.withblock(&block); end
719
+ def self.noargs
720
+ end
721
+
722
+ def self.withargs(a)
723
+ end
724
+
725
+ def self.anyargs(*args)
726
+ end
727
+
728
+ def self.minargs(a, b, *args)
729
+ end
730
+
731
+ def self.withblock(&block)
732
+ end
706
733
  end
707
734
 
708
735
  module TestMixin
709
- def noargs; end
710
- def withargs(a); end
711
- def anyargs(*args); end
712
- def minargs(a, b, *args); end
713
- def withblock(&block); end
736
+ def noargs
737
+ end
738
+
739
+ def withargs(a)
740
+ end
741
+
742
+ def anyargs(*args)
743
+ end
744
+
745
+ def minargs(a, b, *args)
746
+ end
747
+
748
+ def withblock(&block)
749
+ end
714
750
  end
715
751
 
716
752
  class DelegateClass
717
- def self.respond_to?(*args)
753
+ def self.respond_to_missing?(*args)
718
754
  TestClass.respond_to?(*args) || super
719
755
  end
720
756
 
@@ -726,7 +762,7 @@ module MuchStub
726
762
  @delegate = TestClass.new
727
763
  end
728
764
 
729
- def respond_to?(*args)
765
+ def respond_to_missing?(*args)
730
766
  @delegate.respond_to?(*args) || super
731
767
  end
732
768