minitest-spec-rails 5.4.0 → 6.0.3

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.
Files changed (60) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/ci.yml +35 -0
  3. data/.rubocop.yml +26 -0
  4. data/Appraisals +10 -6
  5. data/CHANGELOG.md +25 -1
  6. data/Gemfile +0 -1
  7. data/README.md +23 -35
  8. data/Rakefile +6 -6
  9. data/gemfiles/{rails42.gemfile → rails_v5.1.x.gemfile} +3 -2
  10. data/gemfiles/rails_v5.1.x.gemfile.lock +128 -0
  11. data/gemfiles/{rails50.gemfile → rails_v5.2.x.gemfile} +3 -2
  12. data/gemfiles/rails_v5.2.x.gemfile.lock +136 -0
  13. data/gemfiles/{rails41.gemfile → rails_v6.0.x.gemfile} +3 -2
  14. data/gemfiles/rails_v6.0.x.gemfile.lock +152 -0
  15. data/lib/minitest-spec-rails/dsl.rb +5 -9
  16. data/lib/minitest-spec-rails/init/action_controller.rb +3 -7
  17. data/lib/minitest-spec-rails/init/action_dispatch.rb +1 -3
  18. data/lib/minitest-spec-rails/init/action_mailer.rb +2 -7
  19. data/lib/minitest-spec-rails/init/action_view.rb +1 -5
  20. data/lib/minitest-spec-rails/init/active_job.rb +3 -8
  21. data/lib/minitest-spec-rails/init/active_support.rb +8 -10
  22. data/lib/minitest-spec-rails/init/mini_shoulda.rb +2 -6
  23. data/lib/minitest-spec-rails/parallelize.rb +30 -0
  24. data/lib/minitest-spec-rails/railtie.rb +24 -21
  25. data/lib/minitest-spec-rails/version.rb +1 -1
  26. data/minitest-spec-rails.gemspec +7 -7
  27. data/test/cases/action_controller_test.rb +7 -10
  28. data/test/cases/action_dispatch_test.rb +10 -13
  29. data/test/cases/action_mailer_test.rb +7 -10
  30. data/test/cases/action_view_test.rb +13 -16
  31. data/test/cases/active_job_test.rb +38 -36
  32. data/test/cases/active_support_test.rb +22 -12
  33. data/test/cases/mini_shoulda_test.rb +0 -4
  34. data/test/dummy_app/app/assets/config/manifest.js +1 -0
  35. data/test/dummy_app/app/controllers/application_controller.rb +1 -3
  36. data/test/dummy_app/app/controllers/users_controller.rb +1 -3
  37. data/test/dummy_app/app/helpers/application_helper.rb +0 -1
  38. data/test/dummy_app/app/helpers/foos_helper.rb +3 -1
  39. data/test/dummy_app/app/helpers/users_helper.rb +1 -3
  40. data/test/dummy_app/app/mailers/user_mailer.rb +2 -4
  41. data/test/dummy_app/app/models/post.rb +0 -3
  42. data/test/dummy_app/app/models/user.rb +0 -3
  43. data/test/dummy_app/config/routes.rb +1 -1
  44. data/test/dummy_app/init.rb +13 -6
  45. data/test/dummy_tests/application_controller_test.rb +3 -9
  46. data/test/dummy_tests/foos_helper_test.rb +0 -3
  47. data/test/dummy_tests/integration_test.rb +2 -8
  48. data/test/dummy_tests/special_users_controller_test.rb +0 -2
  49. data/test/dummy_tests/user_mailer_test.rb +4 -10
  50. data/test/dummy_tests/user_test.rb +2 -8
  51. data/test/dummy_tests/users_controller_test.rb +1 -3
  52. data/test/dummy_tests/users_helper_test.rb +2 -8
  53. data/test/support/shared_test_case_behavior.rb +4 -7
  54. data/test/test_helper.rb +0 -3
  55. data/test/test_helper_dummy.rb +5 -6
  56. metadata +20 -16
  57. data/.travis.yml +0 -22
  58. data/gemfiles/rails41.gemfile.lock +0 -96
  59. data/gemfiles/rails42.gemfile.lock +0 -123
  60. data/gemfiles/rails50.gemfile.lock +0 -133
@@ -2,6 +2,7 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "rails", "~> 4.1.0"
5
+ gem "rails", "~> 6.0.0"
6
+ gem "minitest"
6
7
 
