minitest-rails 5.1.0 → 7.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +10 -2
  3. data/README.md +47 -6
  4. data/lib/generators/minitest/controller/controller_generator.rb +2 -0
  5. data/lib/generators/minitest/controller/templates/functional_spec.rb.tt +2 -2
  6. data/lib/generators/minitest/controller/templates/functional_test.rb.tt +1 -1
  7. data/lib/generators/minitest/generator/generator_generator.rb +4 -2
  8. data/lib/generators/minitest/generator/templates/generator_spec.rb.tt +2 -2
  9. data/lib/generators/minitest/install/install_generator.rb +1 -0
  10. data/lib/generators/minitest/install/templates/test/channels/application_cable/connection_test.rb.tt +25 -0
  11. data/lib/generators/minitest/install/templates/test/test_helper.rb.tt +14 -6
  12. data/lib/generators/minitest/integration/templates/integration_spec.rb.tt +1 -1
  13. data/lib/generators/minitest/integration/templates/integration_test.rb.tt +1 -1
  14. data/lib/generators/minitest/job/templates/unit_spec.rb.tt +1 -1
  15. data/lib/generators/minitest/job/templates/unit_test.rb.tt +1 -1
  16. data/lib/generators/minitest/mailer/templates/functional_test.rb.tt +1 -1
  17. data/lib/generators/minitest/model/templates/unit_test.rb.tt +1 -1
  18. data/lib/generators/minitest/plugin/templates/%file_name%_test.rb.tt +1 -1
  19. data/lib/generators/minitest/scaffold/scaffold_generator.rb +9 -4
  20. data/lib/generators/minitest/scaffold/templates/api_functional_spec.rb.tt +3 -3
  21. data/lib/generators/minitest/scaffold/templates/api_functional_test.rb.tt +3 -3
  22. data/lib/generators/minitest/scaffold/templates/functional_spec.rb.tt +5 -5
  23. data/lib/generators/minitest/scaffold/templates/functional_test.rb.tt +5 -5
  24. data/lib/generators/minitest/scaffold/templates/system_spec.rb.tt +10 -12
  25. data/lib/generators/minitest/scaffold/templates/system_test.rb.tt +6 -8
  26. data/lib/generators/minitest/system/templates/system_spec.rb.tt +3 -4
  27. data/lib/generators/minitest/system/templates/system_test.rb.tt +2 -3
  28. data/lib/generators/minitest.rb +1 -1
  29. data/lib/minitest/rails/assertions/action_cable.rb +232 -0
  30. data/lib/minitest/rails/assertions/action_mailer.rb +42 -4
  31. data/lib/minitest/rails/assertions/active_job.rb +5 -0
  32. data/lib/minitest/rails/assertions/active_support.rb +4 -4
  33. data/lib/minitest/rails/assertions.rb +1 -0
  34. data/lib/minitest/rails/capybara.rb +1 -0
  35. data/lib/minitest/rails/expectations/action_cable.rb +197 -0
  36. data/lib/minitest/rails/expectations/action_mailer.rb +43 -4
  37. data/lib/minitest/rails/expectations/active_job.rb +4 -0
  38. data/lib/minitest/rails/expectations/active_support.rb +4 -4
  39. data/lib/minitest/rails/expectations.rb +1 -0
  40. data/lib/minitest/rails/parallelize.rb +41 -0
  41. data/lib/minitest/rails/version.rb +1 -1
  42. data/lib/minitest/rails.rb +44 -8
  43. metadata +26 -21
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b1104f99ae200b725d2b60309b6ee1868f2bf15075386cc16073f39e24d3aaf3
4
- data.tar.gz: c4bda57b55878bcf5fb0a057ca7f7f888b60108eb4ae47d4b1db1098b5ae6d63
3
+ metadata.gz: 12dd18b8d1565450f168529368e96087db538ed383b72d0f246c6c6303587cd5
4
+ data.tar.gz: b1887d75856ca2908921d78060b0eb08a7b822d4c848ee9b86b07b82e34d08f2
5
5
  SHA512:
6
- metadata.gz: f8ba06eab31eeabe204b9fb51e87594d33dd10964f95952510b04dee8089c38b883cd19979d2d6604e296a19a4d9afbec3aee2da33332ead155416465a628288
7
- data.tar.gz: 2d0c87af3c79e3774c1467b9811660ed0c6eef5101f2805d0b93fc90486fce1a2bb8610496db696e0b78dff7a4cb512a684817c7173c6575908603809349b3e9
6
+ metadata.gz: cb9f831b0073ce58154763cf71b9f2f2ea60be3b150395ab13ad3ce1230424b2facd00e4e165c6505f41dae738190846d257feed1838608a374383ed13971ea0
7
+ data.tar.gz: ae95f363639484e1669464fc46fafd690d76cfb4db18274c72c609f5eaae4b7d63e828ec7a2519bb10be988626b9ea1365410a86e54918e770a7a3b5fec3aea9
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changes
2
2
 
3
- ### 5.1.0 / upcoming...
3
+ ### 7.1.0 / 2023-10-26
4
4
 
5
- * ...
5
+ Support Rails 7.1.
6
+
7
+ ### 7.0.0 / 2022-04-25
8
+
9
+ Support Rails 7.0.
10
+
11
+ ### 6.1.0 / 2020-12-14
12
+
13
+ Support Rails 6.1.
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # minitest-rails
2
2
 
3
- Minitest integration for Rails 5.1
3
+ Minitest integration for Rails 7.1
4
4
 
