minitest-spec-rails 5.0.0 → 7.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/ci.yml +36 -0
- data/.gitignore +1 -2
- data/.rubocop.yml +26 -0
- data/Appraisals +13 -1
- data/CHANGELOG.md +130 -46
- data/CODE_OF_CONDUCT.md +31 -0
- data/Gemfile +0 -4
- data/README.md +63 -67
- data/Rakefile +6 -14
- data/gemfiles/rails_v6.0.x.gemfile +8 -0
- data/gemfiles/rails_v6.0.x.gemfile.lock +172 -0
- data/gemfiles/rails_v6.1.x.gemfile +8 -0
- data/gemfiles/rails_v6.1.x.gemfile.lock +175 -0
- data/gemfiles/rails_v7.0.x.gemfile +8 -0
- data/gemfiles/rails_v7.0.x.gemfile.lock +174 -0
- data/gemfiles/rails_v7.1.x.gemfile +9 -0
- data/lib/minitest-spec-rails/dsl.rb +6 -10
- data/lib/minitest-spec-rails/init/action_cable.rb +28 -0
- data/lib/minitest-spec-rails/init/action_controller.rb +3 -7
- data/lib/minitest-spec-rails/init/action_dispatch.rb +1 -3
- data/lib/minitest-spec-rails/init/action_mailer.rb +2 -7
- data/lib/minitest-spec-rails/init/action_view.rb +1 -5
- data/lib/minitest-spec-rails/init/active_job.rb +24 -0
- data/lib/minitest-spec-rails/init/active_support.rb +8 -11
- data/lib/minitest-spec-rails/init/mini_shoulda.rb +2 -6
- data/lib/minitest-spec-rails/parallelize.rb +30 -0
- data/lib/minitest-spec-rails/railtie.rb +24 -17
- data/lib/minitest-spec-rails/version.rb +1 -1
- data/minitest-spec-rails.gemspec +10 -9
- data/test/cases/action_cable_test.rb +38 -0
- data/test/cases/action_controller_test.rb +13 -16
- data/test/cases/action_dispatch_test.rb +18 -21
- data/test/cases/action_mailer_test.rb +13 -16
- data/test/cases/action_view_test.rb +17 -20
- data/test/cases/active_job_test.rb +46 -0
- data/test/cases/active_support_test.rb +28 -18
- data/test/cases/mini_shoulda_test.rb +6 -11
- data/test/dummy_app/app/assets/config/manifest.js +1 -0
- data/test/dummy_app/app/channels/application_cable/channel.rb +4 -0
- data/test/dummy_app/app/channels/application_cable/connection.rb +4 -0
- data/test/dummy_app/app/controllers/application_controller.rb +1 -3
- data/test/dummy_app/app/controllers/users_controller.rb +1 -3
- data/test/dummy_app/app/helpers/application_helper.rb +0 -1
- data/test/dummy_app/app/helpers/foos_helper.rb +3 -1
- data/test/dummy_app/app/helpers/users_helper.rb +1 -3
- data/test/dummy_app/app/mailers/user_mailer.rb +2 -4
- data/test/dummy_app/app/models/post.rb +0 -3
- data/test/dummy_app/app/models/user.rb +0 -3
- data/test/dummy_app/config/routes.rb +1 -1
- data/test/dummy_app/config/storage.yml +34 -0
- data/test/dummy_app/init.rb +18 -21
- data/test/dummy_app/tmp/development_secret.txt +1 -0
- data/test/dummy_tests/application_controller_test.rb +19 -25
- data/test/dummy_tests/{foo_helper_test.rb → foos_helper_test.rb} +2 -5
- data/test/dummy_tests/integration_test.rb +5 -11
- data/test/dummy_tests/library_test.rb +3 -3
- data/test/dummy_tests/special_users_controller_test.rb +10 -0
- data/test/dummy_tests/user_mailer_test.rb +24 -26
- data/test/dummy_tests/user_test.rb +15 -21
- data/test/dummy_tests/users_controller_test.rb +8 -4
- data/test/dummy_tests/users_helper_test.rb +15 -21
- data/test/support/shared_test_case_behavior.rb +4 -7
- data/test/test_helper.rb +1 -5
- data/test/test_helper_dummy.rb +5 -7
- metadata +87 -74
- data/.travis.yml +0 -11
- data/Guardfile +0 -7
- data/test/support/minitest.rb +0 -1
@@ -1,27 +1,22 @@
|
|
1
1
|
module MiniTestSpecRails
|
2
2
|
module Init
|
3
3
|
module ActionMailerBehavior
|
4
|
-
|
5
4
|
extend ActiveSupport::Concern
|
6
5
|
|
7
6
|
included do
|
8
|
-
register_spec_type(self) { |desc| Class
|
7
|
+
register_spec_type(self) { |desc| desc.is_a?(Class) && desc < ActionMailer::Base }
|
9
8
|
register_spec_type(/Mailer( ?Test)?\z/, self)
|
10
|
-
register_spec_type(self) { |desc| Class
|
9
|
+
register_spec_type(self) { |desc| desc.is_a?(Class) && desc < self }
|
11
10
|
extend Descriptions
|
12
11
|
end
|
13
12
|
|
14
13
|
module Descriptions
|
15
|
-
|
16
14
|
def described_class
|
17
15
|
determine_default_mailer(name)
|
18
16
|
end
|
19
|
-
|
20
17
|
end
|
21
|
-
|
22
18
|
end
|
23
19
|
end
|
24
20
|
end
|
25
21
|
|
26
22
|
ActionMailer::TestCase.send :include, MiniTestSpecRails::Init::ActionMailerBehavior
|
27
|
-
|
@@ -1,24 +1,20 @@
|
|
1
1
|
module MiniTestSpecRails
|
2
2
|
module Init
|
3
3
|
module ActionViewBehavior
|
4
|
-
|
5
4
|
extend ActiveSupport::Concern
|
6
5
|
|
7
6
|
included do
|
8
7
|
class_attribute :_helper_class
|
9
8
|
register_spec_type(/(Helper|View)( ?Test)?\z/, self)
|
10
|
-
register_spec_type(self) { |desc| Class
|
9
|
+
register_spec_type(self) { |desc| desc.is_a?(Class) && desc < self }
|
11
10
|
extend Descriptions
|
12
11
|
end
|
13
12
|
|
14
13
|
module Descriptions
|
15
|
-
|
16
14
|
def described_class
|
17
15
|
determine_default_helper_class(name)
|
18
16
|
end
|
19
|
-
|
20
17
|
end
|
21
|
-
|
22
18
|
end
|
23
19
|
end
|
24
20
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module MiniTestSpecRails
|
2
|
+
module Init
|
3
|
+
module ActiveJobBehavior
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
register_spec_type(self) { |desc| desc.is_a?(Class) && desc < ActiveJob::Base }
|
8
|
+
register_spec_type(/Job( ?Test)?\z/, self)
|
9
|
+
register_spec_type(self) { |desc| desc.is_a?(Class) && desc < self }
|
10
|
+
extend Descriptions
|
11
|
+
end
|
12
|
+
|
13
|
+
module Descriptions
|
14
|
+
def described_class
|
15
|
+
determine_constant_from_test_name(name) do |constant|
|
16
|
+
constant.is_a?(Class) && constant < ActiveJob::Base
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
ActiveJob::TestCase.send :include, MiniTestSpecRails::Init::ActiveJobBehavior
|
@@ -1,33 +1,30 @@
|
|
1
1
|
module MiniTestSpecRails
|
2
2
|
module Init
|
3
3
|
module ActiveSupportBehavior
|
4
|
-
|
5
4
|
extend ActiveSupport::Concern
|
6
5
|
|
7
6
|
included do
|
8
|
-
|
9
|
-
extend MiniTest::Spec::DSL
|
7
|
+
extend Minitest::Spec::DSL
|
10
8
|
include MiniTestSpecRails::DSL
|
11
9
|
include ActiveSupport::Testing::ConstantLookup
|
12
10
|
extend Descriptions
|
13
|
-
register_spec_type(self) { |desc| Class
|
11
|
+
register_spec_type(self) { |desc| desc.is_a?(Class) }
|
14
12
|
end
|
15
13
|
|
16
14
|
module Descriptions
|
17
|
-
|
18
15
|
def described_class
|
19
16
|
determine_constant_from_test_name(name) do |constant|
|
20
|
-
Class
|
17
|
+
constant.is_a?(Class)
|
21
18
|
end
|
22
19
|
end
|
23
|
-
|
24
20
|
end
|
25
21
|
|
26
|
-
|
27
|
-
|
28
|
-
|
22
|
+
if Minitest::VERSION < '5.3.3'
|
23
|
+
def initialize(*args)
|
24
|
+
Thread.current[:current_spec] = self
|
25
|
+
super
|
26
|
+
end
|
29
27
|
end
|
30
|
-
|
31
28
|
end
|
32
29
|
end
|
33
30
|
end
|
@@ -1,25 +1,21 @@
|
|
1
1
|
module MiniTestSpecRails
|
2
2
|
module Init
|
3
3
|
module MiniShouldaBehavior
|
4
|
-
|
5
4
|
extend ActiveSupport::Concern
|
6
5
|
|
7
6
|
included do
|
8
7
|
class << self
|
9
|
-
|
10
|
-
|
8
|
+
alias_method :context, :describe
|
9
|
+
alias_method :should, :it
|
11
10
|
end
|
12
11
|
extend ClassMethods
|
13
12
|
end
|
14
13
|
|
15
14
|
module ClassMethods
|
16
|
-
|
17
15
|
def should_eventually(desc)
|
18
16
|
it("should eventually #{desc}") { skip("Should eventually #{desc}") }
|
19
17
|
end
|
20
|
-
|
21
18
|
end
|
22
|
-
|
23
19
|
end
|
24
20
|
end
|
25
21
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
|
2
|
+
# HACK: stolen and altered from https://github.com/blowmage/minitest-rails/pull/218/files
|
3
|
+
# Which was referenced in https://github.com/metaskills/minitest-spec-rails/issues/94
|
4
|
+
|
5
|
+
module MiniTestSpecRails
|
6
|
+
##
|
7
|
+
# This module is a placeholder for all the Test classes created using the
|
8
|
+
# spec DSL. Normally all classes are created but not assigned to a constant.
|
9
|
+
# This module is where constants will be created for these classes.
|
10
|
+
module SpecTests #:nodoc:
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
module Kernel #:nodoc:
|
15
|
+
alias describe_before_minitest_spec_constant_fix describe
|
16
|
+
private :describe_before_minitest_spec_constant_fix
|
17
|
+
def describe *args, &block
|
18
|
+
cls = describe_before_minitest_spec_constant_fix(*args, &block)
|
19
|
+
cls_const = "Test__#{cls.name.to_s.split(/\W/).reject(&:empty?).join('_'.freeze)}"
|
20
|
+
if block.source_location
|
21
|
+
source_path, line_num = block.source_location
|
22
|
+
source_path = Pathname.new(File.expand_path(source_path)).relative_path_from(Rails.root).to_s
|
23
|
+
source_path = source_path.split(/\W/).reject(&:empty?).join("_".freeze)
|
24
|
+
cls_const += "__#{source_path}__#{line_num}"
|
25
|
+
end
|
26
|
+
cls_const += "_1" while MiniTestSpecRails::SpecTests.const_defined? cls_const
|
27
|
+
MiniTestSpecRails::SpecTests.const_set cls_const, cls
|
28
|
+
cls
|
29
|
+
end
|
30
|
+
end
|
@@ -1,30 +1,37 @@
|
|
1
1
|
module MiniTestSpecRails
|
2
2
|
class Railtie < ::Rails::Railtie
|
3
|
-
|
4
3
|
config.minitest_spec_rails = ActiveSupport::OrderedOptions.new
|
5
4
|
config.minitest_spec_rails.mini_shoulda = false
|
6
|
-
|
7
|
-
config.before_initialize do |
|
8
|
-
|
5
|
+
|
6
|
+
config.before_initialize do |_app|
|
7
|
+
require 'active_support'
|
8
|
+
require 'minitest-spec-rails/init/active_support'
|
9
|
+
require 'minitest-spec-rails/parallelize'
|
10
|
+
ActiveSupport.on_load(:action_cable) do
|
11
|
+
require 'minitest-spec-rails/init/action_cable'
|
12
|
+
end
|
13
|
+
ActiveSupport.on_load(:action_controller) do
|
14
|
+
require 'minitest-spec-rails/init/action_controller'
|
15
|
+
require 'minitest-spec-rails/init/action_dispatch'
|
16
|
+
end
|
17
|
+
ActiveSupport.on_load(:action_mailer) do
|
18
|
+
require 'minitest-spec-rails/init/action_mailer'
|
19
|
+
end
|
20
|
+
ActiveSupport.on_load(:active_job) do
|
21
|
+
require 'minitest-spec-rails/init/active_job'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
initializer 'minitest-spec-rails.action_view', after: 'action_view.setup_action_pack', group: :all do |_app|
|
26
|
+
Rails.application.config.to_prepare do
|
9
27
|
ActiveSupport.on_load(:action_view) do
|
10
28
|
require 'minitest-spec-rails/init/action_view'
|
11
29
|
end
|
12
|
-
ActiveSupport.on_load(:action_controller) do
|
13
|
-
require 'minitest-spec-rails/init/action_controller'
|
14
|
-
require 'minitest-spec-rails/init/action_dispatch'
|
15
|
-
end
|
16
|
-
ActiveSupport.on_load(:action_mailer) do
|
17
|
-
require 'minitest-spec-rails/init/action_mailer'
|
18
|
-
end
|
19
30
|
end
|
20
31
|
end
|
21
32
|
|
22
|
-
initializer 'minitest-spec-rails.
|
23
|
-
if
|
24
|
-
require 'minitest-spec-rails/init/active_support'
|
25
|
-
require 'minitest-spec-rails/init/mini_shoulda' if app.config.minitest_spec_rails.mini_shoulda
|
26
|
-
end
|
33
|
+
initializer 'minitest-spec-rails.mini_shoulda', group: :all do |app|
|
34
|
+
require 'minitest-spec-rails/init/mini_shoulda' if app.config.minitest_spec_rails.mini_shoulda
|
27
35
|
end
|
28
|
-
|
29
36
|
end
|
30
37
|
end
|
data/minitest-spec-rails.gemspec
CHANGED
@@ -1,6 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require "minitest-spec-rails/version"
|
1
|
+
$LOAD_PATH.push File.expand_path('lib', __dir__)
|
2
|
+
require 'minitest-spec-rails/version'
|
4
3
|
|
5
4
|
Gem::Specification.new do |gem|
|
6
5
|
gem.name = 'minitest-spec-rails'
|
@@ -9,17 +8,19 @@ Gem::Specification.new do |gem|
|
|
9
8
|
gem.authors = ['Ken Collins']
|
10
9
|
gem.email = ['ken@metaskills.net']
|
11
10
|
gem.homepage = 'http://github.com/metaskills/minitest-spec-rails'
|
12
|
-
gem.summary = 'Make Rails Use
|
13
|
-
gem.description = 'The minitest-spec-rails gem makes it easy to use the
|
11
|
+
gem.summary = 'Make Rails Use Minitest::Spec!'
|
12
|
+
gem.description = 'The minitest-spec-rails gem makes it easy to use the \
|
13
|
+
Minitest::Spec DSL within your existing Rails test suite.'
|
14
14
|
gem.license = 'MIT'
|
15
15
|
gem.files = `git ls-files`.split("\n")
|
16
16
|
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
|
-
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
18
18
|
gem.require_paths = ['lib']
|
19
|
-
gem.add_runtime_dependency 'minitest', '
|
20
|
-
gem.add_runtime_dependency '
|
19
|
+
gem.add_runtime_dependency 'minitest', '>= 5.0'
|
20
|
+
gem.add_runtime_dependency 'railties', '>= 4.1'
|
21
21
|
gem.add_development_dependency 'appraisal'
|
22
|
-
gem.add_development_dependency '
|
22
|
+
gem.add_development_dependency 'minitest-focus'
|
23
|
+
gem.add_development_dependency 'pry'
|
23
24
|
gem.add_development_dependency 'rake'
|
24
25
|
gem.add_development_dependency 'sqlite3'
|
25
26
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class ModelsChannel < ApplicationCable::Channel; end
|
4
|
+
|
5
|
+
class ActionCableChannelTest < MiniTestSpecRails::TestCase
|
6
|
+
it 'matches spec type for class constants' do
|
7
|
+
assert_channel_test Minitest::Spec.spec_type(ApplicationCable::Channel)
|
8
|
+
assert_channel_test Minitest::Spec.spec_type(ModelsChannel)
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'matches spec type for strings' do
|
12
|
+
assert_channel_test Minitest::Spec.spec_type('WidgetChannel')
|
13
|
+
assert_channel_test Minitest::Spec.spec_type('WidgetChannelTest')
|
14
|
+
assert_channel_test Minitest::Spec.spec_type('Widget Channel Test')
|
15
|
+
# And is case sensitive
|
16
|
+
refute_channel_test Minitest::Spec.spec_type('widgetcontroller')
|
17
|
+
refute_channel_test Minitest::Spec.spec_type('widgetcontrollertest')
|
18
|
+
refute_channel_test Minitest::Spec.spec_type('widget controller test')
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'wont match spec type for non space characters' do
|
22
|
+
refute_channel_test Minitest::Spec.spec_type("Widget Channel\tTest")
|
23
|
+
refute_channel_test Minitest::Spec.spec_type("Widget Channel\rTest")
|
24
|
+
refute_channel_test Minitest::Spec.spec_type("Widget Channel\nTest")
|
25
|
+
refute_channel_test Minitest::Spec.spec_type("Widget Channel\fTest")
|
26
|
+
refute_channel_test Minitest::Spec.spec_type('Widget ChannelXTest')
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def assert_channel_test(actual)
|
32
|
+
assert_equal ActionCable::Channel::TestCase, actual
|
33
|
+
end
|
34
|
+
|
35
|
+
def refute_channel_test(actual)
|
36
|
+
refute_equal ActionCable::Channel::TestCase, actual
|
37
|
+
end
|
38
|
+
end
|
@@ -3,31 +3,29 @@ require 'test_helper'
|
|
3
3
|
class ModelsController < ApplicationController; end
|
4
4
|
|
5
5
|
class ActionControllerTest < MiniTestSpecRails::TestCase
|
6
|
-
|
7
6
|
it 'matches spec type for class constants' do
|
8
|
-
assert_controller
|
9
|
-
assert_controller
|
7
|
+
assert_controller Minitest::Spec.spec_type(ApplicationController)
|
8
|
+
assert_controller Minitest::Spec.spec_type(ModelsController)
|
10
9
|
end
|
11
10
|
|
12
11
|
it 'matches spec type for strings' do
|
13
|
-
assert_controller
|
14
|
-
assert_controller
|
15
|
-
assert_controller
|
12
|
+
assert_controller Minitest::Spec.spec_type('WidgetController')
|
13
|
+
assert_controller Minitest::Spec.spec_type('WidgetControllerTest')
|
14
|
+
assert_controller Minitest::Spec.spec_type('Widget Controller Test')
|
16
15
|
# And is case sensitive
|
17
|
-
refute_controller
|
18
|
-
refute_controller
|
19
|
-
refute_controller
|
16
|
+
refute_controller Minitest::Spec.spec_type('widgetcontroller')
|
17
|
+
refute_controller Minitest::Spec.spec_type('widgetcontrollertest')
|
18
|
+
refute_controller Minitest::Spec.spec_type('widget controller test')
|
20
19
|
end
|
21
20
|
|
22
21
|
it 'wont match spec type for non space characters' do
|
23
|
-
refute_controller
|
24
|
-
refute_controller
|
25
|
-
refute_controller
|
26
|
-
refute_controller
|
27
|
-
refute_controller
|
22
|
+
refute_controller Minitest::Spec.spec_type("Widget Controller\tTest")
|
23
|
+
refute_controller Minitest::Spec.spec_type("Widget Controller\rTest")
|
24
|
+
refute_controller Minitest::Spec.spec_type("Widget Controller\nTest")
|
25
|
+
refute_controller Minitest::Spec.spec_type("Widget Controller\fTest")
|
26
|
+
refute_controller Minitest::Spec.spec_type('Widget ControllerXTest')
|
28
27
|
end
|
29
28
|
|
30
|
-
|
31
29
|
private
|
32
30
|
|
33
31
|
def assert_controller(actual)
|
@@ -37,5 +35,4 @@ class ActionControllerTest < MiniTestSpecRails::TestCase
|
|
37
35
|
def refute_controller(actual)
|
38
36
|
refute_equal ActionController::TestCase, actual
|
39
37
|
end
|
40
|
-
|
41
38
|
end
|
@@ -3,40 +3,38 @@ require 'test_helper'
|
|
3
3
|
class ModelsController < ApplicationController; end
|
4
4
|
|
5
5
|
class ActionControllerTest < MiniTestSpecRails::TestCase
|
6
|
-
|
7
6
|
it 'resolves spec type for matching acceptance strings' do
|
8
|
-
assert_dispatch
|
9
|
-
assert_dispatch
|
7
|
+
assert_dispatch Minitest::Spec.spec_type('WidgetAcceptanceTest')
|
8
|
+
assert_dispatch Minitest::Spec.spec_type('Widget Acceptance Test')
|
10
9
|
# And is case sensitive
|
11
|
-
refute_dispatch
|
12
|
-
refute_dispatch
|
10
|
+
refute_dispatch Minitest::Spec.spec_type('widgetacceptancetest')
|
11
|
+
refute_dispatch Minitest::Spec.spec_type('widget acceptance test')
|
13
12
|
end
|
14
13
|
|
15
14
|
it 'wont match spec type for space characters in acceptance strings' do
|
16
|
-
refute_dispatch
|
17
|
-
refute_dispatch
|
18
|
-
refute_dispatch
|
19
|
-
refute_dispatch
|
20
|
-
refute_dispatch
|
15
|
+
refute_dispatch Minitest::Spec.spec_type("Widget Acceptance\tTest")
|
16
|
+
refute_dispatch Minitest::Spec.spec_type("Widget Acceptance\rTest")
|
17
|
+
refute_dispatch Minitest::Spec.spec_type("Widget Acceptance\nTest")
|
18
|
+
refute_dispatch Minitest::Spec.spec_type("Widget Acceptance\fTest")
|
19
|
+
refute_dispatch Minitest::Spec.spec_type('Widget AcceptanceXTest')
|
21
20
|
end
|
22
21
|
|
23
22
|
it 'resolves spec type for matching integration strings' do
|
24
|
-
assert_dispatch
|
25
|
-
assert_dispatch
|
23
|
+
assert_dispatch Minitest::Spec.spec_type('WidgetIntegrationTest')
|
24
|
+
assert_dispatch Minitest::Spec.spec_type('Widget Integration Test')
|
26
25
|
# And is case sensitive
|
27
|
-
refute_dispatch
|
28
|
-
refute_dispatch
|
26
|
+
refute_dispatch Minitest::Spec.spec_type('widgetintegrationtest')
|
27
|
+
refute_dispatch Minitest::Spec.spec_type('widget integration test')
|
29
28
|
end
|
30
29
|
|
31
30
|
it 'wont match spec type for space characters in integration strings' do
|
32
|
-
refute_dispatch
|
33
|
-
refute_dispatch
|
34
|
-
refute_dispatch
|
35
|
-
refute_dispatch
|
36
|
-
refute_dispatch
|
31
|
+
refute_dispatch Minitest::Spec.spec_type("Widget Integration\tTest")
|
32
|
+
refute_dispatch Minitest::Spec.spec_type("Widget Integration\rTest")
|
33
|
+
refute_dispatch Minitest::Spec.spec_type("Widget Integration\nTest")
|
34
|
+
refute_dispatch Minitest::Spec.spec_type("Widget Integration\fTest")
|
35
|
+
refute_dispatch Minitest::Spec.spec_type('Widget IntegrationXTest')
|
37
36
|
end
|
38
37
|
|
39
|
-
|
40
38
|
private
|
41
39
|
|
42
40
|
def assert_dispatch(actual)
|
@@ -46,5 +44,4 @@ class ActionControllerTest < MiniTestSpecRails::TestCase
|
|
46
44
|
def refute_dispatch(actual)
|
47
45
|
refute_equal ActionDispatch::IntegrationTest, actual
|
48
46
|
end
|
49
|
-
|
50
47
|
end
|
@@ -4,31 +4,29 @@ class NotificationMailer < ActionMailer::Base; end
|
|
4
4
|
class Notifications < ActionMailer::Base; end
|
5
5
|
|
6
6
|
class ActionMailerTest < MiniTestSpecRails::TestCase
|
7
|
-
|
8
7
|
it 'matches spec type for class constants' do
|
9
|
-
assert_mailer
|
10
|
-
assert_mailer
|
8
|
+
assert_mailer Minitest::Spec.spec_type(NotificationMailer)
|
9
|
+
assert_mailer Minitest::Spec.spec_type(Notifications)
|
11
10
|
end
|
12
11
|
|
13
12
|
it 'matches spec type for strings' do
|
14
|
-
assert_mailer
|
15
|
-
assert_mailer
|
16
|
-
assert_mailer
|
13
|
+
assert_mailer Minitest::Spec.spec_type('WidgetMailer')
|
14
|
+
assert_mailer Minitest::Spec.spec_type('WidgetMailerTest')
|
15
|
+
assert_mailer Minitest::Spec.spec_type('Widget Mailer Test')
|
17
16
|
# And is case sensitive
|
18
|
-
refute_mailer
|
19
|
-
refute_mailer
|
20
|
-
refute_mailer
|
17
|
+
refute_mailer Minitest::Spec.spec_type('widgetmailer')
|
18
|
+
refute_mailer Minitest::Spec.spec_type('widgetmailertest')
|
19
|
+
refute_mailer Minitest::Spec.spec_type('widget mailer test')
|
21
20
|
end
|
22
21
|
|
23
22
|
it 'wont match spec type for non space characters' do
|
24
|
-
refute_mailer
|
25
|
-
refute_mailer
|
26
|
-
refute_mailer
|
27
|
-
refute_mailer
|
28
|
-
refute_mailer
|
23
|
+
refute_mailer Minitest::Spec.spec_type("Widget Mailer\tTest")
|
24
|
+
refute_mailer Minitest::Spec.spec_type("Widget Mailer\rTest")
|
25
|
+
refute_mailer Minitest::Spec.spec_type("Widget Mailer\nTest")
|
26
|
+
refute_mailer Minitest::Spec.spec_type("Widget Mailer\fTest")
|
27
|
+
refute_mailer Minitest::Spec.spec_type('Widget MailerXTest')
|
29
28
|
end
|
30
29
|
|
31
|
-
|
32
30
|
private
|
33
31
|
|
34
32
|
def assert_mailer(actual)
|
@@ -38,5 +36,4 @@ class ActionMailerTest < MiniTestSpecRails::TestCase
|
|
38
36
|
def refute_mailer(actual)
|
39
37
|
refute_equal ActionMailer::TestCase, actual
|
40
38
|
end
|
41
|
-
|
42
39
|
end
|
@@ -1,36 +1,34 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
class ActionViewTest < MiniTestSpecRails::TestCase
|
4
|
-
|
5
4
|
it 'resolves spec type for matching helper strings' do
|
6
|
-
assert_view
|
7
|
-
assert_view
|
8
|
-
assert_view
|
5
|
+
assert_view Minitest::Spec.spec_type('WidgetHelper')
|
6
|
+
assert_view Minitest::Spec.spec_type('WidgetHelperTest')
|
7
|
+
assert_view Minitest::Spec.spec_type('Widget Helper Test')
|
9
8
|
# And is case sensitive
|
10
|
-
refute_view
|
11
|
-
refute_view
|
12
|
-
refute_view
|
9
|
+
refute_view Minitest::Spec.spec_type('widgethelper')
|
10
|
+
refute_view Minitest::Spec.spec_type('widgethelpertest')
|
11
|
+
refute_view Minitest::Spec.spec_type('widget helper test')
|
13
12
|
end
|
14
13
|
|
15
14
|
it 'resolves spec type for matching view strings' do
|
16
|
-
assert_view
|
17
|
-
assert_view
|
18
|
-
assert_view
|
15
|
+
assert_view Minitest::Spec.spec_type('WidgetView')
|
16
|
+
assert_view Minitest::Spec.spec_type('WidgetViewTest')
|
17
|
+
assert_view Minitest::Spec.spec_type('Widget View Test')
|
19
18
|
# And is case sensitive
|
20
|
-
refute_view
|
21
|
-
refute_view
|
22
|
-
refute_view
|
19
|
+
refute_view Minitest::Spec.spec_type('widgetview')
|
20
|
+
refute_view Minitest::Spec.spec_type('widgetviewtest')
|
21
|
+
refute_view Minitest::Spec.spec_type('widget view test')
|
23
22
|
end
|
24
23
|
|
25
24
|
it 'wont match spec type for non space characters' do
|
26
|
-
refute_view
|
27
|
-
refute_view
|
28
|
-
refute_view
|
29
|
-
refute_view
|
30
|
-
refute_view
|
25
|
+
refute_view Minitest::Spec.spec_type("Widget Helper\tTest")
|
26
|
+
refute_view Minitest::Spec.spec_type("Widget Helper\rTest")
|
27
|
+
refute_view Minitest::Spec.spec_type("Widget Helper\nTest")
|
28
|
+
refute_view Minitest::Spec.spec_type("Widget Helper\fTest")
|
29
|
+
refute_view Minitest::Spec.spec_type('Widget HelperXTest')
|
31
30
|
end
|
32
31
|
|
33
|
-
|
34
32
|
private
|
35
33
|
|
36
34
|
def assert_view(actual)
|
@@ -40,5 +38,4 @@ class ActionViewTest < MiniTestSpecRails::TestCase
|
|
40
38
|
def refute_view(actual)
|
41
39
|
refute_equal ActionView::TestCase, actual
|
42
40
|
end
|
43
|
-
|
44
41
|
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
if defined?(ActiveJob)
|
4
|
+
class MyJob < ActiveJob::Base
|
5
|
+
def perform(_record)
|
6
|
+
true
|
7
|
+
end
|
8
|
+
end
|
9
|
+
class TrashableCleanupJob < MyJob
|
10
|
+
end
|
11
|
+
|
12
|
+
class ActiveJobTest < MiniTestSpecRails::TestCase
|
13
|
+
it 'matches spec type for class constants' do
|
14
|
+
assert_job Minitest::Spec.spec_type(MyJob)
|
15
|
+
assert_job Minitest::Spec.spec_type(TrashableCleanupJob)
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'matches spec type for strings' do
|
19
|
+
assert_job Minitest::Spec.spec_type('WidgetJob')
|
20
|
+
assert_job Minitest::Spec.spec_type('WidgetJobTest')
|
21
|
+
assert_job Minitest::Spec.spec_type('Widget Job Test')
|
22
|
+
# And is case sensitive
|
23
|
+
refute_job Minitest::Spec.spec_type('widgetmailer')
|
24
|
+
refute_job Minitest::Spec.spec_type('widgetmailertest')
|
25
|
+
refute_job Minitest::Spec.spec_type('widget mailer test')
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'wont match spec type for non space characters' do
|
29
|
+
refute_job Minitest::Spec.spec_type("Widget Job\tTest")
|
30
|
+
refute_job Minitest::Spec.spec_type("Widget Job\rTest")
|
31
|
+
refute_job Minitest::Spec.spec_type("Widget Job\nTest")
|
32
|
+
refute_job Minitest::Spec.spec_type("Widget Job\fTest")
|
33
|
+
refute_job Minitest::Spec.spec_type('Widget JobXTest')
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def assert_job(actual)
|
39
|
+
assert_equal ActiveJob::TestCase, actual
|
40
|
+
end
|
41
|
+
|
42
|
+
def refute_job(actual)
|
43
|
+
refute_equal ActiveJob::TestCase, actual
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|