timer 0.2 → 0.3.0
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 +5 -5
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -7
- data/Gemfile.lock +52 -0
- data/{History.txt → History.md} +5 -2
- data/{README.rdoc → README.md} +11 -11
- data/Rakefile +6 -2
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/timer.rb +2 -2
- data/lib/timer/version.rb +3 -0
- data/timer.gemspec +23 -45
- metadata +72 -29
- data/.document +0 -5
- data/LICENSE +0 -20
- data/VERSION +0 -1
- data/spec/timer_spec.rb +0 -167
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d14a0565d017071e4fe031695184c65f1d561f81309c7dbad3178d13491ff177
|
4
|
+
data.tar.gz: b8a8bc6909ee7ef3a8866a0d2701b75e4ba9e3f7b1220810ca2b989d11a76267
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c75ba50d98a6a06ee4da1c6a09182060839ae068c8a83fac23f0403eb28829436f9029ffcccaaffe689b84cb61241b188980bcb625e0a59a9281a639528f16e
|
7
|
+
data.tar.gz: 6fead0c6a40326961572139ee7bde8d8b5ab82c4906e7a7a6a0d7279612c0404e3c680e4cf0504fc6bddf28d7a44ed6c7489b1b635e7846950992d274d01d06d
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
CHANGED
@@ -1,9 +1,6 @@
|
|
1
|
-
source
|
1
|
+
source "https://rubygems.org"
|
2
2
|
|
3
|
-
|
4
|
-
gem "natural_time", ">= 0"
|
3
|
+
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
5
4
|
|
6
|
-
|
7
|
-
|
8
|
-
gem "timecop", ">= 0"
|
9
|
-
end
|
5
|
+
# Specify your gem's dependencies in timer.gemspec
|
6
|
+
gemspec
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
timer (0.3.0)
|
5
|
+
natural_time (~> 0.3.0)
|
6
|
+
timecop (~> 0.9.1)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
activesupport (5.1.4)
|
12
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
13
|
+
i18n (~> 0.7)
|
14
|
+
minitest (~> 5.1)
|
15
|
+
tzinfo (~> 1.1)
|
16
|
+
concurrent-ruby (1.0.5)
|
17
|
+
diff-lcs (1.3)
|
18
|
+
i18n (0.9.1)
|
19
|
+
concurrent-ruby (~> 1.0)
|
20
|
+
minitest (5.11.0)
|
21
|
+
natural_time (0.3.0)
|
22
|
+
activesupport (~> 5.1.4)
|
23
|
+
rake (10.5.0)
|
24
|
+
rspec (3.7.0)
|
25
|
+
rspec-core (~> 3.7.0)
|
26
|
+
rspec-expectations (~> 3.7.0)
|
27
|
+
rspec-mocks (~> 3.7.0)
|
28
|
+
rspec-core (3.7.0)
|
29
|
+
rspec-support (~> 3.7.0)
|
30
|
+
rspec-expectations (3.7.0)
|
31
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
32
|
+
rspec-support (~> 3.7.0)
|
33
|
+
rspec-mocks (3.7.0)
|
34
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
35
|
+
rspec-support (~> 3.7.0)
|
36
|
+
rspec-support (3.7.0)
|
37
|
+
thread_safe (0.3.6)
|
38
|
+
timecop (0.9.1)
|
39
|
+
tzinfo (1.2.4)
|
40
|
+
thread_safe (~> 0.1)
|
41
|
+
|
42
|
+
PLATFORMS
|
43
|
+
ruby
|
44
|
+
|
45
|
+
DEPENDENCIES
|
46
|
+
bundler (~> 1.16)
|
47
|
+
rake (~> 10.0)
|
48
|
+
rspec (~> 3.0)
|
49
|
+
timer!
|
50
|
+
|
51
|
+
BUNDLED WITH
|
52
|
+
1.16.1
|
data/{History.txt → History.md}
RENAMED
@@ -1,8 +1,11 @@
|
|
1
|
-
|
1
|
+
## 0.3.0 2018-01-02
|
2
|
+
* update gem to more recent dependencies
|
3
|
+
|
4
|
+
## 0.1.5 2010-01-16
|
2
5
|
* minor enhancements
|
3
6
|
* when an exception occurs during a timed block, output the exception message
|
4
7
|
|
5
|
-
|
8
|
+
## 0.1.4 2010-01-13
|
6
9
|
* minor enhancements
|
7
10
|
* extracted natural time output into 'natural_time' gem
|
8
11
|
* when an exception occurs during a timed block, output the elapsed time and re-raise
|
data/{README.rdoc → README.md}
RENAMED
@@ -1,20 +1,20 @@
|
|
1
|
-
|
1
|
+
# Timer
|
2
2
|
|
3
3
|
Simple timer to display elapsed time of a block.
|
4
4
|
|
5
|
-
|
5
|
+
## Usage
|
6
6
|
|
7
|
-
|
7
|
+
Instantiate timer with optional Growl message timer.
|
8
8
|
|
9
|
-
|
9
|
+
timer = Timer.new(:title => "My Timer")
|
10
10
|
|
11
|
-
|
11
|
+
Call the timer with a block and optional message to output.
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
timer.time("The block has finished executing!") do
|
14
|
+
# some code in here
|
15
|
+
end
|
16
16
|
|
17
|
-
|
17
|
+
## Note on Patches/Pull Requests
|
18
18
|
|
19
19
|
* Fork the project.
|
20
20
|
* Make your feature addition or bug fix.
|
@@ -24,6 +24,6 @@ Simple timer to display elapsed time of a block.
|
|
24
24
|
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
25
25
|
* Send me a pull request. Bonus points for topic branches.
|
26
26
|
|
27
|
-
|
27
|
+
## Copyright
|
28
28
|
|
29
|
-
Copyright (c)
|
29
|
+
Copyright (c) 2018 Isaac Priestley. See LICENSE for details.
|
data/Rakefile
CHANGED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "timer"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/timer.rb
CHANGED
data/timer.gemspec
CHANGED
@@ -1,50 +1,28 @@
|
|
1
|
-
Gem::Specification.new do |s|
|
2
|
-
s.name = %q{timer}
|
3
|
-
s.version = "0.2"
|
4
1
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
s.description = %q{Simple timer to perform a block and display the elapsed time.}
|
9
|
-
s.email = %q{progressions@gmail.com}
|
10
|
-
s.extra_rdoc_files = [
|
11
|
-
"LICENSE",
|
12
|
-
"README.rdoc"
|
13
|
-
]
|
14
|
-
s.files = [
|
15
|
-
".document",
|
16
|
-
"Gemfile",
|
17
|
-
"History.txt",
|
18
|
-
"LICENSE",
|
19
|
-
"README.rdoc",
|
20
|
-
"Rakefile",
|
21
|
-
"VERSION",
|
22
|
-
"lib/timer.rb",
|
23
|
-
"spec/timer_spec.rb",
|
24
|
-
"timer.gemspec"
|
25
|
-
]
|
26
|
-
s.homepage = %q{http://github.com/progressions/timer}
|
27
|
-
s.require_paths = ["lib"]
|
28
|
-
s.rubygems_version = %q{1.3.7}
|
29
|
-
s.summary = %q{Simple timer to perform a block and display the elapsed time}
|
30
|
-
s.test_files = [
|
31
|
-
"spec/timer_spec.rb"
|
32
|
-
]
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "timer/version"
|
33
5
|
|
34
|
-
|
35
|
-
|
36
|
-
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "timer"
|
8
|
+
spec.version = Timer::VERSION
|
9
|
+
spec.authors = ["Isaac Priestley"]
|
10
|
+
spec.email = ["progressions@gmail.com"]
|
37
11
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
end
|
45
|
-
else
|
46
|
-
s.add_dependency(%q<activesupport>, [">= 0"])
|
47
|
-
s.add_dependency(%q<natural_time>, [">= 0"])
|
12
|
+
spec.summary = %q{Simple timer to perform a block and display the elapsed time}
|
13
|
+
spec.description = %q{Simple timer to perform a block and display the elapsed time.}
|
14
|
+
spec.homepage = %q{http://github.com/progressions/timer}
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
|
+
f.match(%r{^(test|spec|features)/})
|
48
18
|
end
|
49
|
-
|
19
|
+
spec.bindir = "exe"
|
20
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ["lib"]
|
50
22
|
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
26
|
+
spec.add_dependency "natural_time", "~> 0.3.0"
|
27
|
+
spec.add_dependency "timecop", "~> 0.9.1"
|
28
|
+
end
|
metadata
CHANGED
@@ -1,60 +1,104 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: timer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Isaac Priestley
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
20
|
-
type: :
|
19
|
+
version: '1.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
21
49
|
prerelease: false
|
22
50
|
version_requirements: !ruby/object:Gem::Requirement
|
23
51
|
requirements:
|
24
|
-
- -
|
52
|
+
- - "~>"
|
25
53
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
54
|
+
version: '3.0'
|
27
55
|
- !ruby/object:Gem::Dependency
|
28
56
|
name: natural_time
|
29
57
|
requirement: !ruby/object:Gem::Requirement
|
30
58
|
requirements:
|
31
|
-
- -
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.3.0
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.3.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: timecop
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
32
74
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
75
|
+
version: 0.9.1
|
34
76
|
type: :runtime
|
35
77
|
prerelease: false
|
36
78
|
version_requirements: !ruby/object:Gem::Requirement
|
37
79
|
requirements:
|
38
|
-
- -
|
80
|
+
- - "~>"
|
39
81
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
82
|
+
version: 0.9.1
|
41
83
|
description: Simple timer to perform a block and display the elapsed time.
|
42
|
-
email:
|
84
|
+
email:
|
85
|
+
- progressions@gmail.com
|
43
86
|
executables: []
|
44
87
|
extensions: []
|
45
|
-
extra_rdoc_files:
|
46
|
-
- LICENSE
|
47
|
-
- README.rdoc
|
88
|
+
extra_rdoc_files: []
|
48
89
|
files:
|
49
|
-
- .
|
90
|
+
- ".gitignore"
|
91
|
+
- ".rspec"
|
92
|
+
- ".travis.yml"
|
50
93
|
- Gemfile
|
51
|
-
-
|
52
|
-
-
|
53
|
-
- README.
|
94
|
+
- Gemfile.lock
|
95
|
+
- History.md
|
96
|
+
- README.md
|
54
97
|
- Rakefile
|
55
|
-
-
|
98
|
+
- bin/console
|
99
|
+
- bin/setup
|
56
100
|
- lib/timer.rb
|
57
|
-
-
|
101
|
+
- lib/timer/version.rb
|
58
102
|
- timer.gemspec
|
59
103
|
homepage: http://github.com/progressions/timer
|
60
104
|
licenses: []
|
@@ -65,19 +109,18 @@ require_paths:
|
|
65
109
|
- lib
|
66
110
|
required_ruby_version: !ruby/object:Gem::Requirement
|
67
111
|
requirements:
|
68
|
-
- -
|
112
|
+
- - ">="
|
69
113
|
- !ruby/object:Gem::Version
|
70
114
|
version: '0'
|
71
115
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
116
|
requirements:
|
73
|
-
- -
|
117
|
+
- - ">="
|
74
118
|
- !ruby/object:Gem::Version
|
75
119
|
version: '0'
|
76
120
|
requirements: []
|
77
121
|
rubyforge_project:
|
78
|
-
rubygems_version: 2.
|
122
|
+
rubygems_version: 2.7.3
|
79
123
|
signing_key:
|
80
|
-
specification_version:
|
124
|
+
specification_version: 4
|
81
125
|
summary: Simple timer to perform a block and display the elapsed time
|
82
|
-
test_files:
|
83
|
-
- spec/timer_spec.rb
|
126
|
+
test_files: []
|
data/.document
DELETED
data/LICENSE
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright (c) 2009 Jeff Coleman
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.1.6
|
data/spec/timer_spec.rb
DELETED
@@ -1,167 +0,0 @@
|
|
1
|
-
$:.unshift File.dirname(__FILE__) + '/../lib'
|
2
|
-
require 'rubygems'
|
3
|
-
require 'timecop'
|
4
|
-
require 'timer'
|
5
|
-
|
6
|
-
describe "Timer" do
|
7
|
-
before do
|
8
|
-
$stdout.stub!(:puts).as_null_object
|
9
|
-
@g = Object.new
|
10
|
-
Growl.stub(:new).and_return(@g)
|
11
|
-
@g.stub(:notify).as_null_object
|
12
|
-
end
|
13
|
-
|
14
|
-
describe "growl" do
|
15
|
-
it "should growl a message" do
|
16
|
-
@g.should_receive(:notify).with(anything, anything, /hello/, anything, anything)
|
17
|
-
Timer.new.time("hello") do
|
18
|
-
x = 1
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
it "should growl a title" do
|
23
|
-
@g.should_receive(:notify).with(anything, /word/, anything, anything, anything)
|
24
|
-
Timer.new(:title => "word").time("hello") do
|
25
|
-
x = 1
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should turn off growl" do
|
30
|
-
@timer = Timer.new(:growl => false)
|
31
|
-
@timer.growl?.should be_false
|
32
|
-
end
|
33
|
-
|
34
|
-
it "shouldn't growl a message" do
|
35
|
-
Growl.should_not_receive(:new)
|
36
|
-
Timer.new(:growl => false).time("hello") do
|
37
|
-
x = 1
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
it "should fail gracefully if growl is off" do
|
42
|
-
@g.should_receive(:notify).and_raise("Connection refused: send(2)")
|
43
|
-
lambda {
|
44
|
-
Timer.new.time("hello") do
|
45
|
-
x = 1
|
46
|
-
end
|
47
|
-
}.should_not raise_error
|
48
|
-
end
|
49
|
-
|
50
|
-
it "should raise other exceptions" do
|
51
|
-
@g.should_receive(:notify).and_raise("Something else")
|
52
|
-
lambda {
|
53
|
-
Timer.new.time("hello") do
|
54
|
-
x = 1
|
55
|
-
end
|
56
|
-
}.should raise_error("Something else")
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
it "should put a message" do
|
61
|
-
$stdout.should_receive(:puts).with(/hello/)
|
62
|
-
Timer.new.time("hello") do
|
63
|
-
x = 1
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
describe "title" do
|
68
|
-
it "should set the title" do
|
69
|
-
Timer.new(:title => "YO").title.should == "YO"
|
70
|
-
end
|
71
|
-
|
72
|
-
it "shuld reset the title" do
|
73
|
-
@timer = Timer.new(:title => "YO")
|
74
|
-
@timer.title = "HEY"
|
75
|
-
@timer.title.should == "HEY"
|
76
|
-
end
|
77
|
-
|
78
|
-
it "should override the title" do
|
79
|
-
@g.should_receive(:notify).with(anything, /YEAH/, anything, anything, anything)
|
80
|
-
@timer = Timer.new(:title => "word")
|
81
|
-
@timer.time("hello", :title => "YEAH") do
|
82
|
-
x = 1
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
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 the exception" do
|
119
|
-
$stdout.should_receive(:puts).with(/Exception/)
|
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
|
-
|
140
|
-
describe "timing the action" do
|
141
|
-
before(:each) do
|
142
|
-
Timecop.return
|
143
|
-
@timer = Timer.new
|
144
|
-
end
|
145
|
-
|
146
|
-
it "should report seconds" do
|
147
|
-
@g.should_receive(:notify).with(anything, anything, /Elapsed time: 3 seconds\"\n$/, anything, anything)
|
148
|
-
@timer.time("hello") do
|
149
|
-
Timecop.freeze(Time.now + 3)
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
it "should report only minutes when it's even" do
|
154
|
-
@g.should_receive(:notify).with(anything, anything, /Elapsed time: 2 minutes\"\n$/, anything, anything)
|
155
|
-
@timer.time("hello") do
|
156
|
-
Timecop.freeze(Time.now + 120)
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
it "should report minutes and seconds" do
|
161
|
-
@g.should_receive(:notify).with(anything, anything, /Elapsed time: 1 minute and 14 seconds\"\n$/, anything, anything)
|
162
|
-
@timer.time("hello") do
|
163
|
-
Timecop.freeze(Time.now + 74)
|
164
|
-
end
|
165
|
-
end
|
166
|
-
end
|
167
|
-
end
|