7
- gemspec :path => "../"
8
+ gemspec path: "../"
@@ -0,0 +1,152 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ minitest-spec-rails (6.0.2)
5
+ minitest (>= 5.0)
6
+ railties (>= 4.1)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ actioncable (6.0.1)
12
+ actionpack (= 6.0.1)
13
+ nio4r (~> 2.0)
14
+ websocket-driver (>= 0.6.1)
15
+ actionmailbox (6.0.1)
16
+ actionpack (= 6.0.1)
17
+ activejob (= 6.0.1)
18
+ activerecord (= 6.0.1)
19
+ activestorage (= 6.0.1)
20
+ activesupport (= 6.0.1)
21
+ mail (>= 2.7.1)
22
+ actionmailer (6.0.1)
23
+ actionpack (= 6.0.1)
24
+ actionview (= 6.0.1)
25
+ activejob (= 6.0.1)
26
+ mail (~> 2.5, >= 2.5.4)
27
+ rails-dom-testing (~> 2.0)
28
+ actionpack (6.0.1)
29
+ actionview (= 6.0.1)
30
+ activesupport (= 6.0.1)
31
+ rack (~> 2.0)
32
+ rack-test (>= 0.6.3)
33
+ rails-dom-testing (~> 2.0)
34
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
35
+ actiontext (6.0.1)
36
+ actionpack (= 6.0.1)
37
+ activerecord (= 6.0.1)
38
+ activestorage (= 6.0.1)
39
+ activesupport (= 6.0.1)
40
+ nokogiri (>= 1.8.5)
41
+ actionview (6.0.1)
42
+ activesupport (= 6.0.1)
43
+ builder (~> 3.1)
44
+ erubi (~> 1.4)
45
+ rails-dom-testing (~> 2.0)
46
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
47
+ activejob (6.0.1)
48
+ activesupport (= 6.0.1)
49
+ globalid (>= 0.3.6)
50
+ activemodel (6.0.1)
51
+ activesupport (= 6.0.1)
52
+ activerecord (6.0.1)
53
+ activemodel (= 6.0.1)
54
+ activesupport (= 6.0.1)
55
+ activestorage (6.0.1)
56
+ actionpack (= 6.0.1)
57
+ activejob (= 6.0.1)
58
+ activerecord (= 6.0.1)
59
+ marcel (~> 0.3.1)
60
+ activesupport (6.0.1)
61
+ concurrent-ruby (~> 1.0, >= 1.0.2)
62
+ i18n (>= 0.7, < 2)
63
+ minitest (~> 5.1)
64
+ tzinfo (~> 1.1)
65
+ zeitwerk (~> 2.2)
66
+ appraisal (2.2.0)
67
+ bundler
68
+ rake
69
+ thor (>= 0.14.0)
70
+ builder (3.2.3)
71
+ concurrent-ruby (1.1.5)
72
+ crass (1.0.5)
73
+ erubi (1.9.0)
74
+ globalid (0.4.2)
75
+ activesupport (>= 4.2.0)
76
+ i18n (1.7.0)
77
+ concurrent-ruby (~> 1.0)
78
+ loofah (2.4.0)
79
+ crass (~> 1.0.2)
80
+ nokogiri (>= 1.5.9)
81
+ mail (2.7.1)
82
+ mini_mime (>= 0.1.1)
83
+ marcel (0.3.3)
84
+ mimemagic (~> 0.3.2)
85
+ method_source (0.9.2)
86
+ mimemagic (0.3.3)
87
+ mini_mime (1.0.2)
88
+ mini_portile2 (2.4.0)
89
+ minitest (5.13.0)
90
+ nio4r (2.5.2)
91
+ nokogiri (1.10.5)
92
+ mini_portile2 (~> 2.4.0)
93
+ rack (2.0.7)
94
+ rack-test (1.1.0)
95
+ rack (>= 1.0, < 3)
96
+ rails (6.0.1)
97
+ actioncable (= 6.0.1)
98
+ actionmailbox (= 6.0.1)
99
+ actionmailer (= 6.0.1)
100
+ actionpack (= 6.0.1)
101
+ actiontext (= 6.0.1)
102
+ actionview (= 6.0.1)
103
+ activejob (= 6.0.1)
104
+ activemodel (= 6.0.1)
105
+ activerecord (= 6.0.1)
106
+ activestorage (= 6.0.1)
107
+ activesupport (= 6.0.1)
108
+ bundler (>= 1.3.0)
109
+ railties (= 6.0.1)
110
+ sprockets-rails (>= 2.0.0)
111
+ rails-dom-testing (2.0.3)
112
+ activesupport (>= 4.2.0)
113
+ nokogiri (>= 1.6)
114
+ rails-html-sanitizer (1.3.0)
115
+ loofah (~> 2.3)
116
+ railties (6.0.1)
117
+ actionpack (= 6.0.1)
118
+ activesupport (= 6.0.1)
119
+ method_source
120
+ rake (>= 0.8.7)
121
+ thor (>= 0.20.3, < 2.0)
122
+ rake (13.0.1)
123
+ sprockets (4.0.0)
124
+ concurrent-ruby (~> 1.0)
125
+ rack (> 1, < 3)
126
+ sprockets-rails (3.2.1)
127
+ actionpack (>= 4.0)
128
+ activesupport (>= 4.0)
129
+ sprockets (>= 3.0.0)
130
+ sqlite3 (1.4.1)
131
+ thor (0.20.3)
132
+ thread_safe (0.3.6)
133
+ tzinfo (1.2.5)
134
+ thread_safe (~> 0.1)
135
+ websocket-driver (0.7.1)
136
+ websocket-extensions (>= 0.1.0)
137
+ websocket-extensions (0.1.4)
138
+ zeitwerk (2.2.1)
139
+
140
+ PLATFORMS
141
+ ruby
142
+
143
+ DEPENDENCIES
144
+ appraisal
145
+ minitest
146
+ minitest-spec-rails!
147
+ rails (~> 6.0.0)
148
+ rake
149
+ sqlite3
150
+
151
+ BUNDLED WITH
152
+ 1.17.3
@@ -1,13 +1,11 @@
1
1
  module MiniTestSpecRails
