minitest-rails 3.0.0 → 6.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +5 -0
- data/LICENSE +1 -1
- data/README.md +117 -0
- data/UPDATING.md +31 -0
- data/lib/generators/minitest.rb +17 -4
- data/lib/generators/minitest/controller/controller_generator.rb +6 -9
- data/lib/generators/minitest/controller/templates/{controller_spec.rb → functional_spec.rb.tt} +4 -4
- data/lib/generators/minitest/controller/templates/{controller_test.rb → functional_test.rb.tt} +3 -3
- data/lib/generators/minitest/generator/generator_generator.rb +3 -8
- data/lib/generators/minitest/generator/templates/{generator_spec.rb → generator_spec.rb.tt} +2 -2
- data/lib/generators/minitest/generator/templates/{generator_test.rb → generator_test.rb.tt} +1 -2
- data/lib/generators/minitest/helper/helper_generator.rb +5 -3
- data/lib/generators/minitest/install/install_generator.rb +21 -8
- data/lib/generators/minitest/install/templates/test/application_system_test_case.rb.tt +10 -0
- data/lib/generators/minitest/install/templates/test/channels/application_cable/connection_test.rb.tt +23 -0
- data/lib/generators/minitest/install/templates/test/test_helper.rb.tt +23 -0
- data/lib/generators/minitest/integration/integration_generator.rb +12 -9
- data/lib/generators/minitest/integration/templates/integration_spec.rb.tt +9 -0
- data/lib/generators/minitest/integration/templates/integration_test.rb.tt +9 -0
- data/lib/generators/minitest/job/job_generator.rb +13 -10
- data/lib/generators/minitest/job/templates/unit_spec.rb.tt +9 -0
- data/lib/generators/minitest/job/templates/{job_test.rb → unit_test.rb.tt} +3 -3
- data/lib/generators/minitest/mailer/mailer_generator.rb +8 -11
- data/lib/generators/minitest/mailer/templates/functional_spec.rb.tt +21 -0
- data/lib/generators/minitest/mailer/templates/{mailer_test.rb → functional_test.rb.tt} +3 -3
- data/lib/generators/minitest/mailer/templates/{preview.rb → preview.rb.tt} +0 -0
- data/lib/generators/minitest/model/model_generator.rb +9 -12
- data/lib/generators/minitest/model/templates/{fixtures.yml → fixtures.yml.tt} +3 -3
- data/lib/generators/minitest/model/templates/unit_spec.rb.tt +9 -0
- data/lib/generators/minitest/model/templates/unit_test.rb.tt +9 -0
- data/lib/generators/minitest/plugin/plugin_generator.rb +15 -0
- data/lib/generators/minitest/plugin/templates/%file_name%_test.rb.tt +15 -0
- data/lib/generators/minitest/plugin/templates/test_helper.rb +2 -0
- data/lib/generators/minitest/scaffold/scaffold_generator.rb +28 -23
- data/lib/generators/minitest/scaffold/templates/api_functional_spec.rb.tt +42 -0
- data/lib/generators/minitest/scaffold/templates/api_functional_test.rb.tt +44 -0
- data/lib/generators/minitest/scaffold/templates/functional_spec.rb.tt +52 -0
- data/lib/generators/minitest/scaffold/templates/{controller_test.rb → functional_test.rb.tt} +16 -16
- data/lib/generators/minitest/scaffold/templates/system_spec.rb.tt +55 -0
- data/lib/generators/minitest/scaffold/templates/system_test.rb.tt +57 -0
- data/lib/generators/minitest/system/system_generator.rb +25 -0
- data/lib/generators/minitest/system/templates/application_system_test_case.rb.tt +10 -0
- data/lib/generators/minitest/system/templates/system_spec.rb.tt +9 -0
- data/lib/generators/minitest/system/templates/system_test.rb.tt +9 -0
- data/lib/minitest/rails.rb +76 -105
- data/lib/minitest/rails/assertions.rb +6 -906
- data/lib/minitest/rails/assertions/action_cable.rb +232 -0
- data/lib/minitest/rails/assertions/action_dispatch.rb +356 -0
- data/lib/minitest/rails/assertions/action_mailer.rb +153 -0
- data/lib/minitest/rails/assertions/action_view.rb +356 -0
- data/lib/minitest/rails/assertions/active_job.rb +151 -0
- data/lib/minitest/rails/assertions/active_support.rb +57 -0
- data/lib/minitest/rails/capybara.rb +17 -0
- data/lib/minitest/rails/expectations.rb +5 -565
- data/lib/minitest/rails/expectations/action_cable.rb +197 -0
- data/lib/minitest/rails/expectations/action_dispatch.rb +307 -0
- data/lib/minitest/rails/expectations/action_mailer.rb +175 -0
- data/lib/minitest/rails/expectations/active_job.rb +182 -0
- data/lib/minitest/rails/expectations/active_support.rb +73 -0
- data/lib/minitest/rails/parallelize.rb +41 -0
- data/lib/minitest/rails/railtie.rb +3 -2
- data/lib/minitest/rails/version.rb +1 -1
- metadata +87 -92
- data/.autotest +0 -23
- data/.gemtest +0 -0
- data/.travis.yml +0 -25
- data/CHANGELOG.rdoc +0 -223
- data/Gemfile +0 -7
- data/Manifest.txt +0 -76
- data/README.rdoc +0 -110
- data/Rakefile +0 -30
- data/gemfiles/5.0.gemfile +0 -5
- data/gemfiles/head.gemfile +0 -5
- data/lib/generators/.document +0 -0
- data/lib/generators/minitest/install/templates/test_helper.rb +0 -19
- data/lib/generators/minitest/integration/templates/integration_spec.rb +0 -8
- data/lib/generators/minitest/integration/templates/integration_test.rb +0 -7
- data/lib/generators/minitest/job/templates/job_spec.rb +0 -9
- data/lib/generators/minitest/mailer/templates/mailer_spec.rb +0 -20
- data/lib/generators/minitest/model/templates/model_spec.rb +0 -11
- data/lib/generators/minitest/model/templates/model_test.rb +0 -13
- data/lib/generators/minitest/scaffold/templates/api_controller_spec.rb +0 -42
- data/lib/generators/minitest/scaffold/templates/api_controller_test.rb +0 -44
- data/lib/generators/minitest/scaffold/templates/controller_spec.rb +0 -52
- data/lib/minitest/rails/constant_lookup.rb +0 -52
- data/lib/minitest/rails/controller.rb +0 -14
- data/minitest-rails.gemspec +0 -48
- data/tasks/test.rake +0 -29
- data/test/generators/test_controller_generator.rb +0 -58
- data/test/generators/test_generator_generator.rb +0 -58
- data/test/generators/test_helper_generator.rb +0 -34
- data/test/generators/test_install_generator.rb +0 -27
- data/test/generators/test_job_generator.rb +0 -45
- data/test/generators/test_mailer_generator.rb +0 -42
- data/test/generators/test_model_generator.rb +0 -80
- data/test/generators/test_scaffold_generator.rb +0 -26
- data/test/helper.rb +0 -93
- data/test/rails/action_dispatch/test_assertions.rb +0 -39
- data/test/rails/action_dispatch/test_expectations.rb +0 -39
- data/test/rails/action_dispatch/test_spec_type.rb +0 -49
- data/test/rails/action_mailer/test_mailers.rb +0 -109
- data/test/rails/action_mailer/test_spec_type.rb +0 -47
- data/test/rails/action_view/test_helpers.rb +0 -73
- data/test/rails/action_view/test_spec_type.rb +0 -58
- data/test/rails/active_job/test_assertions.rb +0 -46
- data/test/rails/active_job/test_expectations.rb +0 -55
- data/test/rails/active_job/test_spec_type.rb +0 -49
- data/test/rails/active_support/test_assertions.rb +0 -31
- data/test/rails/active_support/test_expectations.rb +0 -21
- data/test/rails/active_support/test_spec_type.rb +0 -28
- data/test/rails/generators/test_spec_type.rb +0 -45
- data/test/rails/test_constant_lookup.rb +0 -58
- data/test/test_sanity.rb +0 -7
@@ -0,0 +1,44 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
<% module_namespacing do -%>
|
4
|
+
class <%= controller_class_name %>ControllerTest < ActionDispatch::IntegrationTest
|
5
|
+
<%- if mountable_engine? -%>
|
6
|
+
include Engine.routes.url_helpers
|
7
|
+
|
8
|
+
<%- end -%>
|
9
|
+
setup do
|
10
|
+
@<%= singular_table_name %> = <%= fixture_name %>(:one)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_get_index
|
14
|
+
get <%= index_helper %>_url, as: :json
|
15
|
+
assert_response :success
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_create_<%= singular_table_name %>
|
19
|
+
assert_difference("<%= class_name %>.count") do
|
20
|
+
post <%= index_helper %>_url, params: { <%= "#{singular_table_name}: { #{attributes_string} }" %> }, as: :json
|
21
|
+
end
|
22
|
+
|
23
|
+
assert_response 201
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_show_<%= singular_table_name %>
|
27
|
+
get <%= show_helper %>, as: :json
|
28
|
+
assert_response :success
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_update_<%= singular_table_name %>
|
32
|
+
patch <%= show_helper %>, params: { <%= "#{singular_table_name}: { #{attributes_string} }" %> }, as: :json
|
33
|
+
assert_response 200
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_destroy_<%= singular_table_name %>
|
37
|
+
assert_difference("<%= class_name %>.count", -1) do
|
38
|
+
delete <%= show_helper %>, as: :json
|
39
|
+
end
|
40
|
+
|
41
|
+
assert_response 204
|
42
|
+
end
|
43
|
+
end
|
44
|
+
<% end -%>
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
<% module_namespacing do -%>
|
4
|
+
describe <%= controller_class_name %>Controller do
|
5
|
+
<%- if mountable_engine? -%>
|
6
|
+
include Engine.routes.url_helpers
|
7
|
+
|
8
|
+
<%- end -%>
|
9
|
+
let(:<%= singular_table_name %>) { <%= fixture_name %>(:one) }
|
10
|
+
|
11
|
+
it "should get index" do
|
12
|
+
get <%= index_helper %>_url
|
13
|
+
must_respond_with :success
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should get new" do
|
17
|
+
get <%= new_helper %>
|
18
|
+
must_respond_with :success
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should create <%= singular_table_name %>" do
|
22
|
+
assert_difference("<%= class_name %>.count") do
|
23
|
+
post <%= index_helper %>_url, params: { <%= "#{singular_table_name}: { #{attributes_string} }" %> }
|
24
|
+
end
|
25
|
+
|
26
|
+
must_redirect_to <%= singular_table_name %>_url(<%= class_name %>.last)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should show <%= singular_table_name %>" do
|
30
|
+
get <%= show_helper %>
|
31
|
+
must_respond_with :success
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should get edit" do
|
35
|
+
get <%= edit_helper %>
|
36
|
+
must_respond_with :success
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should update <%= singular_table_name %>" do
|
40
|
+
patch <%= show_helper %>, params: { <%= "#{singular_table_name}: { #{attributes_string} }" %> }
|
41
|
+
must_redirect_to <%= singular_table_name %>_url(<%= "#{singular_table_name}" %>)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should destroy <%= singular_table_name %>" do
|
45
|
+
assert_difference("<%= class_name %>.count", -1) do
|
46
|
+
delete <%= show_helper %>
|
47
|
+
end
|
48
|
+
|
49
|
+
must_redirect_to <%= index_helper %>_url
|
50
|
+
end
|
51
|
+
end
|
52
|
+
<% end -%>
|
data/lib/generators/minitest/scaffold/templates/{controller_test.rb → functional_test.rb.tt}
RENAMED
@@ -6,49 +6,49 @@ class <%= controller_class_name %>ControllerTest < ActionDispatch::IntegrationTe
|
|
6
6
|
include Engine.routes.url_helpers
|
7
7
|
|
8
8
|
<%- end -%>
|
9
|
-
|
10
|
-
@<%= singular_table_name %>
|
9
|
+
setup do
|
10
|
+
@<%= singular_table_name %> = <%= fixture_name %>(:one)
|
11
11
|
end
|
12
12
|
|
13
|
-
def
|
13
|
+
def test_get_index
|
14
14
|
get <%= index_helper %>_url
|
15
15
|
assert_response :success
|
16
16
|
end
|
17
17
|
|
18
|
-
def
|
18
|
+
def test_get_new
|
19
19
|
get <%= new_helper %>
|
20
20
|
assert_response :success
|
21
21
|
end
|
22
22
|
|
23
|
-
def
|
24
|
-
assert_difference
|
25
|
-
post <%= index_helper %>_url, params: { <%= "#{singular_table_name}: { #{
|
23
|
+
def test_create_<%= singular_table_name %>
|
24
|
+
assert_difference("<%= class_name %>.count") do
|
25
|
+
post <%= index_helper %>_url, params: { <%= "#{singular_table_name}: { #{attributes_string} }" %> }
|
26
26
|
end
|
27
27
|
|
28
|
-
assert_redirected_to <%= singular_table_name %>
|
28
|
+
assert_redirected_to <%= singular_table_name %>_url(<%= class_name %>.last)
|
29
29
|
end
|
30
30
|
|
31
|
-
def
|
31
|
+
def test_show_<%= singular_table_name %>
|
32
32
|
get <%= show_helper %>
|
33
33
|
assert_response :success
|
34
34
|
end
|
35
35
|
|
36
|
-
def
|
36
|
+
def test_get_edit
|
37
37
|
get <%= edit_helper %>
|
38
38
|
assert_response :success
|
39
39
|
end
|
40
40
|
|
41
|
-
def
|
42
|
-
patch <%= show_helper %>, params: { <%= "#{singular_table_name}: { #{
|
43
|
-
assert_redirected_to <%= singular_table_name %>
|
41
|
+
def test_update_<%= singular_table_name %>
|
42
|
+
patch <%= show_helper %>, params: { <%= "#{singular_table_name}: { #{attributes_string} }" %> }
|
43
|
+
assert_redirected_to <%= singular_table_name %>_url(<%= "@#{singular_table_name}" %>)
|
44
44
|
end
|
45
45
|
|
46
|
-
def
|
47
|
-
assert_difference
|
46
|
+
def test_destroy_<%= singular_table_name %>
|
47
|
+
assert_difference("<%= class_name %>.count", -1) do
|
48
48
|
delete <%= show_helper %>
|
49
49
|
end
|
50
50
|
|
51
|
-
assert_redirected_to <%= index_helper %>
|
51
|
+
assert_redirected_to <%= index_helper %>_url
|
52
52
|
end
|
53
53
|
end
|
54
54
|
<% end -%>
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require "application_system_test_case"
|
2
|
+
|
3
|
+
<% module_namespacing do -%>
|
4
|
+
describe "<%= class_name.pluralize %>", :system do
|
5
|
+
let(:<%= singular_table_name %>) { <%= fixture_name %>(:one) }
|
6
|
+
|
7
|
+
it "visiting the index" do
|
8
|
+
visit <%= plural_table_name %>_url
|
9
|
+
assert_selector "h1", text: "<%= class_name.pluralize.titleize %>"
|
10
|
+
end
|
11
|
+
|
12
|
+
it "creating a <%= human_name %>" do
|
13
|
+
visit <%= plural_table_name %>_url
|
14
|
+
click_on "New <%= class_name.titleize %>"
|
15
|
+
|
16
|
+
<%- attributes_hash.each do |attr, value| -%>
|
17
|
+
<%- if boolean?(attr) -%>
|
18
|
+
check "<%= attr.humanize %>" if <%= value %>
|
19
|
+
<%- else -%>
|
20
|
+
fill_in "<%= attr.humanize %>", with: <%= value %>
|
21
|
+
<%- end -%>
|
22
|
+
<%- end -%>
|
23
|
+
click_on "Create <%= human_name %>"
|
24
|
+
|
25
|
+
assert_text "<%= human_name %> was successfully created"
|
26
|
+
click_on "Back"
|
27
|
+
end
|
28
|
+
|
29
|
+
it "updating a <%= human_name %>" do
|
30
|
+
visit <%= plural_table_name %>_url
|
31
|
+
click_on "Edit", match: :first
|
32
|
+
|
33
|
+
<%- attributes_hash.each do |attr, value| -%>
|
34
|
+
<%- if boolean?(attr) -%>
|
35
|
+
check "<%= attr.humanize %>" if <%= value %>
|
36
|
+
<%- else -%>
|
37
|
+
fill_in "<%= attr.humanize %>", with: <%= value %>
|
38
|
+
<%- end -%>
|
39
|
+
<%- end -%>
|
40
|
+
click_on "Update <%= human_name %>"
|
41
|
+
|
42
|
+
assert_text "<%= human_name %> was successfully updated"
|
43
|
+
click_on "Back"
|
44
|
+
end
|
45
|
+
|
46
|
+
it "destroying a <%= human_name %>" do
|
47
|
+
visit <%= plural_table_name %>_url
|
48
|
+
page.accept_confirm do
|
49
|
+
click_on "Destroy", match: :first
|
50
|
+
end
|
51
|
+
|
52
|
+
assert_text "<%= human_name %> was successfully destroyed"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
<% end -%>
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require "application_system_test_case"
|
2
|
+
|
3
|
+
<% module_namespacing do -%>
|
4
|
+
class <%= class_name.pluralize %>Test < ApplicationSystemTestCase
|
5
|
+
setup do
|
6
|
+
@<%= singular_table_name %> = <%= fixture_name %>(:one)
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_visiting_index
|
10
|
+
visit <%= plural_table_name %>_url
|
11
|
+
assert_selector "h1", text: "<%= class_name.pluralize.titleize %>"
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_creating_<%= human_name %>
|
15
|
+
visit <%= plural_table_name %>_url
|
16
|
+
click_on "New <%= class_name.titleize %>"
|
17
|
+
|
18
|
+
<%- attributes_hash.each do |attr, value| -%>
|
19
|
+
<%- if boolean?(attr) -%>
|
20
|
+
check "<%= attr.humanize %>" if <%= value %>
|
21
|
+
<%- else -%>
|
22
|
+
fill_in "<%= attr.humanize %>", with: <%= value %>
|
23
|
+
<%- end -%>
|
24
|
+
<%- end -%>
|
25
|
+
click_on "Create <%= human_name %>"
|
26
|
+
|
27
|
+
assert_text "<%= human_name %> was successfully created"
|
28
|
+
click_on "Back"
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_updating_<%= human_name %>
|
32
|
+
visit <%= plural_table_name %>_url
|
33
|
+
click_on "Edit", match: :first
|
34
|
+
|
35
|
+
<%- attributes_hash.each do |attr, value| -%>
|
36
|
+
<%- if boolean?(attr) -%>
|
37
|
+
check "<%= attr.humanize %>" if <%= value %>
|
38
|
+
<%- else -%>
|
39
|
+
fill_in "<%= attr.humanize %>", with: <%= value %>
|
40
|
+
<%- end -%>
|
41
|
+
<%- end -%>
|
42
|
+
click_on "Update <%= human_name %>"
|
43
|
+
|
44
|
+
assert_text "<%= human_name %> was successfully updated"
|
45
|
+
click_on "Back"
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_destroying_<%= human_name %>
|
49
|
+
visit <%= plural_table_name %>_url
|
50
|
+
page.accept_confirm do
|
51
|
+
click_on "Destroy", match: :first
|
52
|
+
end
|
53
|
+
|
54
|
+
assert_text "<%= human_name %> was successfully destroyed"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
<% end -%>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "generators/minitest"
|
4
|
+
|
5
|
+
module Minitest # :nodoc:
|
6
|
+
module Generators # :nodoc:
|
7
|
+
class SystemGenerator < Base # :nodoc:
|
8
|
+
check_class_collision suffix: "Test"
|
9
|
+
|
10
|
+
def create_test_files
|
11
|
+
unless File.exist?(File.join("test/application_system_test_case.rb"))
|
12
|
+
template "application_system_test_case.rb", File.join("test", "application_system_test_case.rb")
|
13
|
+
end
|
14
|
+
|
15
|
+
template "system_#{test_file_type}.rb", File.join("test/system", class_path, "#{file_name.pluralize}_test.rb")
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def file_name
|
21
|
+
@_file_name ||= super.sub(/_test\z/i, "")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
require "minitest/rails/capybara"
|
3
|
+
|
4
|
+
class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
|
5
|
+
driven_by :selenium, using: :chrome, screen_size: [1400, 1400]
|
6
|
+
|
7
|
+
register_spec_type(self) do |desc, *addl|
|
8
|
+
addl.include? :system
|
9
|
+
end
|
10
|
+
end
|
data/lib/minitest/rails.rb
CHANGED
@@ -4,102 +4,58 @@ require "minitest/spec"
|
|
4
4
|
require "minitest/mock"
|
5
5
|
require "minitest/hell" if ENV["MT_HELL"]
|
6
6
|
|
7
|
-
################################################################################
|
8
|
-
# Do we support old school controller tests?
|
9
|
-
################################################################################
|
10
|
-
|
11
|
-
module Minitest
|
12
|
-
module Rails
|
13
|
-
def self.controller_tests?
|
14
|
-
require "rails-controller-testing"
|
15
|
-
return true
|
16
|
-
rescue LoadError
|
17
|
-
return false
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
################################################################################
|
23
|
-
# Add and configure the spec DSL
|
24
|
-
################################################################################
|
25
|
-
|
26
7
|
require "active_support/test_case"
|
27
|
-
require "
|
8
|
+
require "active_support/testing/constant_lookup"
|
9
|
+
|
28
10
|
class ActiveSupport::TestCase
|
11
|
+
# Add and configure the spec DSL
|
29
12
|
# Remove describe method if present
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
13
|
+
if respond_to?(:describe) &&
|
14
|
+
method(:describe).owner == ActiveSupport::TestCase
|
15
|
+
class << self
|
16
|
+
remove_method :describe
|
17
|
+
end
|
18
|
+
end
|
34
19
|
|
35
20
|
# Add spec DSL
|
36
21
|
extend Minitest::Spec::DSL
|
37
22
|
|
38
23
|
# Resolve constants from the test name when using the spec DSL
|
39
|
-
include
|
40
|
-
end
|
24
|
+
include ActiveSupport::Testing::ConstantLookup
|
41
25
|
|
42
|
-
class
|
43
|
-
if defined?
|
44
|
-
# Use AS::TestCase for the base class when describing a model
|
26
|
+
# Use AS::TC for the base class when describing a model
|
27
|
+
if defined? ActiveRecord
|
45
28
|
register_spec_type(self) do |desc|
|
46
29
|
desc < ActiveRecord::Base if desc.is_a?(Class)
|
47
30
|
end
|
48
31
|
end
|
49
|
-
register_spec_type(self) do |desc, *addl|
|
50
|
-
addl.include? :model
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
if Minitest::Rails.controller_tests?
|
55
|
-
require "action_controller/test_case"
|
56
|
-
require "minitest/rails/controller"
|
57
|
-
class ActionController::TestCase
|
58
|
-
# Use AC::TestCase for the base class when describing a controller
|
59
|
-
register_spec_type(self) do |desc|
|
60
|
-
Class === desc && desc < ActionController::Metal
|
61
|
-
end
|
62
|
-
register_spec_type(/Controller( ?Test)?\z/i, self)
|
63
|
-
register_spec_type(self) do |desc, *addl|
|
64
|
-
addl.include? :controller
|
65
|
-
end
|
66
32
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
Class === constant && constant < ActionController::Metal
|
71
|
-
end
|
72
|
-
raise NameError.new("Unable to resolve controller for #{name}") if controller.nil?
|
73
|
-
controller
|
74
|
-
end
|
33
|
+
# Use AS::TC for the base class when described using :model
|
34
|
+
register_spec_type(self) do |_desc, *addl|
|
35
|
+
addl.include? :model
|
75
36
|
end
|
76
37
|
end
|
77
38
|
|
78
39
|
require "action_view/test_case"
|
79
|
-
class ActionView::TestCase
|
80
|
-
# Use AV::TestCase for the base class for helpers and views
|
81
|
-
register_spec_type(/(Helper( ?Test)?| View Test)\z/i, self)
|
82
|
-
register_spec_type(self) do |desc, *addl|
|
83
|
-
addl.include?(:view) ||
|
84
|
-
addl.include?(:helper)
|
85
|
-
end
|
86
40
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
end
|
41
|
+
class ActionView::TestCase
|
42
|
+
# Use AV::TC for the base class when described using :view or :helper
|
43
|
+
register_spec_type(self) do |_desc, *addl|
|
44
|
+
addl.include?(:view) || addl.include?(:helper)
|
92
45
|
end
|
93
46
|
end
|
94
47
|
|
95
48
|
if defined? ActiveJob
|
49
|
+
# TODO: require?
|
50
|
+
|
96
51
|
class ActiveJob::TestCase
|
97
|
-
# Use AJ::
|
52
|
+
# Use AJ::TC for the base when describing a job
|
98
53
|
register_spec_type(self) do |desc|
|
99
54
|
desc < ActiveJob::Base if desc.is_a?(Class)
|
100
55
|
end
|
101
|
-
|
102
|
-
|
56
|
+
|
57
|
+
# Use AJ::TC for the base class when described using :job
|
58
|
+
register_spec_type(self) do |_desc, *addl|
|
103
59
|
addl.include? :job
|
104
60
|
end
|
105
61
|
end
|
@@ -108,64 +64,73 @@ end
|
|
108
64
|
if defined? ActionMailer
|
109
65
|
require "action_mailer/test_helper"
|
110
66
|
require "action_mailer/test_case"
|
67
|
+
|
111
68
|
class ActionMailer::TestCase
|
112
|
-
# Use AM::
|
69
|
+
# Use AM::TC for the base class when describing a mailer
|
113
70
|
register_spec_type(self) do |desc|
|
114
71
|
desc < ActionMailer::Base if desc.is_a?(Class)
|
115
72
|
end
|
116
|
-
register_spec_type(/Mailer( ?Test)?\z/i, self)
|
117
|
-
register_spec_type(self) do |desc, *addl|
|
118
|
-
addl.include? :mailer
|
119
|
-
end
|
120
73
|
|
121
|
-
#
|
122
|
-
|
123
|
-
mailer
|
124
|
-
Class === constant && constant < ::ActionMailer::Base
|
125
|
-
end
|
126
|
-
raise ActionMailer::NonInferrableMailerError.new(name) if mailer.nil?
|
127
|
-
mailer
|
74
|
+
# Use AM::TC for the base class when described using :mailer
|
75
|
+
register_spec_type(self) do |_desc, *addl|
|
76
|
+
addl.include? :mailer
|
128
77
|
end
|
129
78
|
end
|
130
79
|
end
|
131
80
|
|
132
81
|
require "action_dispatch/testing/integration"
|
82
|
+
|
133
83
|
class ActionDispatch::IntegrationTest
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
register_spec_type(self) do |desc|
|
143
|
-
Class === desc && desc < ActionController::Metal
|
144
|
-
end
|
145
|
-
# Register by name, either Integration or Controller
|
146
|
-
register_spec_type(/(Integration|Controller)( ?Test)?\z/i, self)
|
147
|
-
register_spec_type(self) do |desc, *addl|
|
148
|
-
addl.include?(:integration) ||
|
149
|
-
addl.include?(:controller)
|
150
|
-
end
|
84
|
+
# Use AD:IT for the base class when describing a controller
|
85
|
+
register_spec_type(self) do |desc|
|
86
|
+
desc < ActionController::Metal if desc.is_a?(Class)
|
87
|
+
end
|
88
|
+
|
89
|
+
# Use AD:IT for the base class when described using :integration
|
90
|
+
register_spec_type(self) do |_desc, *addl|
|
91
|
+
addl.include? :integration
|
151
92
|
end
|
152
93
|
end
|
153
94
|
|
95
|
+
# TODO: Rails::Generators::TestCase require?
|
96
|
+
|
154
97
|
class Rails::Generators::TestCase
|
98
|
+
# Use R::G::TC for the base class when describing a generator
|
155
99
|
register_spec_type(self) do |desc|
|
156
100
|
desc < Rails::Generators::Base if desc.is_a?(Class)
|
157
101
|
end
|
158
|
-
|
159
|
-
|
102
|
+
|
103
|
+
# Use R::G::TC for the base class when described using :generator
|
104
|
+
register_spec_type(self) do |_desc, *addl|
|
160
105
|
addl.include? :generator
|
161
106
|
end
|
107
|
+
end
|
162
108
|
|
163
|
-
|
164
|
-
|
165
|
-
|
109
|
+
if defined? ActionCable
|
110
|
+
# TODO: require?
|
111
|
+
|
112
|
+
class ActionCable::Channel::TestCase
|
113
|
+
# Use AC::Ch::TC for the base class when describing a channel
|
114
|
+
register_spec_type(self) do |desc|
|
115
|
+
desc < ActionCable::Channel::Base if desc.is_a?(Class)
|
116
|
+
end
|
117
|
+
|
118
|
+
# Use AC::Ch::TC for the base class when described using :channel
|
119
|
+
register_spec_type(self) do |_desc, *addl|
|
120
|
+
addl.include? :channel
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
class ActionCable::Connection::TestCase
|
125
|
+
# Use AC::Co::TC for the base class when describing a connection
|
126
|
+
register_spec_type(self) do |desc|
|
127
|
+
desc < ActionCable::Connection::Base if desc.is_a?(Class)
|
128
|
+
end
|
129
|
+
|
130
|
+
# Use AC::Co::TC for the base class when described using :connection
|
131
|
+
register_spec_type(self) do |_desc, *addl|
|
132
|
+
addl.include? :connection
|
166
133
|
end
|
167
|
-
raise NameError.new("Unable to resolve generator for #{name}") if generator.nil?
|
168
|
-
generator
|
169
134
|
end
|
170
135
|
end
|
171
136
|
|
@@ -176,6 +141,12 @@ end
|
|
176
141
|
require "minitest/rails/assertions"
|
177
142
|
require "minitest/rails/expectations"
|
178
143
|
|
144
|
+
################################################################################
|
145
|
+
# Support Rails parallelize
|
146
|
+
################################################################################
|
147
|
+
|
148
|
+
require "minitest/rails/parallelize"
|
149
|
+
|
179
150
|
# :stopdoc:
|
180
151
|
|
181
152
|
################################################################################
|