minitest-skip 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +82 -0
- data/Rakefile +2 -0
- data/lib/minitest/skip_dsl.rb +54 -0
- data/lib/minitest/skip_plugin.rb +22 -0
- data/minitest-skip.gemspec +22 -0
- data/test/test_helper.rb +3 -0
- data/test/test_skip_dsl.rb +56 -0
- data/test/test_skip_methods.rb +58 -0
- metadata +100 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1beeaeb08a9e7844ad040cac471f79ab749d1742
|
4
|
+
data.tar.gz: b395cc6ac1cf5b94c0d458e5d32c6100790224d5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8479b71703443531894bb61bf972e8c90bb17fca2bce90306b8d73eb7a8870d0e6f9631f1a5035ad7cdbfabafbf2fb991654e9e8ea44a7360c8ec6d47e131a5a
|
7
|
+
data.tar.gz: 0afdbd6ce4a8c0660a320b087aa3b456e9d9cc91ba6dc02192e2ac25a057437e559f7fe5dbfd63cf680c6be8a652a5350475a089e053298bd2b6a213d7bde610
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2016 Ivan Tse
|
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,82 @@
|
|
1
|
+
# Minitest Skip
|
2
|
+
|
3
|
+
This gem provides alternative ways of skipping a test. Normally a skipped test in Minitest looks like:
|
4
|
+
|
5
|
+
```ruby
|
6
|
+
def test_that_is_flaky
|
7
|
+
skip "Figure out why this flakes"
|
8
|
+
end
|
9
|
+
```
|
10
|
+
|
11
|
+
The gotcha for skipping tests with the `skip` keyword is that the `setup` and `teardown` blocks are still executed. This can be costly for acceptance tests since their setup usually involves starting a browser among other slow things.
|
12
|
+
|
13
|
+
This gem will allow you to use methods that begin with `skip_` to mark a test as skipped. It modifies Minitest such that it will recognize these skip methods and correctly report the results.
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
require "minitest/autorun"
|
17
|
+
class TestSkip < Minitest::Test
|
18
|
+
def setup
|
19
|
+
sleep 2 # costly setup block
|
20
|
+
end
|
21
|
+
|
22
|
+
def skip_test_that_is_temporarily_broken
|
23
|
+
# ...
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# ruby test/test_skip.rb
|
28
|
+
# Run options: --seed 54134
|
29
|
+
|
30
|
+
# # Running:
|
31
|
+
|
32
|
+
# S
|
33
|
+
|
34
|
+
# Finished in 0.001663s, 601.3537 runs/s, 0.0000 assertions/s.
|
35
|
+
|
36
|
+
# 1 runs, 0 assertions, 0 failures, 0 errors, 1 skips
|
37
|
+
|
38
|
+
# You have skipped tests. Run with --verbose for details.
|
39
|
+
```
|
40
|
+
|
41
|
+
This gem also adds `xit` and `xdescribe` if you prefer the spec style syntax for Minitest.
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
require "minitest/autorun"
|
45
|
+
require "minitest/spec"
|
46
|
+
require "minitest/skip_dsl"
|
47
|
+
|
48
|
+
describe "Test" do
|
49
|
+
it "normal" do assert true end
|
50
|
+
xit "skipped" do assert false end
|
51
|
+
xdescribe "All skipped" do
|
52
|
+
it "nested skip" do assert false end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
```
|
57
|
+
|
58
|
+
## Installation
|
59
|
+
|
60
|
+
Add this line to your application's Gemfile:
|
61
|
+
|
62
|
+
```ruby
|
63
|
+
gem 'minitest-skip'
|
64
|
+
```
|
65
|
+
|
66
|
+
And then execute:
|
67
|
+
|
68
|
+
$ bundle
|
69
|
+
|
70
|
+
Or install it yourself as:
|
71
|
+
|
72
|
+
$ gem install minitest-skip
|
73
|
+
|
74
|
+
And that's it! This is a Minitest plugin which means that it will be autoloaded. In order to use `xit` and `xdescribe`, you also need to `require "minitest/skip_dsl"`.
|
75
|
+
|
76
|
+
## Contributing
|
77
|
+
|
78
|
+
1. Fork it ( https://github.com/ivantsepp/minitest-skip/fork )
|
79
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
80
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
81
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
82
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'minitest/spec'
|
2
|
+
|
3
|
+
module Minitest
|
4
|
+
module SkipDSL
|
5
|
+
def xit desc = "anonymous", &block
|
6
|
+
block ||= proc { skip "(no tests defined)" }
|
7
|
+
|
8
|
+
@specs ||= 0
|
9
|
+
@specs += 1
|
10
|
+
|
11
|
+
name = "skip_%04d_%s" % [ @specs, desc ]
|
12
|
+
|
13
|
+
undef_klasses = self.children.reject { |c| c.public_method_defined? name }
|
14
|
+
|
15
|
+
define_method name, &block
|
16
|
+
|
17
|
+
undef_klasses.each do |undef_klass|
|
18
|
+
undef_klass.send :undef_method, name
|
19
|
+
end
|
20
|
+
|
21
|
+
name
|
22
|
+
end
|
23
|
+
|
24
|
+
def nuke_test_methods! # :nodoc:
|
25
|
+
self.public_instance_methods.grep(/^test_|skip_/).each do |name|
|
26
|
+
self.send :undef_method, name
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
Spec.extend(SkipDSL)
|
32
|
+
end
|
33
|
+
|
34
|
+
module Kernel
|
35
|
+
def xdescribe(desc, *additional_desc, &block)
|
36
|
+
stack = Minitest::Spec.describe_stack
|
37
|
+
name = [stack.last, desc, *additional_desc].compact.join("::")
|
38
|
+
sclas = stack.last || if Class === self && kind_of?(Minitest::Spec::DSL) then
|
39
|
+
self
|
40
|
+
else
|
41
|
+
Minitest::Spec.spec_type desc, *additional_desc
|
42
|
+
end
|
43
|
+
|
44
|
+
cls = sclas.create name, desc
|
45
|
+
|
46
|
+
stack.push cls
|
47
|
+
cls.singleton_class.send(:define_method, :it, cls.method(:xit))
|
48
|
+
cls.class_eval(&block)
|
49
|
+
stack.pop
|
50
|
+
cls
|
51
|
+
end
|
52
|
+
|
53
|
+
private :xdescribe
|
54
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Minitest
|
2
|
+
module SkipPlugin
|
3
|
+
def run(reporter, options = {})
|
4
|
+
super
|
5
|
+
methods_matching(/^skip_/).each do |method_name|
|
6
|
+
test = self.new(method_name)
|
7
|
+
test.time = 0
|
8
|
+
|
9
|
+
skip = Skip.new("Skipped from SkipPlugin")
|
10
|
+
source = test.method(method_name).source_location
|
11
|
+
skip.set_backtrace(["#{source[0]}:#{source[1]}"])
|
12
|
+
test.failures << skip
|
13
|
+
|
14
|
+
reporter.record(test)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.plugin_skip_init(options)
|
20
|
+
Runnable.singleton_class.prepend(SkipPlugin)
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "minitest-skip"
|
7
|
+
spec.version = "0.0.1"
|
8
|
+
spec.authors = ["Ivan Tse"]
|
9
|
+
spec.email = ["ivan.tse1@gmail.com"]
|
10
|
+
spec.summary = %q{Alternative ways to skip tests in Minitest}
|
11
|
+
spec.description = %q{Adds skip_* methods and xit/xdescribe spec style methods.}
|
12
|
+
spec.homepage = "https://github.com/ivantsepp/minitest-skip"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
17
|
+
spec.require_paths = ["lib"]
|
18
|
+
|
19
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
20
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
21
|
+
spec.add_dependency "minitest", "~> 5.0"
|
22
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
require 'minitest/skip_dsl'
|
3
|
+
|
4
|
+
class TestSkipDSL < Minitest::Test
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@output = StringIO.new("")
|
8
|
+
|
9
|
+
@reporter = Minitest::CompositeReporter.new
|
10
|
+
@reporter << @summary_reporter = Minitest::SummaryReporter.new(@output)
|
11
|
+
@reporter << @progress_reporter = Minitest::ProgressReporter.new(@output)
|
12
|
+
@reporter.start
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_xit
|
16
|
+
test = describe "Test" do
|
17
|
+
it "normal" do assert true end
|
18
|
+
xit "skipped" do assert false end
|
19
|
+
end
|
20
|
+
test.run(@reporter)
|
21
|
+
@reporter.report
|
22
|
+
|
23
|
+
assert_includes @output.string.dup, "2 runs, 1 assertions, 0 failures, 0 errors, 1 skips"
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_xdescribe
|
27
|
+
test = xdescribe "Test" do
|
28
|
+
it "normal" do assert true end
|
29
|
+
xit "skipped" do assert false end
|
30
|
+
end
|
31
|
+
test.run(@reporter)
|
32
|
+
@reporter.report
|
33
|
+
|
34
|
+
assert_includes @output.string.dup, "2 runs, 0 assertions, 0 failures, 0 errors, 2 skips"
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_nested_describes
|
38
|
+
nested_1 = nested_2 = nil
|
39
|
+
test = describe "Test" do
|
40
|
+
it "normal" do assert true end
|
41
|
+
xit "skipped" do assert false end
|
42
|
+
nested_1 = xdescribe "All skipped" do
|
43
|
+
it "nested skip" do assert false end
|
44
|
+
nested_2 = describe "nested describe" do
|
45
|
+
it "nested 2 levels skip" do assert false end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
test.run(@reporter)
|
50
|
+
nested_1.run(@reporter)
|
51
|
+
nested_2.run(@reporter)
|
52
|
+
@reporter.report
|
53
|
+
|
54
|
+
assert_includes @output.string.dup, "4 runs, 1 assertions, 0 failures, 0 errors, 3 skips"
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
class TestSkipMethods < Minitest::Test
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@@ran = false
|
7
|
+
@test = Class.new(Minitest::Test) do
|
8
|
+
def skip_test_name
|
9
|
+
@@ran = true
|
10
|
+
end
|
11
|
+
end
|
12
|
+
@output = StringIO.new("")
|
13
|
+
|
14
|
+
@reporter = Minitest::CompositeReporter.new
|
15
|
+
@reporter << @summary_reporter = Minitest::SummaryReporter.new(@output)
|
16
|
+
@reporter << @progress_reporter = Minitest::ProgressReporter.new(@output)
|
17
|
+
@reporter.start
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_run_skip
|
21
|
+
@test.run(@reporter)
|
22
|
+
@reporter.report
|
23
|
+
assert_includes @output.string.dup, "1 runs, 0 assertions, 0 failures, 0 errors, 1 skips"
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_run_skip_verbose
|
27
|
+
Object.const_set("ExampleSkipTest", @test)
|
28
|
+
@progress_reporter.options = { verbose: true }
|
29
|
+
@summary_reporter.options = { verbose: true }
|
30
|
+
|
31
|
+
@test.run(@reporter)
|
32
|
+
@reporter.report
|
33
|
+
|
34
|
+
assert_includes @output.string.dup, "#skip_test_name = 0.00 s = S"
|
35
|
+
assert_includes @output.string.dup, <<-EOM.gsub(/^ {4}/, "")
|
36
|
+
1) Skipped:
|
37
|
+
ExampleSkipTest#skip_test_name [test/test_skip_methods.rb:8]:
|
38
|
+
Skipped from SkipPlugin
|
39
|
+
EOM
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_skip_methods_are_recorded
|
44
|
+
@test.run(@reporter)
|
45
|
+
result = @summary_reporter.results.first
|
46
|
+
failure = result.failures.first
|
47
|
+
assert result.skipped?
|
48
|
+
assert_equal Minitest::Skip, failure.error.class
|
49
|
+
assert_equal "Skipped from SkipPlugin", failure.error.message
|
50
|
+
assert_equal "test/test_skip_methods.rb:8", failure.location
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_skip_methods_are_not_executed
|
54
|
+
@test.run(@reporter)
|
55
|
+
refute @@ran, "skip methods should not be executed"
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
metadata
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: minitest-skip
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ivan Tse
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-01-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
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: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.0'
|
55
|
+
description: Adds skip_* methods and xit/xdescribe spec style methods.
|
56
|
+
email:
|
57
|
+
- ivan.tse1@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- lib/minitest/skip_dsl.rb
|
68
|
+
- lib/minitest/skip_plugin.rb
|
69
|
+
- minitest-skip.gemspec
|
70
|
+
- test/test_helper.rb
|
71
|
+
- test/test_skip_dsl.rb
|
72
|
+
- test/test_skip_methods.rb
|
73
|
+
homepage: https://github.com/ivantsepp/minitest-skip
|
74
|
+
licenses:
|
75
|
+
- MIT
|
76
|
+
metadata: {}
|
77
|
+
post_install_message:
|
78
|
+
rdoc_options: []
|
79
|
+
require_paths:
|
80
|
+
- lib
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
requirements: []
|
92
|
+
rubyforge_project:
|
93
|
+
rubygems_version: 2.2.2
|
94
|
+
signing_key:
|
95
|
+
specification_version: 4
|
96
|
+
summary: Alternative ways to skip tests in Minitest
|
97
|
+
test_files:
|
98
|
+
- test/test_helper.rb
|
99
|
+
- test/test_skip_dsl.rb
|
100
|
+
- test/test_skip_methods.rb
|