minitest-snail 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 16d29aa7c6a35492b77bfef671e9ac16bc7a58aa
4
+ data.tar.gz: 6dfb960d71c3ddd016156b99571ec4fc9f295158
5
+ SHA512:
6
+ metadata.gz: 78bd0c921c844769e9a501a0356b582f8a340e645c5ce34451d7226d39b4b8cf0c914bb37d6b6948e4bcc80d9402eace5bd977b487b357549823d0abd6a98134
7
+ data.tar.gz: f6789adbc907889135051a65cc5f3e638c19b9318cec94e9e68d28e88c54eba9dfaeb3e94b0d5772879d2004baa67237468dd8fd7130bf963f09046478fa28b8
@@ -0,0 +1,45 @@
1
+ Minitest Snail
2
+ ======================
3
+
4
+ Prints a list of tests that take too long.
5
+
6
+ Installation
7
+ ------------
8
+
9
+ gem instal minitest-snail
10
+
11
+ Usage
12
+ -----
13
+
14
+ Minitest Snail can be enabled from the command line using the `max-duration` parameter:
15
+
16
+ ruby test/example_test.rb --max-duration 2
17
+
18
+ This would print out a list of any tests taking longer than 2 seconds to run:
19
+
20
+ # Running:
21
+
22
+ ....
23
+
24
+ Finished in 5.001143s
25
+
26
+ 4 runs, 7 assertions, 0 failures, 0 errors, 0 skips
27
+
28
+ 2 slow tests.
29
+ 0) ExampleTest#test_alpha: 2.30 s
30
+ 1) ExampleTest#test_beta: 2.11 s
31
+
32
+ If you don't run your tests directly, you can programmatically enable Minitest Snail:
33
+
34
+ Minitest::SnailReporter.enable!
35
+
36
+ You can also configure it using `enable!`:
37
+
38
+ Minitest::SnailReporter.enable! :max_duration => 2.5
39
+
40
+ If you are using Rails, your `test/test_helper.rb` file is good place to do this initialization.
41
+
42
+ Authors
43
+ -------
44
+
45
+ [Adam Sanderson](netghost@gmail.com) (http://monkeyandcrow.com)
@@ -0,0 +1,17 @@
1
+ require_relative './snail_reporter'
2
+
3
+ module Minitest
4
+ def self.plugin_snail_options(opts, options)
5
+ opts.on "--max-duration TIME", "Report tests that take longer than TIME seconds." do |max_duration|
6
+ SnailReporter.enable! :max_duration => max_duration.to_f
7
+ end
8
+ end
9
+
10
+ def self.plugin_snail_init(options)
11
+ if SnailReporter.enabled?
12
+ io = options[:io]
13
+ Minitest.reporter.reporters << SnailReporter.new(io)
14
+ end
15
+ end
16
+
17
+ end
@@ -0,0 +1,44 @@
1
+ module Minitest
2
+ class SnailReporter < Reporter
3
+ attr_reader :slow_tests, :max_duration
4
+
5
+ def self.options
6
+ @default_options ||= {
7
+ :max_duration => 2
8
+ }
9
+ end
10
+
11
+ def self.enable!(options = {})
12
+ @enabled = true
13
+ self.options.merge!(options)
14
+ end
15
+
16
+ def self.enabled?
17
+ @enabled ||= false
18
+ end
19
+
20
+ def initialize(io = STDOUT, options = self.class.options)
21
+ super
22
+
23
+ @max_duration = options.fetch(:max_duration)
24
+ @slow_tests = []
25
+ end
26
+
27
+ def record result
28
+ slow_tests << result if result.time > max_duration
29
+ end
30
+
31
+ def report
32
+ return if slow_tests.empty?
33
+
34
+ slow_tests.sort_by!{|r| -r.time}
35
+
36
+ io.puts
37
+ io.puts "#{slow_tests.length} slow tests."
38
+ slow_tests.each_with_index do |result, i|
39
+ io.puts "%3d) %s: %.2f s" % [i+1, result.location, result.time]
40
+ end
41
+ end
42
+
43
+ end
44
+ end
metadata ADDED
@@ -0,0 +1,61 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: minitest-snail
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Adam Sanderson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-03-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: minitest
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '5.5'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '5.5'
27
+ description: Summarizes minitest tests, printing out tests that take too long.
28
+ email:
29
+ - netghost@gmail.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - README.markdown
35
+ - lib/minitest/snail_plugin.rb
36
+ - lib/minitest/snail_reporter.rb
37
+ homepage: https://github.com/adamsanderson/minitest-snail
38
+ licenses:
39
+ - MIT
40
+ metadata: {}
41
+ post_install_message:
42
+ rdoc_options: []
43
+ require_paths:
44
+ - lib
45
+ required_ruby_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ required_rubygems_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ requirements: []
56
+ rubyforge_project:
57
+ rubygems_version: 2.2.1
58
+ signing_key:
59
+ specification_version: 4
60
+ summary: Identify slow tests.
61
+ test_files: []