test-this 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d979099f3f759db0e4b1be760f9e911e4a916543
4
- data.tar.gz: 4cf46963314cdada92a606de788431e541bc233c
3
+ metadata.gz: ba031e894e7e5a4f9bd496fec9ff37992d7050dc
4
+ data.tar.gz: 59cdfda3604a63e38d53bca8ad2f6b28c3486df7
5
5
  SHA512:
6
- metadata.gz: 470dc805f79a41319bb5a9573188b76ea21587c8ffd27ec3bcf42563f8627b157a6d044205ac59e898d67c12d1ce49a534e61537069cef668e24ebfbd717a8e9
7
- data.tar.gz: 03f0f31862e31291a26e6e0e0d00bc182180a98694e6a718238ce3dd824e0539663453b3bfde77cad308e8162bf3ad97630196b28ae568a0d549df207f2e9e62
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. See the installation below for
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
- # These are the default configuration values.
35
- Test::This.tap do |config|
33
+ Test::This.configure do |config|
36
34
  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')
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 minitest. For example,
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/some_test.rb
59
- class SomeTest < Minitest::Test
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["some_test","the test to run"]
69
+ $ rake test:this["something","the test to run"]
73
70
 
74
- In MiniTest mode it will automatically convert the spaces to underscores.
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.tap do |config|
5
+ Test::This.configure do |config|
6
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')
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|
@@ -3,32 +3,38 @@ require 'test/this/task'
3
3
 
4
4
  module Test
5
5
  # @!attribute file_suffix
6
- # @!attribute minitest_method_prefix
7
- # @!attribute suite
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
- attr_accessor :file_suffix, :minitest_method_prefix, :test_path
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.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}"
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
- 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
58
+ "#{test_method_prefix}#{name.gsub(' ', '_')}"
60
59
  end
61
60
  end
62
61
  end
@@ -1,5 +1,5 @@
1
1
  module Test
2
2
  module This
3
- VERSION = '0.1.0'
3
+ VERSION = '0.2.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test-this
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Travis Haynes