bubot 0.0.1 → 0.0.2
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/lib/bubot.rb +2 -2
- data/lib/bubot/version.rb +1 -1
- data/spec/bubot_spec.rb +24 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2fae634ace0fd84b594ed5ba002298529ceb869
|
4
|
+
data.tar.gz: b6035c4939b68325d0dec3c4c56fa6db9e66c91a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d1cdc55a327900fec5a7d981ee197987c21c1f89a480d457f2115070677cac6eca0ca61f6bceaa73fe8eea2ff953194f925fa65b90ad6c554e5057799e7e8eb
|
7
|
+
data.tar.gz: f2b55d65cd4fb980fc0647e97eea79492883248e42105a3cd7205e16e7762205439223c1f528fe34fe0d460e4eb38525b9c6d0af9e4e040bd35e5809c2be7d87
|
data/lib/bubot.rb
CHANGED
@@ -6,8 +6,8 @@ module Bubot
|
|
6
6
|
define_method("#{method_name}_with_feature") do
|
7
7
|
start_time = Time.now
|
8
8
|
response = send("#{method_name}_without_feature".to_sym)
|
9
|
-
if (Time.now - start_time) > timeout
|
10
|
-
block.call(self)
|
9
|
+
if (total_time = Time.now - start_time) > timeout
|
10
|
+
block.call(self, total_time)
|
11
11
|
end
|
12
12
|
response
|
13
13
|
end
|
data/lib/bubot/version.rb
CHANGED
data/spec/bubot_spec.rb
CHANGED
@@ -92,6 +92,30 @@ describe Bubot do
|
|
92
92
|
|
93
93
|
bubot_observed.pass_self
|
94
94
|
end
|
95
|
+
|
96
|
+
it "passes the time it took to the strategy" do
|
97
|
+
class RecievesTimeStrategy
|
98
|
+
def self.execute(instance, time)
|
99
|
+
# do stuff
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
class PassesTime
|
104
|
+
extend Bubot
|
105
|
+
watch(:pass_time, 0.001) do |instance, time|
|
106
|
+
RecievesTimeStrategy.execute(instance, time)
|
107
|
+
end
|
108
|
+
def pass_time; sleep 0.002; end
|
109
|
+
end
|
110
|
+
|
111
|
+
bubot_observed = PassesTime.new
|
112
|
+
RecievesTimeStrategy.should_receive(:execute) do |instance, time|
|
113
|
+
expect(time).to be > 0.002
|
114
|
+
expect(instance).to be(bubot_observed)
|
115
|
+
end
|
116
|
+
|
117
|
+
bubot_observed.pass_time
|
118
|
+
end
|
95
119
|
end
|
96
120
|
end
|
97
121
|
end
|