minitest-slow_test 0.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8b31703cc2c551f3c3dedb596bd6b0820d095c83
4
+ data.tar.gz: 047ae032fd6d9e08ffabb72c204f67e911377464
5
+ SHA512:
6
+ metadata.gz: f72fdcd49b2ac769dbc633c6841991495550abf6cabc215a4974e73d9370cfe077318c226dfb9b3cab0339d4d6a9bea811268f64d8616549cde6648ea53393eb
7
+ data.tar.gz: e389d5e2fac59ae9b89115101ba3e3fb9990b79d31c4d10472529fd3f671e3a76622d9a72f2debf4cbe292474a5fdc3e32ac550d5f4a379c3a346a4a02e096a8
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.1
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in minitest-slow_test.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 yuuji.yaginuma
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,66 @@
1
+ # Minitest::SlowTest
2
+
3
+ Display the summary of a slow test when tests finished.
4
+
5
+ ## Output example
6
+
7
+ ```shell
8
+ $ ./bin/rake test
9
+ Run options: --seed 4004
10
+
11
+ # Running:
12
+
13
+ ........................
14
+
15
+ Finished in 3.367417s, 7.1271 runs/s, 16.0360 assertions/s.
16
+
17
+ 24 runs, 54 assertions, 0 failures, 0 errors, 0 skips
18
+ [SlowTest]PageIntegrationTest#test_create_new_page : 1.17s
19
+ [SlowTest]PageTest#test_do_not_find_page_when_use_invalid_title : 1.00s
20
+ ```
21
+
22
+ ## Installation
23
+
24
+ Add this line to your application's Gemfile:
25
+
26
+ gem 'minitest-slow_test'
27
+
28
+ And then execute:
29
+
30
+ $ bundle
31
+
32
+ Or install it yourself as:
33
+
34
+ $ gem install minitest-slow_test
35
+
36
+ ## Usage
37
+
38
+ Such a test is output more than one second, and processing makes by default it.
39
+
40
+ When You want to change the processing time, please set it as follows in `test_helper.rb`
41
+
42
+ ```ruby
43
+ require 'minitest/slow_test'
44
+
45
+ Minitest::SlowTest.long_test_time = 0.5 # specified in seconds
46
+ ```
47
+
48
+ ### When use with `minitest-reporters`
49
+
50
+ When use it with `minitest-reporters`, it is necessary to set `Minitest::SlowTest::Reporter` in `Minitest::Reporters.use!`
51
+
52
+ Example:
53
+
54
+ ```ruby
55
+ require 'minitest/slow_test/reporter'
56
+
57
+ Minitest::Reporters.use! [Minitest::Reporters::SpecReporter.new, Minitest::SlowTest::Reporter.new]
58
+ ```
59
+
60
+ ## Contributing
61
+
62
+ 1. Fork it ( https://github.com/y-yagi/minitest-slow_test/fork )
63
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
64
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
65
+ 4. Push to the branch (`git push origin my-new-feature`)
66
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ task default: :test
5
+ Rake::TestTask.new do |t|
6
+ t.pattern = "test/**/*_test.rb"
7
+ t.verbose = true
8
+ end
@@ -0,0 +1,13 @@
1
+ require 'minitest/slow_test/version'
2
+
3
+ module Minitest
4
+ module SlowTest
5
+ class << self
6
+ attr_accessor :long_test_time
7
+
8
+ def long_test_time
9
+ (@long_test_time || 1.0).to_f
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,31 @@
1
+ module Minitest
2
+ module SlowTest
3
+ class Reporter < StatisticsReporter
4
+ attr_reader :slow_test_list
5
+
6
+ def initialize(io = $stdout, options = {})
7
+ super(io, options)
8
+ @slow_test_list = []
9
+ end
10
+
11
+ def report
12
+ super
13
+ @slow_test_list.each do |slow_test|
14
+ io.print "[SlowTest] %s#%s : %.2fs\n" % [slow_test.class, slow_test.name, slow_test.time]
15
+ end
16
+ end
17
+
18
+ def record(result)
19
+ @slow_test_list << result if result.time.to_f > SlowTest.long_test_time
20
+ end
21
+
22
+ # When using the following methods together with `minitest-reporters`,
23
+ # they are required.
24
+ def add_defaults(defaults); end
25
+
26
+ def before_test(test); end
27
+
28
+ def after_test(test); end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,5 @@
1
+ module Minitest
2
+ module SlowTest
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,8 @@
1
+ require 'minitest/slow_test'
2
+ require 'minitest/slow_test/reporter'
3
+
4
+ module Minitest
5
+ def self.plugin_slow_test_init(opts)
6
+ self.reporter << Minitest::SlowTest::Reporter.new
7
+ end
8
+ end
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'minitest/slow_test/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "minitest-slow_test"
8
+ spec.version = Minitest::SlowTest::VERSION
9
+ spec.authors = ["Yuji Yaginuma"]
10
+ spec.email = ["yuuji.yaginuma@gmail.com"]
11
+ spec.summary = %q{Display the summary of a slow test when tests finished.}
12
+ spec.homepage = "https://github.com/y-yagi/minitest-slow_test"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_dependency 'minitest', '>= 5.0'
21
+ spec.add_development_dependency "bundler", "~> 1.6"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "pry"
24
+ end
@@ -0,0 +1,37 @@
1
+ require 'minitest/autorun'
2
+
3
+ module MinitestSlowTestTest
4
+ class ReportersTest < Minitest::Test
5
+ attr_accessor :reporter, :output
6
+
7
+ def setup
8
+ @output = StringIO.new("")
9
+ self.reporter = Minitest::CompositeReporter.new
10
+ reporter << Minitest::SlowTest::Reporter.new(@output)
11
+ end
12
+
13
+ def test_slow_test_information_do_not_display
14
+ reporter.start
15
+ reporter.record(SampleTest.new(:test_normal).run)
16
+ reporter.report
17
+ assert_empty @output.string
18
+ end
19
+
20
+ def test_slow_test_information_display
21
+ reporter.start
22
+ reporter.record(SampleTest.new(:test_slow).run)
23
+ reporter.report
24
+ assert_match /\[SlowTest\] SampleTest#test_slow/, @output.string
25
+ end
26
+ end
27
+ end
28
+
29
+ class SampleTest < Minitest::Test
30
+ def test_normal
31
+ end
32
+
33
+ def test_slow
34
+ sleep 1.0
35
+ end
36
+ end
37
+
metadata ADDED
@@ -0,0 +1,113 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: minitest-slow_test
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Yuji Yaginuma
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-09-26 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.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '5.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.6'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.6'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description:
70
+ email:
71
+ - yuuji.yaginuma@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".travis.yml"
78
+ - Gemfile
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - lib/minitest/slow_test.rb
83
+ - lib/minitest/slow_test/reporter.rb
84
+ - lib/minitest/slow_test/version.rb
85
+ - lib/minitest/slow_test_plugin.rb
86
+ - minitest-slow_test.gemspec
87
+ - test/slow_test_test.rb
88
+ homepage: https://github.com/y-yagi/minitest-slow_test
89
+ licenses:
90
+ - MIT
91
+ metadata: {}
92
+ post_install_message:
93
+ rdoc_options: []
94
+ require_paths:
95
+ - lib
96
+ required_ruby_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ required_rubygems_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ requirements: []
107
+ rubyforge_project:
108
+ rubygems_version: 2.2.2
109
+ signing_key:
110
+ specification_version: 4
111
+ summary: Display the summary of a slow test when tests finished.
112
+ test_files:
113
+ - test/slow_test_test.rb