test-this 0.1.0 → 0.2.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 +4 -4
- data/README.md +9 -12
- data/Rakefile +3 -4
- data/lib/test/this.rb +23 -24
- data/lib/test/this/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba031e894e7e5a4f9bd496fec9ff37992d7050dc
|
4
|
+
data.tar.gz: 59cdfda3604a63e38d53bca8ad2f6b28c3486df7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47bc7b07a50c6238f59dec3f8a526cfd7a24ad80bb175d890ea13224414f365ba0680708ddd2cda8a03186fb58bb7d2ced16d1603a12d38d260db36ea662c493
|
7
|
+
data.tar.gz: 596026362c0cd53b517df963f5ce8b40e4ca7fe356085e23d5b93b10cdc3d5670beb3da14d413e81bccabbaea5b423c8de2ee3661d51c275f42a4635441e1561
|
data/README.md
CHANGED
@@ -7,8 +7,7 @@ this instead:
|
|
7
7
|
|
8
8
|
$ rake test:this["models/the_model","this is the test"]
|
9
9
|
|
10
|
-
This works for both Rails and Minitest.
|
11
|
-
instructions on how to configure it.
|
10
|
+
This works for both Rails and Minitest.
|
12
11
|
|
13
12
|
## Installation
|
14
13
|
|
@@ -31,12 +30,10 @@ After you install the gem, add this to your Rakefile to use it:
|
|
31
30
|
```ruby
|
32
31
|
require 'test/this'
|
33
32
|
|
34
|
-
|
35
|
-
Test::This.tap do |config|
|
33
|
+
Test::This.configure do |config|
|
36
34
|
config.file_suffix = '_test.rb'
|
37
|
-
config.
|
38
|
-
config.
|
39
|
-
config.test_path = File.join(Dir.pwd, 'test')
|
35
|
+
config.test_method_prefix = 'test_'
|
36
|
+
config.test_path = File.expand_path('../test', __FILE__)
|
40
37
|
end
|
41
38
|
```
|
42
39
|
|
@@ -51,12 +48,12 @@ To test all of the tests in a class full of tests you want to run:
|
|
51
48
|
$ rake test:this["controllers/this_controller"]
|
52
49
|
|
53
50
|
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
|
51
|
+
the prefixed `test_` in the name of the test methods for Minitest. For example,
|
55
52
|
if your Minitest case looked like this:
|
56
53
|
|
57
54
|
```ruby
|
58
|
-
# file: test/
|
59
|
-
class
|
55
|
+
# file: test/something_test.rb
|
56
|
+
class SomethingTest < Minitest::Test
|
60
57
|
def test_the_test_to_run
|
61
58
|
assert true
|
62
59
|
end
|
@@ -69,9 +66,9 @@ end
|
|
69
66
|
|
70
67
|
To run the `test_the_test_to_run`:
|
71
68
|
|
72
|
-
$ rake test:this["
|
69
|
+
$ rake test:this["something","the test to run"]
|
73
70
|
|
74
|
-
|
71
|
+
Spaces will automatically be converted to underscores.
|
75
72
|
|
76
73
|
## Contributing
|
77
74
|
|
data/Rakefile
CHANGED
@@ -2,11 +2,10 @@ require 'bundler/gem_tasks'
|
|
2
2
|
require 'rake/testtask'
|
3
3
|
require 'test/this'
|
4
4
|
|
5
|
-
Test::This.
|
5
|
+
Test::This.configure do |config|
|
6
6
|
config.file_suffix = '_test.rb'
|
7
|
-
config.
|
8
|
-
config.
|
9
|
-
config.test_path = File.join(Dir.pwd, 'test')
|
7
|
+
config.test_method_prefix = 'test_'
|
8
|
+
config.test_path = File.expand_path('../test', __FILE__)
|
10
9
|
end
|
11
10
|
|
12
11
|
Rake::TestTask.new(:test) do |t|
|
data/lib/test/this.rb
CHANGED
@@ -3,32 +3,38 @@ require 'test/this/task'
|
|
3
3
|
|
4
4
|
module Test
|
5
5
|
# @!attribute file_suffix
|
6
|
-
#
|
7
|
-
#
|
6
|
+
# Test files are typically suffixed with either `_test.rb` or `_spec.rb`.
|
7
|
+
# This attribute allows you to specify what file suffix your tests use.
|
8
|
+
#
|
9
|
+
# @return [String] A file suffix - defaults to "_test.rb".
|
10
|
+
#
|
11
|
+
# @!attribute test_method_prefix
|
12
|
+
# Minitest methods are prefixed with `test_`. The Rails `test` method
|
13
|
+
# generates tests for Minitest that have the same prefix. This might not
|
14
|
+
# apply to all test suites, so it can be configured when necessary.
|
15
|
+
#
|
16
|
+
# @return [String] Prefix for test methods.
|
17
|
+
#
|
8
18
|
# @!attribute test_path
|
19
|
+
# The full path to the root of the tests. This defaults to using the
|
20
|
+
# current directory that the task was called from.
|
21
|
+
#
|
22
|
+
# @return [String] Full path to the tests.
|
9
23
|
module This
|
10
24
|
autoload :VERSION, 'test/this/version'
|
11
25
|
|
12
26
|
class << self
|
13
|
-
|
27
|
+
attr_writer :file_suffix, :test_method_prefix, :test_path
|
28
|
+
|
29
|
+
alias_method :configure, :tap
|
14
30
|
end
|
15
31
|
|
16
32
|
def self.file_suffix
|
17
33
|
@file_suffix ||= '_test.rb'
|
18
34
|
end
|
19
35
|
|
20
|
-
def self.
|
21
|
-
@
|
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}"
|
36
|
+
def self.test_method_prefix
|
37
|
+
@test_method_prefix ||= 'test_'
|
32
38
|
end
|
33
39
|
|
34
40
|
def self.test_path
|
@@ -37,10 +43,9 @@ module Test
|
|
37
43
|
|
38
44
|
def self.execute(path, name=nil)
|
39
45
|
path = get_test_path(path)
|
40
|
-
name = get_test_name(name)
|
41
46
|
|
42
47
|
command = %Q[ruby -I"lib:test" #{path}]
|
43
|
-
command << " -n #{name}" unless name.nil?
|
48
|
+
command << " -n #{get_test_name(name)}" unless name.nil?
|
44
49
|
|
45
50
|
system command
|
46
51
|
end
|
@@ -50,13 +55,7 @@ module Test
|
|
50
55
|
end
|
51
56
|
|
52
57
|
def self.get_test_name(name)
|
53
|
-
|
54
|
-
|
55
|
-
case suite
|
56
|
-
when :rails then name
|
57
|
-
when :minitest then "#{minitest_method_prefix}#{name.gsub(' ', '_')}"
|
58
|
-
else fail
|
59
|
-
end
|
58
|
+
"#{test_method_prefix}#{name.gsub(' ', '_')}"
|
60
59
|
end
|
61
60
|
end
|
62
61
|
end
|
data/lib/test/this/version.rb
CHANGED