test-this 0.1.0
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 +7 -0
- data/.gitignore +10 -0
- data/.travis.yml +5 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +21 -0
- data/README.md +84 -0
- data/Rakefile +18 -0
- data/lib/test/this/task.rb +17 -0
- data/lib/test/this/version.rb +5 -0
- data/lib/test/this.rb +62 -0
- data/test-this.gemspec +33 -0
- metadata +96 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d979099f3f759db0e4b1be760f9e911e4a916543
|
4
|
+
data.tar.gz: 4cf46963314cdada92a606de788431e541bc233c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 470dc805f79a41319bb5a9573188b76ea21587c8ffd27ec3bcf42563f8627b157a6d044205ac59e898d67c12d1ce49a534e61537069cef668e24ebfbd717a8e9
|
7
|
+
data.tar.gz: 03f0f31862e31291a26e6e0e0d00bc182180a98694e6a718238ce3dd824e0539663453b3bfde77cad308e8162bf3ad97630196b28ae568a0d549df207f2e9e62
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Travis Haynes
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# Test::This
|
2
|
+
|
3
|
+
Often I want to run just one test in a class full of other tests. I usually
|
4
|
+
end up just commenting out everything except for the one test I want to run,
|
5
|
+
but that's kind of lame, so I decided to write a Rake test that lets me do
|
6
|
+
this instead:
|
7
|
+
|
8
|
+
$ rake test:this["models/the_model","this is the test"]
|
9
|
+
|
10
|
+
This works for both Rails and Minitest. See the installation below for
|
11
|
+
instructions on how to configure it.
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
Add this line to your application's Gemfile:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
gem 'test-this'
|
19
|
+
```
|
20
|
+
|
21
|
+
And then execute:
|
22
|
+
|
23
|
+
$ bundle
|
24
|
+
|
25
|
+
Or install it yourself as:
|
26
|
+
|
27
|
+
$ gem install test-this
|
28
|
+
|
29
|
+
After you install the gem, add this to your Rakefile to use it:
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
require 'test/this'
|
33
|
+
|
34
|
+
# These are the default configuration values.
|
35
|
+
Test::This.tap do |config|
|
36
|
+
config.file_suffix = '_test.rb'
|
37
|
+
config.minitest_method_prefix = 'test_'
|
38
|
+
config.suite = :rails # or :minitest
|
39
|
+
config.test_path = File.join(Dir.pwd, 'test')
|
40
|
+
end
|
41
|
+
```
|
42
|
+
|
43
|
+
## Usage
|
44
|
+
|
45
|
+
To run a single test from a class full of other tests you don't want to run:
|
46
|
+
|
47
|
+
$ rake test:this["controllers/this_controller","the name of the test"]
|
48
|
+
|
49
|
+
To test all of the tests in a class full of tests you want to run:
|
50
|
+
|
51
|
+
$ rake test:this["controllers/this_controller"]
|
52
|
+
|
53
|
+
Note that you can leave off the trailing `_test.rb` in the name of the test and
|
54
|
+
the prefixed `test_` in the name of the test methods for minitest. For example,
|
55
|
+
if your Minitest case looked like this:
|
56
|
+
|
57
|
+
```ruby
|
58
|
+
# file: test/some_test.rb
|
59
|
+
class SomeTest < Minitest::Test
|
60
|
+
def test_the_test_to_run
|
61
|
+
assert true
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_not_the_test_to_run
|
65
|
+
fail
|
66
|
+
end
|
67
|
+
end
|
68
|
+
```
|
69
|
+
|
70
|
+
To run the `test_the_test_to_run`:
|
71
|
+
|
72
|
+
$ rake test:this["some_test","the test to run"]
|
73
|
+
|
74
|
+
In MiniTest mode it will automatically convert the spaces to underscores.
|
75
|
+
|
76
|
+
## Contributing
|
77
|
+
|
78
|
+
Bug reports and pull requests are welcome on GitHub at
|
79
|
+
[hi5dev/test-this](https://github.com/hi5dev/test-this).
|
80
|
+
|
81
|
+
## License
|
82
|
+
|
83
|
+
The gem is available as open source under the terms of the
|
84
|
+
[MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'test/this'
|
4
|
+
|
5
|
+
Test::This.tap do |config|
|
6
|
+
config.file_suffix = '_test.rb'
|
7
|
+
config.minitest_method_prefix = 'test_'
|
8
|
+
config.suite = :minitest
|
9
|
+
config.test_path = File.join(Dir.pwd, 'test')
|
10
|
+
end
|
11
|
+
|
12
|
+
Rake::TestTask.new(:test) do |t|
|
13
|
+
t.libs << 'test'
|
14
|
+
t.libs << 'lib'
|
15
|
+
t.test_files = FileList['test/**/*_test.rb']
|
16
|
+
end
|
17
|
+
|
18
|
+
task default: :test
|
@@ -0,0 +1,17 @@
|
|
1
|
+
namespace :test do
|
2
|
+
desc 'Run one test by name'
|
3
|
+
task :this, [:path, :test_name] do |t, args|
|
4
|
+
if args.count > 0
|
5
|
+
# run the test if at least one of the arguments is present
|
6
|
+
Test::This.execute(args[:path], args[:test_name])
|
7
|
+
else
|
8
|
+
# print the syntax of the task since no arguments were given
|
9
|
+
$stderr.puts 'Syntax: rake test:one["PATH","TEST NAME"]'
|
10
|
+
$stderr.puts 'Make sure not to include any spaces between the arguments.'
|
11
|
+
$stderr.puts 'The name of the test is optional.'
|
12
|
+
|
13
|
+
# exit with status 2
|
14
|
+
exit(2)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/test/this.rb
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'test/this/task'
|
3
|
+
|
4
|
+
module Test
|
5
|
+
# @!attribute file_suffix
|
6
|
+
# @!attribute minitest_method_prefix
|
7
|
+
# @!attribute suite
|
8
|
+
# @!attribute test_path
|
9
|
+
module This
|
10
|
+
autoload :VERSION, 'test/this/version'
|
11
|
+
|
12
|
+
class << self
|
13
|
+
attr_accessor :file_suffix, :minitest_method_prefix, :test_path
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.file_suffix
|
17
|
+
@file_suffix ||= '_test.rb'
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.minitest_method_prefix
|
21
|
+
@minitest_method_prefix ||= 'test_'
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.suite
|
25
|
+
@suite ||= :rails
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.suite=(value)
|
29
|
+
return @suite = value if [:rails, :minitest].include?(value)
|
30
|
+
|
31
|
+
fail ArgumentError, "unknown test suite: #{value}"
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.test_path
|
35
|
+
@test_path ||= File.join(Dir.pwd, 'test')
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.execute(path, name=nil)
|
39
|
+
path = get_test_path(path)
|
40
|
+
name = get_test_name(name)
|
41
|
+
|
42
|
+
command = %Q[ruby -I"lib:test" #{path}]
|
43
|
+
command << " -n #{name}" unless name.nil?
|
44
|
+
|
45
|
+
system command
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.get_test_path(path)
|
49
|
+
File.join(test_path, "#{path}#{file_suffix}")
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.get_test_name(name)
|
53
|
+
return if "#{name}".empty?
|
54
|
+
|
55
|
+
case suite
|
56
|
+
when :rails then name
|
57
|
+
when :minitest then "#{minitest_method_prefix}#{name.gsub(' ', '_')}"
|
58
|
+
else fail
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
data/test-this.gemspec
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
lib = File.expand_path('../lib', __FILE__)
|
4
|
+
|
5
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
6
|
+
|
7
|
+
require 'test/this/version'
|
8
|
+
|
9
|
+
Gem::Specification.new do |spec|
|
10
|
+
spec.name = 'test-this'
|
11
|
+
spec.version = Test::This::VERSION
|
12
|
+
spec.authors = ['Travis Haynes']
|
13
|
+
spec.email = ['travis@hi5dev.com']
|
14
|
+
|
15
|
+
spec.summary = 'Use Rake to run one test in a class.'
|
16
|
+
spec.homepage = 'https://github.com/hi5dev/test-this'
|
17
|
+
spec.license = 'MIT'
|
18
|
+
|
19
|
+
spec.bindir = 'exe'
|
20
|
+
spec.require_paths = %w[lib]
|
21
|
+
|
22
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |file|
|
23
|
+
file.match(%r{^(test|spec|features)/})
|
24
|
+
end
|
25
|
+
|
26
|
+
spec.executables = spec.files.grep(%r{^#{spec.bindir}/}) do |file|
|
27
|
+
File.basename(file)
|
28
|
+
end
|
29
|
+
|
30
|
+
spec.add_development_dependency 'bundler', '~> 1.12'
|
31
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
32
|
+
spec.add_development_dependency 'minitest', '~> 5.0'
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: test-this
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Travis Haynes
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-08-16 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.12'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.12'
|
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: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.0'
|
55
|
+
description:
|
56
|
+
email:
|
57
|
+
- travis@hi5dev.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".travis.yml"
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- lib/test/this.rb
|
69
|
+
- lib/test/this/task.rb
|
70
|
+
- lib/test/this/version.rb
|
71
|
+
- test-this.gemspec
|
72
|
+
homepage: https://github.com/hi5dev/test-this
|
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.5.1
|
93
|
+
signing_key:
|
94
|
+
specification_version: 4
|
95
|
+
summary: Use Rake to run one test in a class.
|
96
|
+
test_files: []
|