2
2
  module DSL
3
-
4
3
  def self.included(klass)
5
4
  klass.extend ClassMethods
6
5
  remove_method :test if method_defined?(:test)
7
6
  end
8
7
 
9
8
  module ClassMethods
10
-
11
9
  def describe(*args, &block)
12
10
  stack = Minitest::Spec.describe_stack
13
11
  stack.push self if stack.empty?
@@ -15,27 +13,25 @@ module MiniTestSpecRails
15
13
  stack.pop if stack.length == 1
16
14
  end
17
15
 
18
- def before(type = nil, &block)
19
- setup { self.instance_eval(&block) }
16
+ def before(_type = nil, &block)
17
+ setup { instance_eval(&block) }
20
18
  end
21
19
 
22
- def after(type = nil, &block)
23
- teardown { self.instance_eval(&block) }
20
+ def after(_type = nil, &block)
21
+ teardown { instance_eval(&block) }
24
22
  end
25
23
 
26
24
  def test(name, &block)
27
- it(name) { self.instance_eval(&block) }
25
+ instance_eval { it(name, &block) }
28
26
  end
29
27
 
30
28
  def described_class
31
29
  nil
32
30
  end
33
-
34
31
  end
35
32
 
36
33
  def described_class
37
34
  self.class.described_class
38
35
  end
39
-
40
36
  end
41
37
  end
@@ -1,24 +1,20 @@
1
1
  module MiniTestSpecRails
2
2
  module Init
3
3
  module ActionControllerBehavior
4
-
5
4
  extend ActiveSupport::Concern
6
5
 
7
6
  included do
8
7
  extend Descriptions
9
- register_spec_type(self) { |desc| Class === desc && desc < ActionController::Metal }
8
+ register_spec_type(self) { |desc| desc.is_a?(Class) && desc < ActionController::Metal }
10
9
  register_spec_type(/Controller( ?Test)?\z/, self)
11
- register_spec_type(self) { |desc| Class === desc && desc < self }
10
+ register_spec_type(self) { |desc| desc.is_a?(Class) && desc < self }
12
11
  end
13
-
14
- module Descriptions
15
12
 
13
+ module Descriptions
16
14
  def described_class
17
15
  determine_default_controller_class(name)
18
16
  end
19
-
20
17
  end
21
-
22
18
  end
23
19
  end
24
20
  end
@@ -1,14 +1,12 @@
1
1
  module MiniTestSpecRails
2
2
  module Init
3
3
  module ActionDispatchBehavior
4
-
5
4
  extend ActiveSupport::Concern
6
5
 
7
6
  included do
8
7
  register_spec_type(/(Acceptance|Integration) ?Test\z/, self)
9
- register_spec_type(self) { |desc| Class === desc && desc < self }
8
+ register_spec_type(self) { |desc| desc.is_a?(Class) && desc < self }
10
9
  end
11
-
12
10
  end
13
11
  end
14
12
  end
@@ -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 === desc && desc < ActionMailer::Base }
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 === desc && desc < self }
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 === desc && desc < self }
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
@@ -1,29 +1,24 @@
1
1
  module MiniTestSpecRails
2
2
  module Init
3
3
  module ActiveJobBehavior
4
-
5
4
  extend ActiveSupport::Concern
6
5
 
7
6
  included do
