bubot 0.0.2 → 0.0.3
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 +14 -1
- 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: 02e14c092d6111ff2a7438dd5372f5ef16c3f620
|
|
4
|
+
data.tar.gz: d580e4a8efa9a8f0bf103d4b5b54ac68a05f0eca
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e335fb6754b0dc81609b965917b36745fb65139929dcc463717d594121192f7a95d03501f993287b3a11def5dad805b01a44522119f2d352d931b24847c4d97e
|
|
7
|
+
data.tar.gz: d8d808b606983dc9b3d81b8fd259fcb4a4990a6ab317614db65e64ba3800d9e47f7561b3a5de7504ce666c96cfd33d6ea630a008a093146bb44d1a9e2d69d15e
|
data/lib/bubot.rb
CHANGED
|
@@ -2,12 +2,12 @@ require "bubot/version"
|
|
|
2
2
|
|
|
3
3
|
module Bubot
|
|
4
4
|
|
|
5
|
-
def watch(method_name, timeout
|
|
5
|
+
def watch(method_name, timeout=0)
|
|
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
9
|
if (total_time = Time.now - start_time) > timeout
|
|
10
|
-
|
|
10
|
+
yield(self, total_time)
|
|
11
11
|
end
|
|
12
12
|
response
|
|
13
13
|
end
|
data/lib/bubot/version.rb
CHANGED
data/spec/bubot_spec.rb
CHANGED
|
@@ -60,6 +60,19 @@ describe Bubot do
|
|
|
60
60
|
end
|
|
61
61
|
end
|
|
62
62
|
|
|
63
|
+
context "timeout is optional" do
|
|
64
|
+
it "timeout is not passed" do
|
|
65
|
+
class NoTimeout
|
|
66
|
+
extend Bubot
|
|
67
|
+
watch(:without_timeout) { Baz.buz }
|
|
68
|
+
def without_timeout() end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
Baz.should_receive(:buz).once
|
|
72
|
+
NoTimeout.new.without_timeout
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
63
76
|
context "watching methods that are not defined" do
|
|
64
77
|
it "does nothing and does not break" do
|
|
65
78
|
expect do
|
|
@@ -71,7 +84,7 @@ describe Bubot do
|
|
|
71
84
|
end
|
|
72
85
|
end
|
|
73
86
|
|
|
74
|
-
context "
|
|
87
|
+
context "sending messages to strategy" do
|
|
75
88
|
it "passes its instance to the strategy" do
|
|
76
89
|
class RecievesSelfStrategy
|
|
77
90
|
def self.execute(instance)
|