minitest-names 0.1.0

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: 4c933c61847da19e3b8fbcd1d08d1fa28e1bc675
4
+ data.tar.gz: 83c0f5d096e9aabc57b3100314c1026d5f9d966c
5
+ SHA512:
6
+ metadata.gz: 82cc5c82787016013c76ebd82b611f84080ed513bbc40fa43b0e1f03d69091156f9791406cade0aea36211770f7fec1c3e8734b3d83f166ae4c73aeda93cea7a
7
+ data.tar.gz: 92ec9f90146818d6e65594d80dd33f34c55f749a529c22d688cdfe2c37c7aefbec4f7ccd51586a5eb029681394007896952f2334262f8bbe9ae427460e792d25
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.3
4
+ - 2.1.7
5
+ - 2.0.0
6
+
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in minitest-listnames.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Masami Ichikawa
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.
@@ -0,0 +1,51 @@
1
+ [![Build Status](https://travis-ci.org/masami256/minitest-names.svg?branch=master)](https://travis-ci.org/masami256/minitest-names)
2
+
3
+ # minitest-names
4
+
5
+ It supports to run multiple testcases by it testcase names.
6
+ The minitest supports regular expression to run some testcases with -n/--name option. However, sometime it's difficult to make regular expression for test.
7
+ So, it would be nice to have a feature passing testcase names to run tests.
8
+
9
+ minitest-names doesn't support regular expression.
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ ```ruby
16
+ gem 'minitest-names'
17
+ ```
18
+
19
+ And then execute:
20
+
21
+ $ bundle
22
+
23
+ Or install it yourself as:
24
+
25
+ $ gem install minitest-names
26
+
27
+ ## Usage
28
+
29
+ To pass testcase name which separated by comma.
30
+
31
+
32
+ Using short option.
33
+ ```
34
+ $ rake TESTOPTS="-N=\"test_say_hello, test_say_kiaora\""
35
+ ```
36
+
37
+ Using long option.
38
+ ```
39
+ rake TESTOPTS="--names=\"test_say_hello, test_say_kiaora\""
40
+ ```
41
+
42
+ In the TESTOPTS option, you need to escape double quotation.
43
+
44
+
45
+ ## Contributing
46
+
47
+ 1. Fork it ( https://github.com/[my-github-username]/minitest-names/fork )
48
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
49
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
50
+ 4. Push to the branch (`git push origin my-new-feature`)
51
+ 5. Create a new Pull Request
@@ -0,0 +1,9 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ end
7
+
8
+ task :default => :test
9
+
@@ -0,0 +1,6 @@
1
+ module Minitest
2
+ # :nodoc:
3
+ module Names
4
+ VERSION = "0.1.0"
5
+ end
6
+ end
@@ -0,0 +1,48 @@
1
+ require "minitest/names/version"
2
+
3
+ module Minitest
4
+ module Names
5
+ module NamesExtendedRunnable
6
+ def self.included base
7
+ base.instance_eval do
8
+ def self.run reporter, options = {}
9
+ names = options[:filter]
10
+
11
+ return if names.nil? || names.empty?
12
+
13
+ filtered_methods = []
14
+
15
+ names.each do |name|
16
+ tmp = self.runnable_methods.find_all { |m|
17
+ name === m || name === "#{self}##{m}"
18
+ }
19
+ filtered_methods += tmp
20
+ end
21
+
22
+ return if filtered_methods.empty?
23
+
24
+ with_info_handler reporter do
25
+ filtered_methods.each do |method_name|
26
+ run_one_method self, method_name, reporter
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+
35
+ def self.plugin_names_options(opts, options)
36
+ opts.on '-N', '--names names', String, 'list test case names separated by commans' do |names|
37
+ options[:names] = names
38
+ end
39
+ end
40
+
41
+ def self.plugin_names_init(options)
42
+ return unless names = options[:names]
43
+
44
+ # Override Runnable class if names option is set
45
+ Minitest::Runnable.send(:include, Minitest::Names::NamesExtendedRunnable)
46
+ options[:filter] = names.split(',').map {|name| name.strip }
47
+ end
48
+ 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/names/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "minitest-names"
8
+ spec.version = Minitest::Names::VERSION
9
+ spec.authors = ["Masami Ichikawa"]
10
+ spec.email = ["ichikawa-masami@dmm.com"]
11
+ spec.summary = %q{Run tests by test names.}
12
+ spec.description = %q{Run test by test names. Test names are passed by command line aregument which is separated by commas.}
13
+ spec.homepage = "https://github.com/DMMcomLabo/minitest-names"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "minitest"
24
+ end
@@ -0,0 +1,4 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+
3
+ require 'minitest/names/version'
4
+ require 'minitest/autorun'
@@ -0,0 +1,114 @@
1
+ require 'minitest_helper'
2
+ require 'stringio'
3
+
4
+ class TestNames < Minitest::Unit::TestCase
5
+
6
+ def setup
7
+ @tc1 = Class.new Minitest::Test do
8
+ define_method :test_say_hello do
9
+ pass
10
+ end
11
+ define_method :test_say_kiaora do
12
+ pass
13
+ end
14
+ define_method :test_say_goodbye do
15
+ assert false
16
+ end
17
+ end
18
+
19
+ @tc2 = Class.new Minitest::Test do
20
+ define_method :test_say_hello do
21
+ pass
22
+ end
23
+ end
24
+ end
25
+
26
+ def test_that_it_has_a_version_number
27
+ refute_nil MiniTest::Names::VERSION
28
+ end
29
+
30
+ def test_run_test_by_names
31
+ args = ['--names', 'test_say_goodbye']
32
+ options = Minitest.process_args args
33
+
34
+ Object.const_set(:Hello1, @tc1)
35
+
36
+ tcs = [@tc1]
37
+
38
+ expected = {
39
+ :count => 1,
40
+ :failures => 1,
41
+ :filter => ['test_say_goodbye']
42
+ }
43
+ result = run_test options, tcs
44
+ assert_result expected, result
45
+ ensure
46
+ Object.send :remove_const, :Hello1
47
+ end
48
+
49
+ def test_run_tests_by_names
50
+ args = ['--names', 'test_say_hello, test_say_kiaora']
51
+ options = Minitest.process_args args
52
+
53
+ Object.const_set(:Hello1, @tc1)
54
+
55
+ tcs = [@tc1]
56
+
57
+ expected = {
58
+ :count => 2,
59
+ :failures => 0,
60
+ :filter => ['test_say_hello', 'test_say_kiaora']
61
+ }
62
+ result = run_test options, tcs
63
+ assert_result expected, result
64
+ ensure
65
+ Object.send :remove_const, :Hello1
66
+ end
67
+
68
+ def test_run_tests_by_name
69
+ args = ['--names', 'test_say_hello']
70
+ options = Minitest.process_args args
71
+
72
+ Object.const_set(:Hello1, @tc1)
73
+ Object.const_set(:Hello2, @tc2)
74
+
75
+ tcs = [@tc1, @tc2]
76
+
77
+ expected = {
78
+ :count => 2,
79
+ :failures => 0,
80
+ :filter => ['test_say_hello']
81
+ }
82
+ result = run_test options, tcs
83
+ assert_result expected, result
84
+ ensure
85
+ Object.send :remove_const, :Hello1
86
+ Object.send :remove_const, :Hello2
87
+ end
88
+
89
+ private
90
+
91
+ def run_test options, tcs
92
+ Minitest.plugin_names_init(options)
93
+
94
+ output = StringIO.new
95
+ reporter = Minitest::CompositeReporter.new
96
+ reporter << Minitest::SummaryReporter.new(output, options)
97
+ reporter << Minitest::ProgressReporter.new(output, options)
98
+
99
+ reporter.start
100
+
101
+ tcs.each do |tc|
102
+ Minitest::Runnable.runnables.delete tc
103
+ tc.run reporter, options
104
+ end
105
+
106
+ reporter.report[0]
107
+ end
108
+
109
+ def assert_result expected, actual
110
+ assert_equal expected[:count], actual.count
111
+ assert_equal expected[:failures], actual.failures
112
+ assert_equal expected[:filter], actual.options[:filter]
113
+ end
114
+ end
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: minitest-names
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Masami Ichikawa
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-12-02 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: '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: Run test by test names. Test names are passed by command line aregument
56
+ which is separated by commas.
57
+ email:
58
+ - ichikawa-masami@dmm.com
59
+ executables: []
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - ".travis.yml"
65
+ - Gemfile
66
+ - LICENSE.txt
67
+ - README.md
68
+ - Rakefile
69
+ - lib/minitest/names/version.rb
70
+ - lib/minitest/names_plugin.rb
71
+ - minitest-names.gemspec
72
+ - test/minitest_helper.rb
73
+ - test/test_names.rb
74
+ homepage: https://github.com/DMMcomLabo/minitest-names
75
+ licenses:
76
+ - MIT
77
+ metadata: {}
78
+ post_install_message:
79
+ rdoc_options: []
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ requirements: []
93
+ rubyforge_project:
94
+ rubygems_version: 2.4.5.1
95
+ signing_key:
96
+ specification_version: 4
97
+ summary: Run tests by test names.
98
+ test_files:
99
+ - test/minitest_helper.rb
100
+ - test/test_names.rb