bubot 0.0.3 → 0.0.4

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: 02e14c092d6111ff2a7438dd5372f5ef16c3f620
4
- data.tar.gz: d580e4a8efa9a8f0bf103d4b5b54ac68a05f0eca
3
+ metadata.gz: 2792c17eeb56bb85d6a9ffc698ea25c1acb172c9
4
+ data.tar.gz: dce40cadc2776cc88e1907ff8a820e9a1ef2e18a
5
5
  SHA512:
6
- metadata.gz: e335fb6754b0dc81609b965917b36745fb65139929dcc463717d594121192f7a95d03501f993287b3a11def5dad805b01a44522119f2d352d931b24847c4d97e
7
- data.tar.gz: d8d808b606983dc9b3d81b8fd259fcb4a4990a6ab317614db65e64ba3800d9e47f7561b3a5de7504ce666c96cfd33d6ea630a008a093146bb44d1a9e2d69d15e
6
+ metadata.gz: a1db04150dfc77b525944a7d7beb2fa07bf0f398faa31a1de58706d77ed91b0a10574b09f2b2bcba06598cda6d5e3d00b3e8ba1ab484e744333681cdf1ee21fb
7
+ data.tar.gz: 9cdb05235e2e6350b873f159150f2301a17f0befae3187a5697cf56b23beb4e44bbca2c5466be95b0a8c49809c970eba6d203660b1c3f46fb1615347c3905565
@@ -5,11 +5,11 @@ module Bubot
5
5
  def watch(method_name, timeout=0)
6
6
  define_method("#{method_name}_with_feature") do
7
7
  start_time = Time.now
8
- response = send("#{method_name}_without_feature".to_sym)
8
+ method_return_value = send("#{method_name}_without_feature".to_sym)
9
9
  if (total_time = Time.now - start_time) > timeout
10
- yield(self, total_time)
10
+ yield(self, total_time, method_return_value)
11
11
  end
12
- response
12
+ method_return_value
13
13
  end
14
14
 
15
15
  alias_method_chain_or_register(method_name)
@@ -1,3 +1,3 @@
1
1
  module Bubot
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -129,6 +129,34 @@ describe Bubot do
129
129
 
130
130
  bubot_observed.pass_time
131
131
  end
132
+
133
+ it "passes the returned value form the watched method" do
134
+ class RecievesReturnValueStrategy
135
+ def self.execute(instance, time, original_value)
136
+ # do stuff
137
+ end
138
+ end
139
+
140
+ class PassesReturnValue
141
+ extend Bubot
142
+ watch(:pass_return_value, 0.001) do |instance, time, return_value|
143
+ RecievesReturnValueStrategy.execute(instance, time, return_value)
144
+ end
145
+ def pass_return_value
146
+ sleep 0.002
147
+ "return_value"
148
+ end
149
+ end
150
+
151
+ bubot_observed = PassesReturnValue.new
152
+ RecievesReturnValueStrategy.should_receive(:execute) do |instance, time, return_value|
153
+ expect(time).to be > 0.002
154
+ expect(instance).to be(bubot_observed)
155
+ expect(return_value).to eq("return_value")
156
+ end
157
+
158
+ bubot_observed.pass_return_value
159
+ end
132
160
  end
133
161
  end
134
162
  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.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Micah Cooper
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-22 00:00:00.000000000 Z
12
+ date: 2013-08-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler