minitest-fail 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ddb39085a6146f7255196d01fd1877c34b2f279a
4
+ data.tar.gz: 05723b0d8a3bb8da38c09d88b98f704e2fbc52cb
5
+ SHA512:
6
+ metadata.gz: 8f1fadc43407750458d8df4dc2e113c7972605f1f8f92458092412c3567fe47fb256e386e2c72f3f193744d80f8d70f0a16756f02d1121b6193dae5182729d15
7
+ data.tar.gz: b8944ff53fea7f40412c79d23212fc347e6722a152f72aacfe6433e71a79cfdb1b0f5df15d68db84345019a292488765c334c962c27c5bc26bfd14018cd7a906
data/.gitignore ADDED
@@ -0,0 +1,17 @@
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
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in minitest-documentation.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Teo Ljungberg
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,35 @@
1
+ # Minitest::Fail
2
+
3
+ This plugin makes an empty test fail in
4
+ [minitest](https://github.com/seattlerb/minitest)
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ gem 'minitest-fail'
11
+
12
+ And then execute:
13
+
14
+ $ bundle
15
+
16
+ Or install it yourself as:
17
+
18
+ $ gem install minitest-fail
19
+
20
+ ## Requirements
21
+
22
+ Minitest >= 5.0.0
23
+
24
+ ## Usage
25
+
26
+ Pass `--fail` as an argument while running your tests or require
27
+ '`minitest/fail` in your tests.
28
+
29
+ ## Contributing
30
+
31
+ 1. Fork it ( http://github.com/teoljungberg/minitest-documentation/fork )
32
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
33
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
34
+ 4. Push to the branch (`git push origin my-new-feature`)
35
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new do |t|
5
+ ENV["RUBYOPT"] = "-w"
6
+ t.pattern = "test/**/*_test.rb"
7
+ t.libs << "test"
8
+ end
9
+ task :default => :test
@@ -0,0 +1,4 @@
1
+ require 'minitest'
2
+
3
+ Minitest.load_plugins
4
+ Minitest::Fail.fail!
@@ -0,0 +1,38 @@
1
+ module Minitest
2
+ def self.plugin_fail_options opts, options
3
+ opts.on "--fail", "Fail on an empty test" do
4
+ Fail.fail!
5
+ end
6
+ end
7
+
8
+ def self.plugin_fail_init options = {}
9
+ if Fail.fail?
10
+ filtered_reporters = self.reporter.reporters.dup
11
+ filtered_reporters.reject! {|rep| rep.is_a? ProgressReporter }
12
+ filtered_reporters.each {|rep| rep.send :extend, Fail }
13
+ end
14
+ end
15
+
16
+ module Fail
17
+ def self.fail!
18
+ @fail = true
19
+ end
20
+
21
+ def self.fail?
22
+ @fail ||= false
23
+ end
24
+
25
+ def record result
26
+ super
27
+ if result.assertions.zero?
28
+ empty_test = result.method(result.name).source_location
29
+ e = ::Minitest::Assertion.new "Empty test #{result}"
30
+
31
+ e.class.send :define_method, :location, -> { empty_test.join(":") }
32
+
33
+ result.failures << e
34
+ self.results << result
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,19 @@
1
+ # coding: utf-8
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "minitest-fail"
5
+ spec.version = "0.0.2"
6
+ spec.authors = ["Teo Ljungberg"]
7
+ spec.email = ["teo.ljungberg@gmail.com"]
8
+ spec.summary = %q{Make an empty test fail}
9
+ spec.description = spec.summary
10
+ spec.homepage = "https://github.com/teoljungberg/minitest-fail"
11
+ spec.license = "MIT"
12
+
13
+ spec.files = `git ls-files`.split($/)
14
+ spec.require_paths = ["lib"]
15
+
16
+ spec.add_dependency "minitest", "~> 5.2"
17
+ spec.add_development_dependency "bundler", "~> 1.5"
18
+ spec.add_development_dependency "rake"
19
+ end
@@ -0,0 +1,46 @@
1
+ require_relative 'test_case'
2
+ require 'minitest/fail'
3
+
4
+ module Minitest
5
+ class FailTest < TestCase
6
+ def test_fail_eh
7
+ fail_off!
8
+ refute Fail.fail?
9
+ end
10
+
11
+ def test_fail_bang
12
+ activate_fail!
13
+ assert Fail.fail?
14
+ ensure
15
+ fail_off!
16
+ end
17
+ end
18
+
19
+ class FailIntegrationTest < TestCase
20
+ def test_integration_represent_empty_tests_as_failures
21
+ activate_fail!
22
+
23
+ reporter.start
24
+ reporter.record example_test.new(:test_empty).run
25
+ reporter.report
26
+
27
+ exp_error = %r(Empty test #<Class:(.*)>#test_empty)
28
+
29
+ assert_match exp_error, io.string
30
+ ensure
31
+ fail_off!
32
+ end
33
+
34
+ def test_integration_fail_needs_to_be_activated
35
+ fail_off!
36
+
37
+ reporter.start
38
+ reporter.record example_test.new(:test_empty).run
39
+ reporter.report
40
+
41
+ exp_error = %r(Empty test, #<Class:(.*)>#test_empty)
42
+
43
+ refute_match exp_error, io.string
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,42 @@
1
+ require 'minitest/autorun'
2
+ require 'stringio'
3
+
4
+ $:<< File.join(File.dirname(__FILE__), '../../lib')
5
+
6
+ module Minitest
7
+ class TestCase < Test
8
+ def setup
9
+ self.reporter = CompositeReporter.new
10
+ self.reporter << SummaryReporter.new(io)
11
+ self.reporter << ProgressReporter.new(io)
12
+ end
13
+ attr_accessor :reporter
14
+
15
+ private
16
+
17
+ def io
18
+ @io ||= StringIO.new ""
19
+ end
20
+
21
+ def example_test
22
+ @example_test ||= Class.new(Minitest::Test) {
23
+ def test_pass
24
+ assert 1
25
+ end
26
+
27
+ def test_empty
28
+ end
29
+ }
30
+ end
31
+
32
+ def fail_off!
33
+ Fail.instance_variable_set("@fail", false)
34
+ end
35
+
36
+ def activate_fail!
37
+ Fail.fail!
38
+ self.reporter.reporters.reject! { |rep| rep.is_a? ProgressReporter }
39
+ self.reporter.reporters.each { |rep| rep.send :extend, Fail }
40
+ end
41
+ end
42
+ end
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: minitest-fail
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Teo Ljungberg
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-04-06 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.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '5.2'
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.5'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.5'
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
+ description: Make an empty test fail
56
+ email:
57
+ - teo.ljungberg@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/fail.rb
68
+ - lib/minitest/fail_plugin.rb
69
+ - minitest-fail.gemspec
70
+ - test/minitest/fail_test.rb
71
+ - test/minitest/test_case.rb
72
+ homepage: https://github.com/teoljungberg/minitest-fail
73
+ licenses:
74
+ - MIT
75
+ metadata: {}
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirements: []
91
+ rubyforge_project:
92
+ rubygems_version: 2.2.2
93
+ signing_key:
94
+ specification_version: 4
95
+ summary: Make an empty test fail
96
+ test_files: []