minitest-skip 0.0.1 → 0.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 1beeaeb08a9e7844ad040cac471f79ab749d1742
4
- data.tar.gz: b395cc6ac1cf5b94c0d458e5d32c6100790224d5
2
+ SHA256:
3
+ metadata.gz: d58ef5603272ebb1da3d8d993be21afb4e4e7eeefed265545a90090c93a5a36e
4
+ data.tar.gz: 0ba54cd05b6c1fac386c1ac3542090d89aa09b5bb9de7cb9c0a8b357dcfc0920
5
5
  SHA512:
6
- metadata.gz: 8479b71703443531894bb61bf972e8c90bb17fca2bce90306b8d73eb7a8870d0e6f9631f1a5035ad7cdbfabafbf2fb991654e9e8ea44a7360c8ec6d47e131a5a
7
- data.tar.gz: 0afdbd6ce4a8c0660a320b087aa3b456e9d9cc91ba6dc02192e2ac25a057437e559f7fe5dbfd63cf680c6be8a652a5350475a089e053298bd2b6a213d7bde610
6
+ metadata.gz: f80152d68a6a7cbfe14624d0db6ee35fce9d0775cdba46ef882c97204e750742b5966801c8a33d622e2e1ae56b23c8ba57bb835c1e9196a9eeb0e59f99f74fb5
7
+ data.tar.gz: 6f6fc98a1ff2310cd339d6bdf321313f9562d8c7e3b65f0368d7b75be682bf4d4cc6ede359b118de3a3ef028d045a320e4f5c19893c6014b2724bfd996f61787
data/README.md CHANGED
@@ -55,6 +55,14 @@ end
55
55
 
56
56
  ```
57
57
 
58
+ Or you can use the `skip` macro (suggested by [@sgtFloyd](https://github.com/sgtFloyd)):
59
+
60
+ ```ruby
61
+ skip def test_something
62
+ # ...
63
+ end
64
+ ```
65
+
58
66
  ## Installation
59
67
 
60
68
  Add this line to your application's Gemfile:
@@ -71,7 +79,7 @@ Or install it yourself as:
71
79
 
72
80
  $ gem install minitest-skip
73
81
 
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"`.
82
+ And that's it! This is a Minitest plugin which means that it will be autoloaded. If you want to use `xit` and `xdescribe` methods, you also need to `require "minitest/skip_dsl"`.
75
83
 
76
84
  ## Contributing
77
85
 
data/Rakefile CHANGED
@@ -1,2 +1,8 @@
1
1
  require "bundler/gem_tasks"
2
+ require "rake/testtask"
2
3
 
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ end
7
+
8
+ task :default => :test
@@ -2,6 +2,9 @@ require 'minitest/spec'
2
2
 
3
3
  module Minitest
4
4
  module SkipDSL
5
+
6
+ # Exact copy of Minitest::Spec::DSL#it except that it creates a method
7
+ # that starts with `skip_`
5
8
  def xit desc = "anonymous", &block
6
9
  block ||= proc { skip "(no tests defined)" }
7
10
 
@@ -21,6 +24,8 @@ module Minitest
21
24
  name
22
25
  end
23
26
 
27
+ # Exact copy of Minitest::Spec::DSL#nuke_test_methods! except that it
28
+ # also undefines `skip_` methods
24
29
  def nuke_test_methods! # :nodoc:
25
30
  self.public_instance_methods.grep(/^test_|skip_/).each do |name|
26
31
  self.send :undef_method, name
@@ -32,6 +37,8 @@ module Minitest
32
37
  end
33
38
 
34
39
  module Kernel
40
+ # Exact copy of Kernel#desribe except that it aliases `it` to `xit` for
41
+ # the class that is created
35
42
  def xdescribe(desc, *additional_desc, &block)
36
43
  stack = Minitest::Spec.describe_stack
37
44
  name = [stack.last, desc, *additional_desc].compact.join("::")
@@ -52,3 +59,10 @@ module Kernel
52
59
 
53
60
  private :xdescribe
54
61
  end
62
+
63
+ class Minitest::Runnable
64
+ def self.skip(method_name)
65
+ undef_method(method_name)
66
+ define_method("skip_#{method_name}") {}
67
+ end
68
+ end
@@ -1,9 +1,14 @@
1
1
  module Minitest
2
2
  module SkipPlugin
3
+ # Patch runnable.run(reporter, options) so that it
4
+ # recognizes `skip_` methods and records them as skips
3
5
  def run(reporter, options = {})
4
6
  super
5
7
  methods_matching(/^skip_/).each do |method_name|
6
- test = self.new(method_name)
8
+ # Minitest 5.13 added skip_until as a default method.
9
+ next if method_name == "skip_until"
10
+
11
+ test = new(method_name)
7
12
  test.time = 0
8
13
 
9
14
  skip = Skip.new("Skipped from SkipPlugin")
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "minitest-skip"
7
- spec.version = "0.0.1"
7
+ spec.version = "0.0.2"
8
8
  spec.authors = ["Ivan Tse"]
9
9
  spec.email = ["ivan.tse1@gmail.com"]
10
10
  spec.summary = %q{Alternative ways to skip tests in Minitest}
@@ -53,4 +53,21 @@ class TestSkipDSL < Minitest::Test
53
53
 
54
54
  assert_includes @output.string.dup, "4 runs, 1 assertions, 0 failures, 0 errors, 3 skips"
55
55
  end
56
+
57
+ def test_skip_macro
58
+ test = describe "Test" do
59
+ skip def test_something
60
+ assert false
61
+ end
62
+
63
+ def test_something_else
64
+ assert false
65
+ end
66
+ skip :test_something_else
67
+ end
68
+ test.run(@reporter)
69
+ @reporter.report
70
+
71
+ assert_includes @output.string.dup, "2 runs, 0 assertions, 0 failures, 0 errors, 2 skips"
72
+ end
56
73
  end
@@ -32,12 +32,10 @@ class TestSkipMethods < Minitest::Test
32
32
  @reporter.report
33
33
 
34
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
-
35
+ assert_includes @output.string.dup, "1) Skipped:"
36
+ assert_includes @output.string.dup, "ExampleSkipTest#skip_test_name"
37
+ assert_includes @output.string.dup, "test/test_skip_methods.rb:8"
38
+ assert_includes @output.string.dup, "Skipped from SkipPlugin"
41
39
  end
42
40
 
43
41
  def test_skip_methods_are_recorded
@@ -47,7 +45,7 @@ class TestSkipMethods < Minitest::Test
47
45
  assert result.skipped?
48
46
  assert_equal Minitest::Skip, failure.error.class
49
47
  assert_equal "Skipped from SkipPlugin", failure.error.message
50
- assert_equal "test/test_skip_methods.rb:8", failure.location
48
+ assert_includes failure.location, "test/test_skip_methods.rb:8"
51
49
  end
52
50
 
53
51
  def test_skip_methods_are_not_executed
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minitest-skip
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Tse
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-23 00:00:00.000000000 Z
11
+ date: 2020-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -89,8 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
89
89
  - !ruby/object:Gem::Version
90
90
  version: '0'
91
91
  requirements: []
92
- rubyforge_project:
93
- rubygems_version: 2.2.2
92
+ rubygems_version: 3.0.3
94
93
  signing_key:
95
94
  specification_version: 4
96
95
  summary: Alternative ways to skip tests in Minitest