5
- [![Build Status](https://secure.travis-ci.org/blowmage/minitest-rails.png)](http://travis-ci.org/blowmage/minitest-rails)
5
+ [![CI](https://github.com/blowmage/minitest-rails/actions/workflows/ci.yml/badge.svg)](https://github.com/blowmage/minitest-rails/actions/workflows/ci.yml)
6
6
  [![Code Climate](https://codeclimate.com/github/blowmage/minitest-rails.png)](https://codeclimate.com/github/blowmage/minitest-rails)
7
7
 
8
8
  ## Install
@@ -19,13 +19,54 @@ Create a new rails app:
19
19
 
20
20
  `rails new MyApp`
21
21
 
22
- ### Update Gemfile
22
+ ### Choosing a version
23
23
 
24
- This version is for Rails 5.1 applications. Update your application to use the
25
- gem by adding the following to your Gemfile:
24
+ This gem follows the versioning of Rails.
25
+ If you are running Rails 7.1, specify the corresponding 7.1 release in the Gemfile.
26
+ For example:
26
27
 
27
28
  ```ruby
28
- gem "minitest-rails", "~> 5.1.0"
29
+ gem "minitest-rails", "~> 7.1.0"
30
+ ```
31
+
32
+ If you are running Rails 7.0, specify the corresponding 7.0 release in the Gemfile.
33
+ For example, if you are using Rails 6.1 you will specify:
34
+
35
+ ```ruby
36
+ gem "minitest-rails", "~> 7.0.0"
37
+ ```
38
+
39
+ If you are running Rails 6.x, specify the corresponding 6.x release in the Gemfile.
40
+ For example, if you are using Rails 6.1 you will specify:
41
+
42
+ ```ruby
43
+ gem "minitest-rails", "~> 6.1.0"
44
+ ```
45
+
46
+ If you are running Rails 5.x, specify the corresponding 5.x release in the Gemfile.
47
+ For example, if you are using Rails 5.2 you will specify:
48
+
49
+ ```ruby
50
+ gem "minitest-rails", "~> 5.2.0"
51
+ ```
52
+
53
+ Or, if you prefer to run the previous release for Rails 5.x, specify the 3.x release in the Gemfile:
54
+
55
+ ```ruby
56
+ gem "minitest-rails", "~> 3.0"
57
+ ```
58
+
59
+ If you are running Rails 4.1 or 4.2, specify the 2.x release in the Gemfile:
60
+
61
+ ```ruby
62
+ gem "minitest-rails", "~> 2.0"
63
+ ```
64
+
65
+ If you are running Rails 4.0 or earlier, you really need to upgrade.
66
+ But if you are you need to specify the 1.x release in the Gemfile:
67
+
68
+ ```ruby
69
+ gem "minitest-rails", "~> 1.0"
29
70
  ```
30
71
 
31
72
  ### Installing
@@ -6,6 +6,8 @@ module Minitest # :nodoc:
6
6
  module Generators # :nodoc:
7
7
  class ControllerGenerator < Base # :nodoc:
8
8
  argument :actions, type: :array, default: [], banner: "action action"
9
+ class_option :skip_routes, type: :boolean
10
+
9
11
  check_class_collision suffix: "ControllerTest"
10
12
 
11
13
  def create_test_files
@@ -12,11 +12,11 @@ describe <%= class_name %>Controller do
12
12
  # end
13
13
  <% else -%>
14
14
  <% actions.each do |action| -%>
15
- it "must get <%= action %>" do
15
+ it "gets <%= action %>" do
16
16
  get <%= url_helper_prefix %>_<%= action %>_url
17
17
  must_respond_with :success
18
18
  end
19
-
19
+ <%= "\n" unless action == actions.last -%>
20
20
  <% end -%>
21
21
  <% end -%>
22
22
  end
@@ -16,7 +16,7 @@ class <%= class_name %>ControllerTest < ActionDispatch::IntegrationTest
16
16
  get <%= url_helper_prefix %>_<%= action %>_url
17
17
  assert_response :success
18
18
  end
19
-
19
+ <%= "\n" unless action == actions.last -%>
20
20
  <% end -%>
21
21
  <% end -%>
22
22
  end
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "generators/minitest"
2
4
 
3
- module Minitest
4
- module Generators
5
+ module Minitest # :nodoc:
6
+ module Generators # :nodoc:
5
7
  class GeneratorGenerator < Base # :nodoc:
6
8
  check_class_collision suffix: "GeneratorTest"
7
9
 
@@ -2,8 +2,8 @@ require "test_helper"
2
2
  require "<%= generator_path %>"
3
3
 
4
4
  <% module_namespacing do -%>
5
- describe <%= class_name %>Generator do
6
- #tests <%= class_name %>Generator
5
+ describe <%= class_name %>Generator, :generator do
6
+ tests <%= class_name %>Generator
7
7
  destination Rails.root.join("tmp/generators")
8
8
  setup :prepare_destination
9
9
 
@@ -26,6 +26,7 @@ module Minitest
26
26
  empty_directory_with_keep_file "test/helpers"
27
27
  empty_directory_with_keep_file "test/integration"
28
28
 
29
+ template "test/channels/application_cable/connection_test.rb"
29
30
  template "test/application_system_test_case.rb"
30
31
  template "test/test_helper.rb"
31
32
  end
@@ -0,0 +1,25 @@
1
+ require "test_helper"
2
+
3
+ <%- if options[:spec] -%>
4
+ describe "ApplicationCable Connection", :connection do
5
+ # it "connects with cookies" do
6
+ # cookies.signed[:user_id] = 42
7
+ #
8
+ # connect
9
+ #
10
+ # connection.user_id.must_equal "42"
11
+ # end
12
+ end
13
+ <%- else -%>
14
+ module ApplicationCable
15
+ class ConnectionTest < ActionCable::Connection::TestCase
16
+ # test "connects with cookies" do
17
+ # cookies.signed[:user_id] = 42
18
+ #
19
+ # connect
20
+ #
21
+ # assert_equal connection.user_id, "42"
22
+ # end
23
+ end
24
+ end
25
+ <%- end -%>
@@ -1,16 +1,24 @@
1
1
  ENV["RAILS_ENV"] ||= "test"
2
+ # Consider setting MT_NO_EXPECTATIONS to not add expectations to Object.
3
+ # ENV["MT_NO_EXPECTATIONS"] = "true"
2
4
  require_relative "../config/environment"
3
5
  require "rails/test_help"
4
6
  require "minitest/rails"
5
7
 
6
- # Consider setting MT_NO_EXPECTATIONS to not add expectations to Object.
7
- # ENV["MT_NO_EXPECTATIONS"] = true
8
+ module ActiveSupport
9
+ class TestCase
10
+ # Run tests in parallel with specified workers
11
+ <% if Process.respond_to?(:fork) && !Gem.win_platform? -%>
12
+ parallelize(workers: :number_of_processors)
13
+ <%- else -%>
14
+ parallelize(workers: :number_of_processors, with: :threads)
15
+ <% end -%>
8
16
 
9
- class ActiveSupport::TestCase
10
17
  <% unless options[:skip_active_record] -%>
11
- # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
12
- fixtures :all
18
+ # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
19
+ fixtures :all
13
20
 
14
21
  <% end -%>
15
- # Add more helper methods to be used by all tests here...
22
+ # Add more helper methods to be used by all tests here...
23
+ end
16
24
  end
@@ -1,4 +1,4 @@
1
- require 'test_helper'
1
+ require "test_helper"
2
2
 
3
3
  <% module_namespacing do -%>
4
4
  describe "<%= human_name %>", :integration do
@@ -1,4 +1,4 @@
1
- require 'test_helper'
1
+ require "test_helper"
2
2
 
3
3
  <% module_namespacing do -%>
4
4
  class <%= class_name %>Test < ActionDispatch::IntegrationTest
@@ -1,4 +1,4 @@
1
- require 'test_helper'
1
+ require "test_helper"
2
2
 
3
3
  <% module_namespacing do -%>
4
4
  describe <%= class_name %>Job do
@@ -1,4 +1,4 @@
1
- require 'test_helper'
1
+ require "test_helper"
2
2
 
3
3
  <% module_namespacing do -%>
4
4
  class <%= class_name %>JobTest < ActiveJob::TestCase
@@ -1,4 +1,4 @@
1
- require 'test_helper'
1
+ require "test_helper"
2
2
 
3
3
  <% module_namespacing do -%>
4
4
  class <%= class_name %>MailerTest < ActionMailer::TestCase
@@ -1,4 +1,4 @@
1
- require 'test_helper'
1
+ require "test_helper"
2
2
 
3
3
  <% module_namespacing do -%>
4
4
  class <%= class_name %>Test < ActiveSupport::TestCase
@@ -1,4 +1,4 @@
1
- require 'test_helper'
1
+ require "test_helper"
2
2
 
3
3
  <%- if options[:spec] -%>
4
4
  describe <%= class_name %> do
@@ -11,7 +11,7 @@ module Minitest # :nodoc:
11
11
  check_class_collision suffix: "ControllerTest"
12
12
 
13
13
  class_option :api, type: :boolean,
14
- desc: "Generates API functional tests"
14
+ desc: "Generate API functional tests"
15
15
 
16
16
  class_option :system_tests, type: :string,
17
17
  desc: "Skip system test files"
@@ -46,10 +46,10 @@ module Minitest # :nodoc:
46
46
  def attributes_hash
47
47
  return {} if attributes_names.empty?
48
48
 
49
- attributes_names.map do |name|
49
+ attributes_names.filter_map do |name|
50
50
  if %w[password password_confirmation].include?(name) && attributes.any?(&:password_digest?)
51
- [name.to_s, "'secret'"]
52
- else
51
+ [name.to_s, '"secret"']
52
+ elsif !virtual?(name)
53
53
  [name.to_s, "@#{singular_table_name}.#{name}"]
54
54
  end
55
55
  end.sort.to_h
@@ -59,6 +59,11 @@ module Minitest # :nodoc:
59
59
  attribute = attributes.find { |attr| attr.name == name }
60
60
  attribute&.type == :boolean
61
61
  end
62
+
63
+ def virtual? name
64
+ attribute = attributes.find { |attr| attr.name == name }
65
+ attribute&.virtual?
66
+ end
62
67
  end
63
68
  end
64
69
  end
@@ -18,7 +18,7 @@ describe <%= controller_class_name %>Controller do
18
18
  post <%= index_helper %>_url, params: { <%= "#{singular_table_name}: { #{attributes_string} }" %> }, as: :json
19
19
  end.must_differ "<%= class_name %>.count"
20
20
 
21
- must_respond_with 201
21
+ must_respond_with :created
22
22
  end
23
23
 
24
24
  it "should show <%= singular_table_name %>" do
@@ -28,7 +28,7 @@ describe <%= controller_class_name %>Controller do
28
28
 
29
29
  it "should update <%= singular_table_name %>" do
30
30
  patch <%= show_helper %>, params: { <%= "#{singular_table_name}: { #{attributes_string} }" %> }, as: :json
31
- must_respond_with 200
31
+ must_respond_with :success
32
32
  end
33
33
 
34
34
  it "should destroy <%= singular_table_name %>" do
@@ -36,7 +36,7 @@ describe <%= controller_class_name %>Controller do
36
36
  delete <%= show_helper %>, as: :json
37
37
  end.must_differ "<%= class_name %>.count", -1
38
38
 
39
- must_respond_with 204
39
+ must_respond_with :no_content
40
40
  end
41
41
  end
42
42
  <% end -%>
@@ -20,7 +20,7 @@ class <%= controller_class_name %>ControllerTest < ActionDispatch::IntegrationTe
20
20
  post <%= index_helper %>_url, params: { <%= "#{singular_table_name}: { #{attributes_string} }" %> }, as: :json
21
21
  end
22
22
 
23
- assert_response 201
23
+ assert_response :created
24
24
  end
25
25
 
26
26
  def test_show_<%= singular_table_name %>
@@ -30,7 +30,7 @@ class <%= controller_class_name %>ControllerTest < ActionDispatch::IntegrationTe
30
30
 
31
31
  def test_update_<%= singular_table_name %>
32
32
  patch <%= show_helper %>, params: { <%= "#{singular_table_name}: { #{attributes_string} }" %> }, as: :json
33
- assert_response 200
33
+ assert_response :success
34
34
  end
35
35
 
36
36
  def test_destroy_<%= singular_table_name %>
@@ -38,7 +38,7 @@ class <%= controller_class_name %>ControllerTest < ActionDispatch::IntegrationTe
38
38
  delete <%= show_helper %>, as: :json
39
39
  end
40
40
 
41
- assert_response 204
41
+ assert_response :no_content
42
42
  end
43
43
  end
44
44
  <% end -%>
@@ -9,7 +9,7 @@ describe <%= controller_class_name %>Controller do
9
9
  let(:<%= singular_table_name %>) { <%= fixture_name %>(:one) }
10
10
 
11
11
  it "should get index" do
12
- get <%= index_helper %>_url
12
+ get <%= index_helper(type: :url) %>
13
13
  must_respond_with :success
14
14
  end
15
15
 
@@ -20,10 +20,10 @@ describe <%= controller_class_name %>Controller do
20
20
 
21
21
  it "should create <%= singular_table_name %>" do
22
22
  assert_difference("<%= class_name %>.count") do
23
- post <%= index_helper %>_url, params: { <%= "#{singular_table_name}: { #{attributes_string} }" %> }
23
+ post <%= index_helper(type: :url) %>, params: { <%= "#{singular_table_name}: { #{attributes_string} }" %> }
24
24
  end
25
25
 
26
- must_redirect_to <%= singular_table_name %>_url(<%= class_name %>.last)
26
+ must_redirect_to <%= show_helper("#{class_name}.last") %>
27
27
  end
28
28
 
29
29
  it "should show <%= singular_table_name %>" do
@@ -38,7 +38,7 @@ describe <%= controller_class_name %>Controller do
38
38
 
39
39
  it "should update <%= singular_table_name %>" do
40
40
  patch <%= show_helper %>, params: { <%= "#{singular_table_name}: { #{attributes_string} }" %> }
41
- must_redirect_to <%= singular_table_name %>_url(<%= "#{singular_table_name}" %>)
41
+ must_redirect_to <%= show_helper %>
42
42
  end
43
43
 
44
44
  it "should destroy <%= singular_table_name %>" do
@@ -46,7 +46,7 @@ describe <%= controller_class_name %>Controller do
46
46
  delete <%= show_helper %>
47
47
  end
48
48
 
49
- must_redirect_to <%= index_helper %>_url
49
+ must_redirect_to <%= index_helper(type: :url) %>
50
50
  end
51
51
  end
52
52
  <% end -%>
@@ -11,7 +11,7 @@ class <%= controller_class_name %>ControllerTest < ActionDispatch::IntegrationTe
11
11
  end
12
12
 
13
13
  def test_get_index
14
- get <%= index_helper %>_url
14
+ get <%= index_helper(type: :url) %>
15
15
  assert_response :success
16
16
  end
17
17
 
@@ -22,10 +22,10 @@ class <%= controller_class_name %>ControllerTest < ActionDispatch::IntegrationTe
22
22
 
23
23
  def test_create_<%= singular_table_name %>
24
24
  assert_difference("<%= class_name %>.count") do
25
- post <%= index_helper %>_url, params: { <%= "#{singular_table_name}: { #{attributes_string} }" %> }
25
+ post <%= index_helper(type: :url) %>, params: { <%= "#{singular_table_name}: { #{attributes_string} }" %> }
26
26
  end
27
27
 
28
- assert_redirected_to <%= singular_table_name %>_url(<%= class_name %>.last)
28
+ assert_redirected_to <%= show_helper("#{class_name}.last") %>
29
29
  end
30
30
 
31
31
  def test_show_<%= singular_table_name %>
@@ -40,7 +40,7 @@ class <%= controller_class_name %>ControllerTest < ActionDispatch::IntegrationTe
40
40
 
41
41
  def test_update_<%= singular_table_name %>
42
42
  patch <%= show_helper %>, params: { <%= "#{singular_table_name}: { #{attributes_string} }" %> }
43
- assert_redirected_to <%= singular_table_name %>_url(<%= "@#{singular_table_name}" %>)
43
+ assert_redirected_to <%= show_helper %>
44
44
  end
45
45
 
46
46
  def test_destroy_<%= singular_table_name %>
@@ -48,7 +48,7 @@ class <%= controller_class_name %>ControllerTest < ActionDispatch::IntegrationTe
48
48
  delete <%= show_helper %>
49
49
  end
50
50
 
51
- assert_redirected_to <%= index_helper %>_url
51
+ assert_redirected_to <%= index_helper(type: :url) %>
52
52
  end
53
53
  end
54
54
  <% end -%>
@@ -4,14 +4,14 @@ require "application_system_test_case"
4
4
  describe "<%= class_name.pluralize %>", :system do
5
5
  let(:<%= singular_table_name %>) { <%= fixture_name %>(:one) }
6
6
 
7
- it "visiting the index" do
7
+ it "visits the index" do
8
8
  visit <%= plural_table_name %>_url
9
- assert_selector "h1", text: "<%= class_name.pluralize.titleize %>"
9
+ assert_selector "h1", text: "<%= human_name.pluralize %>"
10
10
  end
11
11
 
12
- it "creating a <%= human_name %>" do
12
+ it "creates a <%= human_name %>" do
13
13
  visit <%= plural_table_name %>_url
14
- click_on "New <%= class_name.titleize %>"
14
+ click_on "New <%= human_name.downcase %>"
15
15
 
16
16
  <%- attributes_hash.each do |attr, value| -%>
17
17
  <%- if boolean?(attr) -%>
@@ -26,9 +26,9 @@ describe "<%= class_name.pluralize %>", :system do
26
26
  click_on "Back"
27
27
  end
28
28
 
29
- it "updating a <%= human_name %>" do
30
- visit <%= plural_table_name %>_url
31
- click_on "Edit", match: :first
29
+ it "updates a <%= human_name %>" do
30
+ visit <%= singular_table_name %>_url(@<%= singular_table_name %>)
31
+ click_on "Edit this <%= human_name.downcase %>", match: :first
32
32
 
33
33
  <%- attributes_hash.each do |attr, value| -%>
34
34
  <%- if boolean?(attr) -%>
@@ -43,11 +43,9 @@ describe "<%= class_name.pluralize %>", :system do
43
43
  click_on "Back"
44
44
  end
45
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
46
+ it "destroys a <%= human_name %>" do
47
+ visit <%= singular_table_name %>_url(@<%= singular_table_name %>)
48
+ click_on "Destroy this <%= human_name.downcase %>", match: :first
51
49
 
52
50
  assert_text "<%= human_name %> was successfully destroyed"
53
51
  end
@@ -8,12 +8,12 @@ class <%= class_name.pluralize %>Test < ApplicationSystemTestCase
8
8
 
9
9
  def test_visiting_index
10
10
  visit <%= plural_table_name %>_url
11
- assert_selector "h1", text: "<%= class_name.pluralize.titleize %>"
11
+ assert_selector "h1", text: "<%= human_name.pluralize %>"
12
12
  end
13
13
 
14
14
  def test_creating_<%= human_name %>
15
15
  visit <%= plural_table_name %>_url
16
- click_on "New <%= class_name.titleize %>"
16
+ click_on "New <%= human_name.downcase %>"
17
17
 
18
18
  <%- attributes_hash.each do |attr, value| -%>
19
19
  <%- if boolean?(attr) -%>
@@ -29,8 +29,8 @@ class <%= class_name.pluralize %>Test < ApplicationSystemTestCase
29
29
  end
30
30
 
31
31
  def test_updating_<%= human_name %>
32
- visit <%= plural_table_name %>_url
33
- click_on "Edit", match: :first
32
+ visit <%= singular_table_name %>_url(@<%= singular_table_name %>)
33
+ click_on "Edit this <%= human_name.downcase %>", match: :first
34
34
 
35
35
  <%- attributes_hash.each do |attr, value| -%>
36
36
  <%- if boolean?(attr) -%>
@@ -46,10 +46,8 @@ class <%= class_name.pluralize %>Test < ApplicationSystemTestCase
46
46
  end
47
47
 
48
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
49
+ visit <%= singular_table_name %>_url(@<%= singular_table_name %>)
50
+ click_on "Destroy this <%= human_name.downcase %>", match: :first
53
51
 
54
52
  assert_text "<%= human_name %> was successfully destroyed"
55
53
  end
@@ -1,9 +1,8 @@
1
1
  require "application_system_test_case"
2
2
 
3
- class <%= class_name.pluralize %>Test < ApplicationSystemTestCase
4
- # test "visiting the index" do
3
+ describe <%= class_name.pluralize %>, :system do
4
+ # it "visits the index" do
5
5
  # visit <%= plural_table_name %>_url
6
- #
7
- # assert_selector "h1", text: "<%= class_name %>"
6
+ # assert_selector "h1", text: "<%= human_name.pluralize %>"
8
7
  # end
9
8
  end
@@ -1,9 +1,8 @@
1
1
  require "application_system_test_case"
2
2
 
3
3
  class <%= class_name.pluralize %>Test < ApplicationSystemTestCase
4
- # test "visiting the index" do
4
+ # def test_visiting_index
5
5
  # visit <%= plural_table_name %>_url
6
- #
7
- # assert_selector "h1", text: "<%= class_name %>"
6
+ # assert_selector "h1", text: "<%= human_name.pluralize %>"
8
7
  # end
9
8
  end
@@ -4,7 +4,7 @@ require "rails/generators/named_base"
4
4
 
5
5
  module Minitest
6
6
  module Generators
7
- class Base < ::Rails::Generators::NamedBase #:nodoc:
7
+ class Base < ::Rails::Generators::NamedBase # :nodoc:
8
8
  class_option :spec, type: :boolean, default: true,
9
9
  desc: "Use Minitest::Spec DSL"
10
10
  class_option :spec_expectation_monad, type: :string, default: "value",