bubot 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2792c17eeb56bb85d6a9ffc698ea25c1acb172c9
4
- data.tar.gz: dce40cadc2776cc88e1907ff8a820e9a1ef2e18a
3
+ metadata.gz: 2f70e8e24f5d875d8de41a2aa457fcbfeb374ee7
4
+ data.tar.gz: 34202112c92a9b3925f6e23db6b5f5dd05db2c22
5
5
  SHA512:
6
- metadata.gz: a1db04150dfc77b525944a7d7beb2fa07bf0f398faa31a1de58706d77ed91b0a10574b09f2b2bcba06598cda6d5e3d00b3e8ba1ab484e744333681cdf1ee21fb
7
- data.tar.gz: 9cdb05235e2e6350b873f159150f2301a17f0befae3187a5697cf56b23beb4e44bbca2c5466be95b0a8c49809c970eba6d203660b1c3f46fb1615347c3905565
6
+ metadata.gz: 522a9bbb8a21ac58ac88bb531780f08fca92cb5655d444125b522d2c97aa6cb98dc4221c768cde481cf21042fa3aaf698c400cbf42895a1c53d8e8b875d541d4
7
+ data.tar.gz: a51b03f8ecd290aa917717b70595ac7d260bd62b48f523485fad3f45c03753d7e77f1801346fd1c8803b3380c748ccf0c980fd36cb3db2d7d4755f1210035ffa
data/lib/bubot.rb CHANGED
@@ -3,9 +3,13 @@ require "bubot/version"
3
3
  module Bubot
4
4
 
5
5
  def watch(method_name, timeout=0)
6
- define_method("#{method_name}_with_feature") do
6
+ define_method("#{method_name}_with_feature") do |*args, &block|
7
7
  start_time = Time.now
8
- method_return_value = send("#{method_name}_without_feature".to_sym)
8
+ if block
9
+ method_return_value = send("#{method_name}_without_feature".to_sym, *args, &block)
10
+ else
11
+ method_return_value = send("#{method_name}_without_feature".to_sym, *args)
12
+ end
9
13
  if (total_time = Time.now - start_time) > timeout
10
14
  yield(self, total_time, method_return_value)
11
15
  end
data/lib/bubot/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Bubot
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
data/spec/bubot_spec.rb CHANGED
@@ -158,5 +158,68 @@ describe Bubot do
158
158
  bubot_observed.pass_return_value
159
159
  end
160
160
  end
161
+
162
+ describe "the original method" do
163
+ it "redefines the method to return the original value" do
164
+ class OriginalMethod
165
+ extend Bubot
166
+
167
+ watch :original do
168
+ #something
169
+ end
170
+
171
+ def original
172
+ "original value"
173
+ end
174
+ end
175
+
176
+ original_class = OriginalMethod.new
177
+ expect(original_class.original).to eql("original value")
178
+
179
+ end
180
+
181
+ it "accepts the original methods arguments" do
182
+ class OriginalArguments
183
+ extend Bubot
184
+
185
+ watch :arguments do
186
+ #something
187
+ end
188
+
189
+ def arguments(foo, bar)
190
+ # do something
191
+ end
192
+ end
193
+
194
+ original_class = OriginalArguments.new
195
+ expect(original_class).to receive(:arguments_without_feature).with("foo", "bar")
196
+ original_class.arguments('foo', 'bar')
197
+
198
+ end
199
+
200
+ it "accepts the original methods block" do
201
+ class OriginalBlock
202
+ extend Bubot
203
+
204
+ watch :with_block do
205
+ #something
206
+ end
207
+
208
+ def with_block
209
+ yield(true)
210
+ end
211
+ end
212
+
213
+ original_class = OriginalBlock.new
214
+ block_called = false
215
+
216
+ original_class.with_block do |value|
217
+ block_called = value
218
+ end
219
+
220
+ expect(block_called).to be_true
221
+
222
+ end
223
+ end
161
224
  end
162
225
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bubot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Micah Cooper