8
- register_spec_type(self) { |desc| Class === desc && desc < ActiveJob::Base }
7
+ register_spec_type(self) { |desc| desc.is_a?(Class) && desc < ActiveJob::Base }
9
8
  register_spec_type(/Job( ?Test)?\z/, self)
10
- register_spec_type(self) { |desc| Class === desc && desc < self }
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_constant_from_test_name(name) do |constant|
18
- Class === constant && constant < ActiveJob::Base
16
+ constant.is_a?(Class) && constant < ActiveJob::Base
19
17
  end
20
18
  end
21
-
22
19
  end
23
-
24
20
  end
25
21
  end
26
22
  end
27
23
 
28
24
  ActiveJob::TestCase.send :include, MiniTestSpecRails::Init::ActiveJobBehavior
29
-
@@ -1,7 +1,6 @@
1
1
  module MiniTestSpecRails
2
2
  module Init
3
3
  module ActiveSupportBehavior
4
-
5
4
  extend ActiveSupport::Concern
6
5
 
7
6
  included do
@@ -9,24 +8,23 @@ module MiniTestSpecRails
9
8
  include MiniTestSpecRails::DSL
10
9
  include ActiveSupport::Testing::ConstantLookup
11
10
  extend Descriptions
12
- register_spec_type(self) { |desc| Class === desc }
11
+ register_spec_type(self) { |desc| desc.is_a?(Class) }
13
12
  end
14
13
 
15
14
  module Descriptions
16
-
17
15
  def described_class
18
16
  determine_constant_from_test_name(name) do |constant|
19
- Class === constant
17
+ constant.is_a?(Class)
20
18
  end
21
19
  end
22
-
23
20
  end
24
21
 
25
- def initialize(*args)
26
- Thread.current[:current_spec] = self
27
- super
28
- end if Minitest::VERSION < "5.3.3"
29
-
22
+ if Minitest::VERSION < '5.3.3'
23
+ def initialize(*args)
24
+ Thread.current[:current_spec] = self
25
+ super
26
+ end
27
+ end
30
28
  end
31
29
  end
32
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
- alias :context :describe
10
- alias :should :it
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(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,31 +1,34 @@
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
5
 
7
- config.before_initialize do |app|
8
- require 'active_support'
9
- require 'minitest-spec-rails/init/active_support'
10
- ActiveSupport.on_load(:action_controller) do
11
- require 'minitest-spec-rails/init/action_controller'
12
- require 'minitest-spec-rails/init/action_dispatch'
13
- end
14
- ActiveSupport.on_load(:action_mailer) do
15
- require 'minitest-spec-rails/init/action_mailer'
16
- end
17
- ActiveSupport.on_load(:active_job) do
18
- require 'minitest-spec-rails/init/active_job'
6
+ if ENV['RAILS_ENV'] == 'test'
7
+ config.before_initialize do |_app|
8
+ require 'active_support'
9
+ require 'minitest-spec-rails/init/active_support'
10
+ require 'minitest-spec-rails/parallelize'
11
+ ActiveSupport.on_load(:action_controller) do
12
+ require 'minitest-spec-rails/init/action_controller'
13
+ require 'minitest-spec-rails/init/action_dispatch'
14
+ end
15
+ ActiveSupport.on_load(:action_mailer) do
16
+ require 'minitest-spec-rails/init/action_mailer'
17
+ end
18
+ ActiveSupport.on_load(:active_job) do
19
+ require 'minitest-spec-rails/init/active_job'
20
+ end
19
21
  end
20
- end if ENV['RAILS_ENV'] == 'test'
21
22
 
22
- initializer 'minitest-spec-rails.action_view', :after => 'action_view.setup_action_pack', :group => :all do |app|
23
- require 'minitest-spec-rails/init/action_view'
24
- end if ENV['RAILS_ENV'] == 'test'
25
-
26
- initializer 'minitest-spec-rails.mini_shoulda', :group => :all do |app|
27
- require 'minitest-spec-rails/init/mini_shoulda' if app.config.minitest_spec_rails.mini_shoulda
28
- end if ENV['RAILS_ENV'] == 'test'
23
+ initializer 'minitest-spec-rails.action_view', after: 'action_view.setup_action_pack', group: :all do |_app|
24
+ ActiveSupport.on_load(:action_view) do
25
+ require 'minitest-spec-rails/init/action_view'
26
+ end
27
+ end
29
28
 
29
+ initializer 'minitest-spec-rails.mini_shoulda', group: :all do |app|
30
+ require 'minitest-spec-rails/init/mini_shoulda' if app.config.minitest_spec_rails.mini_shoulda
31
+ end
32
+ end
30
33
  end
31
34
  end