timer 0.1.2 → 0.1.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.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/spec/timer_spec.rb +55 -4
  3. data/timer.gemspec +1 -1
  4. metadata +1 -1
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.1.3
@@ -57,7 +57,7 @@ describe "Timer" do
57
57
  end
58
58
  end
59
59
 
60
- it "puts a message" do
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
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{timer}
8
- s.version = "0.1.2"
8
+ s.version = "0.1.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jeff Coleman"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: timer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Coleman