spec_timer 0.1.1
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 +7 -0
- data/lib/spec_timer/reporter.rb +42 -0
- data/lib/spec_timer/timer.rb +31 -0
- data/lib/spec_timer/version.rb +3 -0
- data/lib/spec_timer/watch.rb +13 -0
- data/lib/spec_timer.rb +5 -0
- metadata +49 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: eca6d2ad3ba3f842205748983b524618ef322c7b
|
4
|
+
data.tar.gz: 54a3ee9d4e95f4ae790f393e6a33bb0355fd2ad6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 827102975cae2b2550584829af3fc2eb3f33fab4e753a19c4a93b4df88908f61b76ea109c1584203fb352c22d4d90c9eebd6636762e80fdfd3d6c0b38e44fc92
|
7
|
+
data.tar.gz: ed090eb0b19b1dccb1b4047b25720eb0d97ca790f586420d285fcbabbe52647a1ffedafdddebba36753cee9d74c99c4f5ea021b0dbc7823c4cb18b1f38917757
|
@@ -0,0 +1,42 @@
|
|
1
|
+
class SpecTimer::Reporter
|
2
|
+
def self.report
|
3
|
+
long_tests = SpecTimer::Timer.long_tests
|
4
|
+
puts SpecTimer::Color.text("\n\nUsing SpecTimer", :yellow)
|
5
|
+
|
6
|
+
if long_tests.any?
|
7
|
+
puts "Long Tests:"
|
8
|
+
long_tests.each_with_index do |test, index|
|
9
|
+
puts SpecTimer::Color.text("\n #{index + 1}) #{test[:name]}", :yellow)
|
10
|
+
puts SpecTimer::Color.text(" Took to long: #{test[:time]} seconds!", :red)
|
11
|
+
puts SpecTimer::Color.text(" # #{test[:file]}", :cyan)
|
12
|
+
end
|
13
|
+
puts "\nSlow examples:"
|
14
|
+
long_tests.each do |test|
|
15
|
+
print SpecTimer::Color.text("rspec #{test[:file]} ", :red)
|
16
|
+
puts SpecTimer::Color.text("# #{test[:name]}", :cyan)
|
17
|
+
end
|
18
|
+
else
|
19
|
+
puts SpecTimer::Color.text("All tests are under the maximum allowed time!", :green)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class SpecTimer::Color
|
25
|
+
COLOR_CONVERSION = {
|
26
|
+
red: 1,
|
27
|
+
green: 2,
|
28
|
+
yellow: 3,
|
29
|
+
blue: 4,
|
30
|
+
magenta: 5,
|
31
|
+
cyan: 6,
|
32
|
+
white: 7
|
33
|
+
}
|
34
|
+
|
35
|
+
def self.text(string, color)
|
36
|
+
"\e[#{COLOR_CONVERSION[color] + 30}m#{string}\e[0m"
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.background(string, color)
|
40
|
+
"\e[#{COLOR_CONVERSION[color] + 40}m#{string}\e[0m"
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module SpecTimer::Timer
|
2
|
+
def self.start
|
3
|
+
@start_time = Time.now
|
4
|
+
end
|
5
|
+
|
6
|
+
def self.finish(example)
|
7
|
+
@end_time = Time.now
|
8
|
+
record(example)
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.record(example)
|
12
|
+
@recorded ||= []
|
13
|
+
@recorded << { time: time_taken, file: example.location, name: example.full_description }
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.long_tests
|
17
|
+
recorded.select { |r| r[:time] > 1 }
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.recorded
|
21
|
+
@recorded
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.time_taken
|
25
|
+
@end_time - @start_time
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.reset
|
29
|
+
@recorded = []
|
30
|
+
end
|
31
|
+
end
|
data/lib/spec_timer.rb
ADDED
metadata
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: spec_timer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- dalexj
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-09-18 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: SpecTimer is a testing hook that reports specs which took too long to
|
14
|
+
run
|
15
|
+
email: 96dalex@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- lib/spec_timer.rb
|
21
|
+
- lib/spec_timer/reporter.rb
|
22
|
+
- lib/spec_timer/timer.rb
|
23
|
+
- lib/spec_timer/version.rb
|
24
|
+
- lib/spec_timer/watch.rb
|
25
|
+
homepage: https://github.com/dalexj
|
26
|
+
licenses:
|
27
|
+
- MIT
|
28
|
+
metadata: {}
|
29
|
+
post_install_message:
|
30
|
+
rdoc_options: []
|
31
|
+
require_paths:
|
32
|
+
- lib
|
33
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
43
|
+
requirements: []
|
44
|
+
rubyforge_project:
|
45
|
+
rubygems_version: 2.4.5
|
46
|
+
signing_key:
|
47
|
+
specification_version: 4
|
48
|
+
summary: Times your tests
|
49
|
+
test_files: []
|