timer 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/spec/timer_spec.rb +55 -4
- data/timer.gemspec +1 -1
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.3
|
data/spec/timer_spec.rb
CHANGED
@@ -57,7 +57,7 @@ describe "Timer" do
|
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
-
it "
|
60
|
+
it "should put a message" do
|
61
61
|
$stdout.should_receive(:puts).with(/hello/)
|
62
62
|
Timer.new.time("hello") do
|
63
63
|
x = 1
|
@@ -84,14 +84,67 @@ describe "Timer" do
|
|
84
84
|
end
|
85
85
|
end
|
86
86
|
|
87
|
+
describe "raising exceptions" do
|
88
|
+
before(:each) do
|
89
|
+
@timer = Timer.new
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should re-raise an exception" do
|
93
|
+
lambda {
|
94
|
+
@timer.time("hello") do
|
95
|
+
raise "Exception"
|
96
|
+
end
|
97
|
+
}.should raise_error("Exception")
|
98
|
+
end
|
99
|
+
|
100
|
+
it "should growl a message" do
|
101
|
+
@g.should_receive(:notify).with(anything, anything, /hello/, anything, anything)
|
102
|
+
lambda {
|
103
|
+
@timer.time("hello") do
|
104
|
+
raise "Exception"
|
105
|
+
end
|
106
|
+
}.should raise_error("Exception")
|
107
|
+
end
|
108
|
+
|
109
|
+
it "should growl a title" do
|
110
|
+
@g.should_receive(:notify).with(anything, /word/, anything, anything, anything)
|
111
|
+
lambda {
|
112
|
+
Timer.new(:title => "word").time("hello") do
|
113
|
+
raise "Exception"
|
114
|
+
end
|
115
|
+
}.should raise_error("Exception")
|
116
|
+
end
|
117
|
+
|
118
|
+
it "should put a message" do
|
119
|
+
$stdout.should_receive(:puts).with(/hello/)
|
120
|
+
lambda {
|
121
|
+
@timer.time("hello") do
|
122
|
+
raise "Exception"
|
123
|
+
end
|
124
|
+
}.should raise_error("Exception")
|
125
|
+
end
|
126
|
+
|
127
|
+
it "should report elapsed time" do
|
128
|
+
Timecop.return
|
129
|
+
@g.should_receive(:notify).with(anything, anything, /Elapsed time: 2 minutes\"\n$/, anything, anything)
|
130
|
+
lambda {
|
131
|
+
@timer.time("hello") do
|
132
|
+
Timecop.freeze(Time.now + 120)
|
133
|
+
raise "Exception"
|
134
|
+
end
|
135
|
+
}.should raise_error("Exception")
|
136
|
+
Timecop.return
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
87
140
|
describe "timing the action" do
|
88
141
|
before(:each) do
|
89
142
|
Timecop.return
|
143
|
+
@timer = Timer.new
|
90
144
|
end
|
91
145
|
|
92
146
|
it "should report seconds" do
|
93
147
|
@g.should_receive(:notify).with(anything, anything, /Elapsed time: 3 seconds\"\n$/, anything, anything)
|
94
|
-
@timer = Timer.new
|
95
148
|
@timer.time("hello") do
|
96
149
|
Timecop.freeze(Time.now + 3)
|
97
150
|
end
|
@@ -99,7 +152,6 @@ describe "Timer" do
|
|
99
152
|
|
100
153
|
it "should report only minutes when it's even" do
|
101
154
|
@g.should_receive(:notify).with(anything, anything, /Elapsed time: 2 minutes\"\n$/, anything, anything)
|
102
|
-
@timer = Timer.new
|
103
155
|
@timer.time("hello") do
|
104
156
|
Timecop.freeze(Time.now + 120)
|
105
157
|
end
|
@@ -107,7 +159,6 @@ describe "Timer" do
|
|
107
159
|
|
108
160
|
it "should report minutes and seconds" do
|
109
161
|
@g.should_receive(:notify).with(anything, anything, /Elapsed time: 1 minute, 14 seconds\"\n$/, anything, anything)
|
110
|
-
@timer = Timer.new
|
111
162
|
@timer.time("hello") do
|
112
163
|
Timecop.freeze(Time.now + 74)
|
113
164
|
end
|
data/timer.gemspec
CHANGED