minitest-rails 3.0.0 → 5.0.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 +5 -5
- data/CHANGELOG.md +5 -0
- data/LICENSE +1 -1
- data/README.md +94 -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 +19 -8
- data/lib/generators/minitest/install/templates/test/test_helper.rb.tt +16 -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 +21 -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/minitest/rails.rb +45 -108
- data/lib/minitest/rails/assertions.rb +5 -906
- data/lib/minitest/rails/assertions/action_dispatch.rb +356 -0
- data/lib/minitest/rails/assertions/action_mailer.rb +115 -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 +29 -0
- data/lib/minitest/rails/expectations.rb +4 -565
- data/lib/minitest/rails/expectations/action_dispatch.rb +307 -0
- data/lib/minitest/rails/expectations/action_mailer.rb +136 -0
- data/lib/minitest/rails/expectations/active_job.rb +182 -0
- data/lib/minitest/rails/expectations/active_support.rb +42 -0
- data/lib/minitest/rails/railtie.rb +3 -2
- data/lib/minitest/rails/version.rb +1 -1
- metadata +72 -89
- 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
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require "generators/minitest"
|
|
2
4
|
|
|
3
|
-
module Minitest
|
|
4
|
-
module Generators
|
|
5
|
-
class MailerGenerator < Base
|
|
5
|
+
module Minitest # :nodoc:
|
|
6
|
+
module Generators # :nodoc:
|
|
7
|
+
class MailerGenerator < Base # :nodoc:
|
|
6
8
|
argument :actions, type: :array, default: [], banner: "method method"
|
|
7
9
|
|
|
8
10
|
def check_class_collision
|
|
@@ -10,22 +12,17 @@ module Minitest
|
|
|
10
12
|
end
|
|
11
13
|
|
|
12
14
|
def create_test_files
|
|
13
|
-
|
|
14
|
-
template_file = "mailer_spec.rb"
|
|
15
|
-
else
|
|
16
|
-
template_file = "mailer_test.rb"
|
|
17
|
-
end
|
|
18
|
-
template template_file, File.join("test/mailers", class_path, "#{file_name}_mailer_test.rb")
|
|
15
|
+
template "functional_#{test_file_type}.rb", File.join("test/mailers", class_path, "#{file_name}_mailer_test.rb")
|
|
19
16
|
end
|
|
20
17
|
|
|
21
18
|
def create_preview_files
|
|
22
19
|
template "preview.rb", File.join("test/mailers/previews", class_path, "#{file_name}_mailer_preview.rb")
|
|
23
20
|
end
|
|
24
21
|
|
|
25
|
-
|
|
22
|
+
private
|
|
26
23
|
|
|
27
24
|
def file_name
|
|
28
|
-
@_file_name ||= super.
|
|
25
|
+
@_file_name ||= super.sub(/_mailer\z/i, "")
|
|
29
26
|
end
|
|
30
27
|
end
|
|
31
28
|
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
require "test_helper"
|
|
2
|
+
|
|
3
|
+
<% module_namespacing do -%>
|
|
4
|
+
describe <%= class_name %>Mailer do
|
|
5
|
+
<% actions.each do |action| -%>
|
|
6
|
+
it "creates <%= action %> email" do
|
|
7
|
+
mail = <%= class_name %>Mailer.<%= action %>
|
|
8
|
+
mail.subject.must_equal <%= action.to_s.humanize.inspect %>
|
|
9
|
+
mail.to.must_equal ["to@example.org"]
|
|
10
|
+
mail.from.must_equal ["from@example.com"]
|
|
11
|
+
mail.body.encoded.must_equal "Hi"
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
<% end -%>
|
|
15
|
+
<% if actions.blank? -%>
|
|
16
|
+
# it "does a thing" do
|
|
17
|
+
# <%= spec_expectation_monad %>(1+1).must_equal 2
|
|
18
|
+
# end
|
|
19
|
+
<% end -%>
|
|
20
|
+
end
|
|
21
|
+
<% end -%>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'test_helper'
|
|
2
2
|
|
|
3
3
|
<% module_namespacing do -%>
|
|
4
4
|
class <%= class_name %>MailerTest < ActionMailer::TestCase
|
|
@@ -13,8 +13,8 @@ class <%= class_name %>MailerTest < ActionMailer::TestCase
|
|
|
13
13
|
|
|
14
14
|
<% end -%>
|
|
15
15
|
<% if actions.blank? -%>
|
|
16
|
-
# def
|
|
17
|
-
#
|
|
16
|
+
# def test_truth
|
|
17
|
+
# assert true
|
|
18
18
|
# end
|
|
19
19
|
<% end -%>
|
|
20
20
|
end
|
|
File without changes
|
|
@@ -1,22 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require "generators/minitest"
|
|
2
4
|
|
|
3
|
-
module Minitest
|
|
4
|
-
module Generators
|
|
5
|
-
class ModelGenerator < Base
|
|
6
|
-
RESERVED_YAML_KEYWORDS = %w
|
|
5
|
+
module Minitest # :nodoc:
|
|
6
|
+
module Generators # :nodoc:
|
|
7
|
+
class ModelGenerator < Base # :nodoc:
|
|
8
|
+
RESERVED_YAML_KEYWORDS = %w[y yes n no true false on off null].freeze
|
|
7
9
|
|
|
8
10
|
argument :attributes, type: :array, default: [], banner: "field:type field:type"
|
|
9
|
-
class_option :fixture, type: :boolean
|
|
11
|
+
class_option :fixture, type: :boolean
|
|
10
12
|
|
|
11
13
|
check_class_collision suffix: "Test"
|
|
12
14
|
|
|
13
15
|
def create_test_file
|
|
14
|
-
|
|
15
|
-
template_file = "model_spec.rb"
|
|
16
|
-
else
|
|
17
|
-
template_file = "model_test.rb"
|
|
18
|
-
end
|
|
19
|
-
template template_file, File.join("test/models", class_path, "#{file_name}_test.rb")
|
|
16
|
+
template "unit_#{test_file_type}.rb", File.join("test/models", class_path, "#{file_name}_test.rb")
|
|
20
17
|
end
|
|
21
18
|
|
|
22
19
|
hook_for :fixture_replacement
|
|
@@ -29,7 +26,7 @@ module Minitest
|
|
|
29
26
|
|
|
30
27
|
private
|
|
31
28
|
|
|
32
|
-
def yaml_key_value
|
|
29
|
+
def yaml_key_value key, value
|
|
33
30
|
if RESERVED_YAML_KEYWORDS.include?(key.downcase)
|
|
34
31
|
"'#{key}': #{value}"
|
|
35
32
|
else
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
<%= name %>:
|
|
5
5
|
<% attributes.each do |attribute| -%>
|
|
6
6
|
<%- if attribute.password_digest? -%>
|
|
7
|
-
password_digest: <%%= BCrypt::Password.create(
|
|
7
|
+
password_digest: <%%= BCrypt::Password.create('secret') %>
|
|
8
8
|
<%- elsif attribute.reference? -%>
|
|
9
|
-
<%= yaml_key_value(attribute.column_name.sub(/_id$/,
|
|
9
|
+
<%= yaml_key_value(attribute.column_name.sub(/_id$/, ''), attribute.default || name) %>
|
|
10
10
|
<%- else -%>
|
|
11
11
|
<%= yaml_key_value(attribute.column_name, attribute.default) %>
|
|
12
12
|
<%- end -%>
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
<% else -%>
|
|
19
19
|
|
|
20
20
|
# This model initially had no columns defined. If you add columns to the
|
|
21
|
-
# model remove the
|
|
21
|
+
# model remove the '{}' from the fixture names and add the columns immediately
|
|
22
22
|
# below each fixture, per the syntax in the comments below
|
|
23
23
|
#
|
|
24
24
|
one: {}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "generators/minitest"
|
|
4
|
+
|
|
5
|
+
module Minitest # :nodoc:
|
|
6
|
+
module Generators # :nodoc:
|
|
7
|
+
class PluginGenerator < Base # :nodoc:
|
|
8
|
+
check_class_collision suffix: "Test"
|
|
9
|
+
|
|
10
|
+
def create_test_files
|
|
11
|
+
directory ".", "test"
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require 'test_helper'
|
|
2
|
+
|
|
3
|
+
<%- if options[:spec] -%>
|
|
4
|
+
describe <%= class_name %> do
|
|
5
|
+
# it "does a thing" do
|
|
6
|
+
# <%= spec_expectation_monad %>(1+1).must_equal 2
|
|
7
|
+
# end
|
|
8
|
+
end
|
|
9
|
+
<%- else -%>
|
|
10
|
+
class <%= class_name %>Test < ActiveSupport::TestCase
|
|
11
|
+
# def test_truth
|
|
12
|
+
# assert true
|
|
13
|
+
# end
|
|
14
|
+
end
|
|
15
|
+
<%- end -%>
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require "generators/minitest"
|
|
2
4
|
require "rails/generators/resource_helpers"
|
|
3
5
|
|
|
4
|
-
module Minitest
|
|
5
|
-
module Generators
|
|
6
|
-
class ScaffoldGenerator < Base
|
|
6
|
+
module Minitest # :nodoc:
|
|
7
|
+
module Generators # :nodoc:
|
|
8
|
+
class ScaffoldGenerator < Base # :nodoc:
|
|
7
9
|
include ::Rails::Generators::ResourceHelpers
|
|
8
10
|
|
|
9
11
|
check_class_collision suffix: "ControllerTest"
|
|
@@ -14,19 +16,7 @@ module Minitest
|
|
|
14
16
|
argument :attributes, type: :array, default: [], banner: "field:type field:type"
|
|
15
17
|
|
|
16
18
|
def create_test_files
|
|
17
|
-
|
|
18
|
-
if options[:spec]
|
|
19
|
-
template_file = "api_controller_spec.rb"
|
|
20
|
-
else
|
|
21
|
-
template_file = "api_controller_test.rb"
|
|
22
|
-
end
|
|
23
|
-
else
|
|
24
|
-
if options[:spec]
|
|
25
|
-
template_file = "controller_spec.rb"
|
|
26
|
-
else
|
|
27
|
-
template_file = "controller_test.rb"
|
|
28
|
-
end
|
|
29
|
-
end
|
|
19
|
+
template_file = options.api? ? "api_functional_#{test_file_type}.rb" : "functional_#{test_file_type}.rb"
|
|
30
20
|
template template_file,
|
|
31
21
|
File.join("test/controllers", controller_class_path, "#{controller_file_name}_controller_test.rb")
|
|
32
22
|
end
|
|
@@ -34,7 +24,7 @@ module Minitest
|
|
|
34
24
|
def fixture_name
|
|
35
25
|
@fixture_name ||=
|
|
36
26
|
if mountable_engine?
|
|
37
|
-
|
|
27
|
+
(namespace_dirs + [table_name]).join("_")
|
|
38
28
|
else
|
|
39
29
|
table_name
|
|
40
30
|
end
|
|
@@ -42,17 +32,25 @@ module Minitest
|
|
|
42
32
|
|
|
43
33
|
private
|
|
44
34
|
|
|
35
|
+
def attributes_string
|
|
36
|
+
attributes_hash.map { |k, v| "#{k}: #{v}" }.join(", ")
|
|
37
|
+
end
|
|
38
|
+
|
|
45
39
|
def attributes_hash
|
|
46
|
-
return if attributes_names.empty?
|
|
40
|
+
return {} if attributes_names.empty?
|
|
47
41
|
|
|
48
42
|
attributes_names.map do |name|
|
|
49
|
-
if %w
|
|
50
|
-
|
|
43
|
+
if %w[password password_confirmation].include?(name) && attributes.any?(&:password_digest?)
|
|
44
|
+
[name.to_s, "'secret'"]
|
|
51
45
|
else
|
|
52
|
-
|
|
53
|
-
"#{name}: #{singular_table_name}.#{name}"
|
|
46
|
+
[name.to_s, "@#{singular_table_name}.#{name}"]
|
|
54
47
|
end
|
|
55
|
-
end.sort.
|
|
48
|
+
end.sort.to_h
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def boolean? name
|
|
52
|
+
attribute = attributes.find { |attr| attr.name == name }
|
|
53
|
+
attribute&.type == :boolean
|
|
56
54
|
end
|
|
57
55
|
end
|
|
58
56
|
end
|
|
@@ -0,0 +1,42 @@
|
|
|
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, as: :json
|
|
13
|
+
must_respond_with :success
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it "should create <%= singular_table_name %>" do
|
|
17
|
+
<%= spec_expectation_monad %> do
|
|
18
|
+
post <%= index_helper %>_url, params: { <%= "#{singular_table_name}: { #{attributes_string} }" %> }, as: :json
|
|
19
|
+
end.must_differ "<%= class_name %>.count"
|
|
20
|
+
|
|
21
|
+
must_respond_with 201
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it "should show <%= singular_table_name %>" do
|
|
25
|
+
get <%= show_helper %>, as: :json
|
|
26
|
+
must_respond_with :success
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it "should update <%= singular_table_name %>" do
|
|
30
|
+
patch <%= show_helper %>, params: { <%= "#{singular_table_name}: { #{attributes_string} }" %> }, as: :json
|
|
31
|
+
must_respond_with 200
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it "should destroy <%= singular_table_name %>" do
|
|
35
|
+
<%= spec_expectation_monad %> do
|
|
36
|
+
delete <%= show_helper %>, as: :json
|
|
37
|
+
end.must_differ "<%= class_name %>.count", -1
|
|
38
|
+
|
|
39
|
+
must_respond_with 204
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
<% end -%>
|
|
@@ -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 -%>
|