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.
Files changed (114) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +5 -0
  3. data/LICENSE +1 -1
  4. data/README.md +117 -0
  5. data/UPDATING.md +31 -0
  6. data/lib/generators/minitest.rb +17 -4
  7. data/lib/generators/minitest/controller/controller_generator.rb +6 -9
  8. data/lib/generators/minitest/controller/templates/{controller_spec.rb → functional_spec.rb.tt} +4 -4
  9. data/lib/generators/minitest/controller/templates/{controller_test.rb → functional_test.rb.tt} +3 -3
  10. data/lib/generators/minitest/generator/generator_generator.rb +3 -8
  11. data/lib/generators/minitest/generator/templates/{generator_spec.rb → generator_spec.rb.tt} +2 -2
  12. data/lib/generators/minitest/generator/templates/{generator_test.rb → generator_test.rb.tt} +1 -2
  13. data/lib/generators/minitest/helper/helper_generator.rb +5 -3
  14. data/lib/generators/minitest/install/install_generator.rb +21 -8
  15. data/lib/generators/minitest/install/templates/test/application_system_test_case.rb.tt +10 -0
  16. data/lib/generators/minitest/install/templates/test/channels/application_cable/connection_test.rb.tt +23 -0
  17. data/lib/generators/minitest/install/templates/test/test_helper.rb.tt +23 -0
  18. data/lib/generators/minitest/integration/integration_generator.rb +12 -9
  19. data/lib/generators/minitest/integration/templates/integration_spec.rb.tt +9 -0
  20. data/lib/generators/minitest/integration/templates/integration_test.rb.tt +9 -0
  21. data/lib/generators/minitest/job/job_generator.rb +13 -10
  22. data/lib/generators/minitest/job/templates/unit_spec.rb.tt +9 -0
  23. data/lib/generators/minitest/job/templates/{job_test.rb → unit_test.rb.tt} +3 -3
  24. data/lib/generators/minitest/mailer/mailer_generator.rb +8 -11
  25. data/lib/generators/minitest/mailer/templates/functional_spec.rb.tt +21 -0
  26. data/lib/generators/minitest/mailer/templates/{mailer_test.rb → functional_test.rb.tt} +3 -3
  27. data/lib/generators/minitest/mailer/templates/{preview.rb → preview.rb.tt} +0 -0
  28. data/lib/generators/minitest/model/model_generator.rb +9 -12
  29. data/lib/generators/minitest/model/templates/{fixtures.yml → fixtures.yml.tt} +3 -3
  30. data/lib/generators/minitest/model/templates/unit_spec.rb.tt +9 -0
  31. data/lib/generators/minitest/model/templates/unit_test.rb.tt +9 -0
  32. data/lib/generators/minitest/plugin/plugin_generator.rb +15 -0
  33. data/lib/generators/minitest/plugin/templates/%file_name%_test.rb.tt +15 -0
  34. data/lib/generators/minitest/plugin/templates/test_helper.rb +2 -0
  35. data/lib/generators/minitest/scaffold/scaffold_generator.rb +28 -23
  36. data/lib/generators/minitest/scaffold/templates/api_functional_spec.rb.tt +42 -0
  37. data/lib/generators/minitest/scaffold/templates/api_functional_test.rb.tt +44 -0
  38. data/lib/generators/minitest/scaffold/templates/functional_spec.rb.tt +52 -0
  39. data/lib/generators/minitest/scaffold/templates/{controller_test.rb → functional_test.rb.tt} +16 -16
  40. data/lib/generators/minitest/scaffold/templates/system_spec.rb.tt +55 -0
  41. data/lib/generators/minitest/scaffold/templates/system_test.rb.tt +57 -0
  42. data/lib/generators/minitest/system/system_generator.rb +25 -0
  43. data/lib/generators/minitest/system/templates/application_system_test_case.rb.tt +10 -0
  44. data/lib/generators/minitest/system/templates/system_spec.rb.tt +9 -0
  45. data/lib/generators/minitest/system/templates/system_test.rb.tt +9 -0
  46. data/lib/minitest/rails.rb +76 -105
  47. data/lib/minitest/rails/assertions.rb +6 -906
  48. data/lib/minitest/rails/assertions/action_cable.rb +232 -0
  49. data/lib/minitest/rails/assertions/action_dispatch.rb +356 -0
  50. data/lib/minitest/rails/assertions/action_mailer.rb +153 -0
  51. data/lib/minitest/rails/assertions/action_view.rb +356 -0
  52. data/lib/minitest/rails/assertions/active_job.rb +151 -0
  53. data/lib/minitest/rails/assertions/active_support.rb +57 -0
  54. data/lib/minitest/rails/capybara.rb +17 -0
  55. data/lib/minitest/rails/expectations.rb +5 -565
  56. data/lib/minitest/rails/expectations/action_cable.rb +197 -0
  57. data/lib/minitest/rails/expectations/action_dispatch.rb +307 -0
  58. data/lib/minitest/rails/expectations/action_mailer.rb +175 -0
  59. data/lib/minitest/rails/expectations/active_job.rb +182 -0
  60. data/lib/minitest/rails/expectations/active_support.rb +73 -0
  61. data/lib/minitest/rails/parallelize.rb +41 -0
  62. data/lib/minitest/rails/railtie.rb +3 -2
  63. data/lib/minitest/rails/version.rb +1 -1
  64. metadata +87 -92
  65. data/.autotest +0 -23
  66. data/.gemtest +0 -0
  67. data/.travis.yml +0 -25
  68. data/CHANGELOG.rdoc +0 -223
  69. data/Gemfile +0 -7
  70. data/Manifest.txt +0 -76
  71. data/README.rdoc +0 -110
  72. data/Rakefile +0 -30
  73. data/gemfiles/5.0.gemfile +0 -5
  74. data/gemfiles/head.gemfile +0 -5
  75. data/lib/generators/.document +0 -0
  76. data/lib/generators/minitest/install/templates/test_helper.rb +0 -19
  77. data/lib/generators/minitest/integration/templates/integration_spec.rb +0 -8
  78. data/lib/generators/minitest/integration/templates/integration_test.rb +0 -7
  79. data/lib/generators/minitest/job/templates/job_spec.rb +0 -9
  80. data/lib/generators/minitest/mailer/templates/mailer_spec.rb +0 -20
  81. data/lib/generators/minitest/model/templates/model_spec.rb +0 -11
  82. data/lib/generators/minitest/model/templates/model_test.rb +0 -13
  83. data/lib/generators/minitest/scaffold/templates/api_controller_spec.rb +0 -42
  84. data/lib/generators/minitest/scaffold/templates/api_controller_test.rb +0 -44
  85. data/lib/generators/minitest/scaffold/templates/controller_spec.rb +0 -52
  86. data/lib/minitest/rails/constant_lookup.rb +0 -52
  87. data/lib/minitest/rails/controller.rb +0 -14
  88. data/minitest-rails.gemspec +0 -48
  89. data/tasks/test.rake +0 -29
  90. data/test/generators/test_controller_generator.rb +0 -58
  91. data/test/generators/test_generator_generator.rb +0 -58
  92. data/test/generators/test_helper_generator.rb +0 -34
  93. data/test/generators/test_install_generator.rb +0 -27
  94. data/test/generators/test_job_generator.rb +0 -45
  95. data/test/generators/test_mailer_generator.rb +0 -42
  96. data/test/generators/test_model_generator.rb +0 -80
  97. data/test/generators/test_scaffold_generator.rb +0 -26
  98. data/test/helper.rb +0 -93
  99. data/test/rails/action_dispatch/test_assertions.rb +0 -39
  100. data/test/rails/action_dispatch/test_expectations.rb +0 -39
  101. data/test/rails/action_dispatch/test_spec_type.rb +0 -49
  102. data/test/rails/action_mailer/test_mailers.rb +0 -109
  103. data/test/rails/action_mailer/test_spec_type.rb +0 -47
  104. data/test/rails/action_view/test_helpers.rb +0 -73
  105. data/test/rails/action_view/test_spec_type.rb +0 -58
  106. data/test/rails/active_job/test_assertions.rb +0 -46
  107. data/test/rails/active_job/test_expectations.rb +0 -55
  108. data/test/rails/active_job/test_spec_type.rb +0 -49
  109. data/test/rails/active_support/test_assertions.rb +0 -31
  110. data/test/rails/active_support/test_expectations.rb +0 -21
  111. data/test/rails/active_support/test_spec_type.rb +0 -28
  112. data/test/rails/generators/test_spec_type.rb +0 -45
  113. data/test/rails/test_constant_lookup.rb +0 -58
  114. data/test/test_sanity.rb +0 -7
@@ -0,0 +1,197 @@
1
+ require "active_support/concern"
2
+
3
+ module Minitest
4
+ module Rails
5
+ module Expectations
6
+ module ActionCable
7
+ module TestHelper
8
+ ##
9
+ # Asserts that the number of broadcasted messages to the stream matches the given number.
10
+ #
11
+ # def test_broadcasts
12
+ # must_have_broadcasts 'messages', 0
13
+ # ActionCable.server.broadcast 'messages', { text: 'hello' }
14
+ # must_have_broadcasts 'messages', 1
15
+ # ActionCable.server.broadcast 'messages', { text: 'world' }
16
+ # must_have_broadcasts 'messages', 2
17
+ # end
18
+ #
19
+ # If a block is passed, that block should cause the specified number of
20
+ # messages to be broadcasted.
21
+ #
22
+ # def test_broadcasts_again
23
+ # must_have_broadcasts('messages', 1) do
24
+ # ActionCable.server.broadcast 'messages', { text: 'hello' }
25
+ # end
26
+ #
27
+ # must_have_broadcasts('messages', 2) do
28
+ # ActionCable.server.broadcast 'messages', { text: 'hi' }
29
+ # ActionCable.server.broadcast 'messages', { text: 'how are you?' }
30
+ # end
31
+ # end
32
+ #
33
+ # See also ActionCable::TestHelper#assert_broadcasts
34
+ # See https://api.rubyonrails.org/v6.1/classes/ActionCable/TestHelper.html#method-i-assert_broadcasts
35
+ #
36
+ # :method: must_have_broadcasts
37
+ # :call-seq: must_have_broadcasts(stream, number)
38
+
39
+ ##
40
+ # Asserts that no messages have been sent to the stream.
41
+ #
42
+ # def test_no_broadcasts
43
+ # wont_have_broadcasts 'messages'
44
+ # ActionCable.server.broadcast 'messages', { text: 'hi' }
45
+ # must_have_broadcasts 'messages', 1
46
+ # end
47
+ #
48
+ # If a block is passed, that block should not cause any message to be sent.
49
+ #
50
+ # def test_broadcasts_again
51
+ # wont_have_broadcasts 'messages' do
52
+ # # No job messages should be sent from this block
53
+ # end
54
+ # end
55
+ #
56
+ # Note: This assertion is simply a shortcut for:
57
+ #
58
+ # must_have_broadcasts 'messages', 0, &block
59
+ #
60
+ # See also ActionCable::TestHelper#wont_have_broadcasts
61
+ # See https://api.rubyonrails.org/v6.1/classes/ActionCable/TestHelper.html#method-i-assert_no_broadcasts
62
+ #
63
+ # :method: wont_have_broadcasts
64
+ # :call-seq: wont_have_broadcasts(stream, &block)
65
+
66
+ ##
67
+ # Asserts that the specified message has been sent to the stream.
68
+ #
69
+ # def test_assert_transmitted_message
70
+ # ActionCable.server.broadcast 'messages', text: 'hello'
71
+ # must_broadcast_on('messages', text: 'hello')
72
+ # end
73
+ #
74
+ # If a block is passed, that block should cause a message with the specified data to be sent.
75
+ #
76
+ # def test_assert_broadcast_on_again
77
+ # must_broadcast_on('messages', text: 'hello') do
78
+ # ActionCable.server.broadcast 'messages', text: 'hello'
79
+ # end
80
+ # end
81
+ #
82
+ # See also ActionCable::TestHelper#assert_broadcast_on
83
+ # See https://api.rubyonrails.org/v6.1/classes/ActionCable/TestHelper.html#method-i-assert_broadcast_on
84
+ #
85
+ # :method: must_broadcast_on
86
+ # :call-seq: must_broadcast_on(stream, data)
87
+
88
+ extend ::ActiveSupport::Concern
89
+
90
+ included do
91
+ alias_method :must_have_broadcasts, :assert_broadcasts
92
+ alias_method :wont_have_broadcasts, :assert_no_broadcasts
93
+ alias_method :must_broadcast_on, :assert_broadcast_on
94
+ end
95
+ end
96
+
97
+ module Channel
98
+ ##
99
+ # Asserts that no streams have been started.
100
+ #
101
+ # def test_assert_no_started_stream
102
+ # subscribe
103
+ # wont_have_streams
104
+ # end
105
+ #
106
+ # See also ActionCable::Channel::TestCase#assert_no_streams
107
+ # See https://api.rubyonrails.org/v6.1/classes/ActionCable/Channel/TestCase/Behavior.html#method-i-assert_no_streams
108
+ #
109
+ # :method: wont_have_streams
110
+
111
+ ##
112
+ # Asserts that the specified stream has been started.
113
+ #
114
+ # def test_assert_started_stream
115
+ # subscribe
116
+ # must_have_streams 'messages'
117
+ # end
118
+ #
119
+ # See also ActionCable::Channel::TestCase#assert_has_stream
120
+ # See https://api.rubyonrails.org/v6.1/classes/ActionCable/Channel/TestCase/Behavior.html#method-i-assert_has_stream
121
+ #
122
+ # :method: must_have_streams
123
+ # :call-seq: must_have_streams(stream)
124
+
125
+ ##
126
+ # Asserts that the specified stream for a model has started.
127
+ #
128
+ # def test_assert_started_stream_for
129
+ # subscribe id: 42
130
+ # must_have_stream_for User.find(42)
131
+ # end
132
+ #
133
+ # See also ActionCable::Channel::TestCase#assert_has_stream_for
134
+ # See https://api.rubyonrails.org/v6.1/classes/ActionCable/Channel/TestCase/Behavior.html#method-i-assert_has_stream_for
135
+ #
136
+ # :method: must_have_stream_for
137
+ # :call-seq: must_have_stream_for(object)
138
+
139
+ extend ::ActiveSupport::Concern
140
+
141
+ included do
142
+ alias_method :wont_have_streams, :assert_no_streams
143
+ alias_method :must_have_streams, :assert_has_stream
144
+ alias_method :must_have_stream_for, :assert_has_stream_for
145
+ end
146
+ end
147
+
148
+ module Connection
149
+ ##
150
+ # Asserts that the connection is rejected (via +reject_unauthorized_connection+).
151
+ #
152
+ # describe "Application Connections", :connection do
153
+ # it "connects with proper cookie" do
154
+ # # Simulate the connection request with a cookie.
155
+ # cookies["user_id"] = users(:john).id
156
+ #
157
+ # connect
158
+ #
159
+ # # Assert the connection identifier matches the fixture.
160
+ # value(connection.user.id).must_equal users(:john).id
161
+ # end
162
+ #
163
+ # it "rejects connection without proper cookie" do
164
+ # must_reject_connection { connect }
165
+ # end
166
+ # end
167
+ #
168
+ # See also ActionCable::Connection::TestCase#assert_reject_connection
169
+ # See https://api.rubyonrails.org/v6.1/classes/ActionCable/Connection/Assertions.html#method-i-assert_reject_connection
170
+ #
171
+ # :method: must_reject_connection
172
+
173
+ extend ::ActiveSupport::Concern
174
+
175
+ included do
176
+ alias_method :must_reject_connection, :assert_reject_connection
177
+ end
178
+ end
179
+ end
180
+ end
181
+ end
182
+ end
183
+
184
+ unless ENV["MT_NO_EXPECTATIONS"]
185
+ class ActionCable::TestCase # :nodoc:
186
+ include Minitest::Rails::Expectations::ActionCable::TestHelper
187
+ end
188
+
189
+ class ActionCable::Channel::TestCase # :nodoc:
190
+ include Minitest::Rails::Expectations::ActionCable::TestHelper
191
+ include Minitest::Rails::Expectations::ActionCable::Channel
192
+ end
193
+
194
+ class ActionCable::Connection::TestCase # :nodoc:
195
+ include Minitest::Rails::Expectations::ActionCable::Connection
196
+ end
197
+ end
@@ -0,0 +1,307 @@
1
+ require "active_support/concern"
2
+ require "minitest/rails/expectations/active_support"
3
+
4
+ module Minitest
5
+ module Rails
6
+ module Expectations
7
+ # This exists as a module to allow easy mixing into classes other than
8
+ # ActionDispatch::IntegrationTest where you might want to do job testing.
9
+ module ActionDispatch
10
+ ##
11
+ # Expects that the provided options can be used to generate the provided path. This is the inverse of +assert_recognizes+.
12
+ # The +extras+ parameter is used to tell the request the names and values of additional request parameters that would be in
13
+ # a query string. The +message+ parameter allows you to specify a custom error message for assertion failures.
14
+ #
15
+ # The +defaults+ parameter is unused.
16
+ #
17
+ # # Expects that the default action is generated for a route with no action
18
+ # value({controller: "items", action: "index"}).must_route_from "/items"
19
+ #
20
+ # # Tests that the list action is properly routed
21
+ # value({controller: "items", action: "list"}).must_route_to "/items/list"
22
+ #
23
+ # # Tests the generation of a route with a parameter
24
+ # value({ controller: "items", action: "list", id: "1" }).must_route_from "/items/list/1"
25
+ #
26
+ # # Expects that the generated route gives us our custom route
27
+ # value({ controller: 'scm', action: 'show_diff', revision: "12" }).must_route_from "changesets/12"
28
+ #
29
+ # See also ActionView::TestCase#assert_generates
30
+ # See also ActionDispatch::IntegrationTest#assert_generates
31
+ #
32
+ # :method: must_route_from
33
+ # :call-seq: options.must_route_from(expected_path, defaults={}, extras = {}, message=nil)
34
+ infect_an_assertion :assert_generates, :must_route_to
35
+
36
+ ##
37
+ # Expects that the routing of the given +path+ was handled correctly and that the parsed options (given in the +expected_options+ hash)
38
+ # match +path+. Basically, it asserts that \Rails recognizes the route given by +expected_options+.
39
+ #
40
+ # Pass a hash in the second argument (+path+) to specify the request method. This is useful for routes
41
+ # requiring a specific HTTP method. The hash should contain a :path with the incoming request path
42
+ # and a :method containing the required HTTP verb.
43
+ #
44
+ # # assert that POSTing to /items will call the create action on ItemsController
45
+ # assert_recognizes({controller: 'items', action: 'create'}, {path: 'items', method: :post})
46
+ #
47
+ # You can also pass in +extras+ with a hash containing URL parameters that would normally be in the query string. This can be used
48
+ # to assert that values in the query string string will end up in the params hash correctly. To test query strings you must use the
49
+ # extras argument, appending the query string on the path directly will not work. For example:
50
+ #
51
+ # # Expect that a path of '/items/list/1?view=print' returns the correct options
52
+ # value('items/list/1').must_route_from({controller: 'items', action: 'list', id: '1', view: 'print'}, { view: "print" })
53
+ #
54
+ # The +message+ parameter allows you to pass in an error message that is displayed upon failure.
55
+ #
56
+ # # Check the default route (i.e., the index action)
57
+ # value('items').must_route_from({controller: 'items', action: 'index'})
58
+ #
59
+ # # Test a specific action
60
+ # value('items/list').must_route_from({controller: 'items', action: 'list'})
61
+ #
62
+ # # Test an action with a parameter
63
+ # value('items/destroy/1').must_route_from({controller: 'items', action: 'destroy', id: '1'})
64
+ #
65
+ # # Test a custom route
66
+ # value('view/item1').must_route_from({controller: 'items', action: 'show', id: '1'})
67
+ #
68
+ # See also ActionView::TestCase#assert_recognizes
69
+ # See also ActionDispatch::IntegrationTest#assert_recognizes
70
+ #
71
+ # :method: must_route_from
72
+ # :call-seq: path.must_route_from(expected_options, extras={}, msg=nil)
73
+ infect_an_assertion :assert_recognizes, :must_route_from
74
+
75
+ ##
76
+ # Expects that path and options match both ways; in other words, it verifies that <tt>path</tt> generates
77
+ # <tt>options</tt> and then that <tt>options</tt> generates <tt>path</tt>. This essentially combines +assert_recognizes+
78
+ # and +assert_generates+ into one step.
79
+ #
80
+ # The +extras+ hash allows you to specify options that would normally be provided as a query string to the action. The
81
+ # +message+ parameter allows you to specify a custom error message to display upon failure.
82
+ #
83
+ # # Expect a basic route: a controller with the default action (index)
84
+ # value({ controller: 'home', action: 'index' }).must_route_for '/home'
85
+ #
86
+ # # Test a route generated with a specific controller, action, and parameter (id)
87
+ # value({ controller: 'entries', action: 'show', id: 23 }).must_route_for '/entries/show/23'
88
+ #
89
+ # # Expect a basic route (controller + default action), with an error message if it fails
90
+ # value({ controller: 'store', action: 'index' }).must_route_for '/store'
91
+ #
92
+ # # Tests a route, providing a defaults hash
93
+ # value({id: "9", item: "square"}).must_route_for 'controller/action/9', {controller: "controller", action: "action"}, {}, {item: "square"}
94
+ #
95
+ # # Tests a route with a HTTP method
96
+ # value({ controller: "product", action: "update", id: "321" }).must_route_for({ method: 'put', path: '/product/321' })
97
+ #
98
+ # See also ActionView::TestCase#assert_routing
99
+ # See also ActionDispatch::IntegrationTest#assert_routing
100
+ #
101
+ # :method: must_route_for
102
+ # :call-seq: options.must_route_for(path, defaults={}, extras={}, message=nil)
103
+ infect_an_assertion :assert_routing, :must_route_for
104
+
105
+ # An expectation that selects elements and makes one or more equality tests.
106
+ #
107
+ # If the first argument is an element, selects all matching elements
108
+ # starting from (and including) that element and all its children in
109
+ # depth-first order.
110
+ #
111
+ # If no element if specified, calling +must_select+ selects from the
112
+ # response HTML unless +must_select+ is called from within an +must_select+ block.
113
+ #
114
+ # When called with a block +must_select+ passes an array of selected elements
115
+ # to the block. Calling +must_select+ from the block, with no element specified,
116
+ # runs the expectation on the complete set of elements selected by the enclosing expectation.
117
+ # Alternatively the array may be iterated through so that +must_select+ can be called
118
+ # separately for each element.
119
+ #
120
+ #
121
+ # ==== Example
122
+ # If the response contains two ordered lists, each with four list elements then:
123
+ # must_select "ol" do |elements|
124
+ # elements.each do |element|
125
+ # must_select element, "li", 4
126
+ # end
127
+ # end
128
+ #
129
+ # will pass, as will:
130
+ # must_select "ol" do
131
+ # must_select "li", 8
132
+ # end
133
+ #
134
+ # The selector may be a CSS selector expression (String), an expression
135
+ # with substitution values, or an HTML::Selector object.
136
+ #
137
+ # === Equality Tests
138
+ #
139
+ # The equality test may be one of the following:
140
+ # * <tt>true</tt> - Assertion is true if at least one element selected.
141
+ # * <tt>false</tt> - Assertion is true if no element selected.
142
+ # * <tt>String/Regexp</tt> - Assertion is true if the text value of at least
143
+ # one element matches the string or regular expression.
144
+ # * <tt>Integer</tt> - Assertion is true if exactly that number of
145
+ # elements are selected.
146
+ # * <tt>Range</tt> - Assertion is true if the number of selected
147
+ # elements fit the range.
148
+ # If no equality test specified, the expectation is true if at least one
149
+ # element selected.
150
+ #
151
+ # To perform more than one equality tests, use a hash with the following keys:
152
+ # * <tt>:text</tt> - Narrow the selection to elements that have this text
153
+ # value (string or regexp).
154
+ # * <tt>:html</tt> - Narrow the selection to elements that have this HTML
155
+ # content (string or regexp).
156
+ # * <tt>:count</tt> - Assertion is true if the number of selected elements
157
+ # is equal to this value.
158
+ # * <tt>:minimum</tt> - Assertion is true if the number of selected
159
+ # elements is at least this value.
160
+ # * <tt>:maximum</tt> - Assertion is true if the number of selected
161
+ # elements is at most this value.
162
+ #
163
+ # If the method is called with a block, once all equality tests are
164
+ # evaluated the block is called with an array of all matched elements.
165
+ #
166
+ # # At least one form element
167
+ # must_select "form"
168
+ #
169
+ # # Form element includes four input fields
170
+ # must_select "form input", 4
171
+ #
172
+ # # Page title is "Welcome"
173
+ # must_select "title", "Welcome"
174
+ #
175
+ # # Page title is "Welcome" and there is only one title element
176
+ # must_select "title", {count: 1, text: "Welcome"},
177
+ # "Wrong title or more than one title element"
178
+ #
179
+ # # Page contains no forms
180
+ # must_select "form", false, "This page must contain no forms"
181
+ #
182
+ # # Test the content and style
183
+ # must_select "body div.header ul.menu"
184
+ #
185
+ # # Use substitution values
186
+ # must_select "ol>li#?", /item-\d+/
187
+ #
188
+ # # All input fields in the form have a name
189
+ # must_select "form input" do
190
+ # must_select "[name=?]", /.+/ # Not empty
191
+ # end
192
+ #
193
+ # See also ActionView::TestCase#assert_select
194
+ # See also ActionDispatch::IntegrationTest#assert_select
195
+ #
196
+ # :method: must_select
197
+ # :call-seq: must_select(*args, &block)
198
+
199
+ # Extracts the body of an email and runs nested expectations on it.
200
+ #
201
+ # You must enable deliveries for this expectation to work, use:
202
+ # ActionMailer::Base.perform_deliveries = true
203
+ #
204
+ # must_select_email do
205
+ # must_select "h1", "Email alert"
206
+ # end
207
+ #
208
+ # must_select_email do
209
+ # items = must_select "ol>li"
210
+ # items.each do
211
+ # # Work with items here...
212
+ # end
213
+ # end
214
+ #
215
+ # See also ActionView::TestCase#assert_select_email
216
+ # See also ActionDispatch::IntegrationTest#assert_select_email
217
+ #
218
+ # :method: must_select_email
219
+ # :call-seq: must_select_email(&block)
220
+
221
+ # Extracts the content of an element, treats it as encoded HTML and runs
222
+ # nested expectation on it.
223
+ #
224
+ # You typically call this method within another expectation to operate on
225
+ # all currently selected elements. You can also pass an element or array
226
+ # of elements.
227
+ #
228
+ # The content of each element is un-encoded, and wrapped in the root
229
+ # element +encoded+. It then calls the block with all un-encoded elements.
230
+ #
231
+ # # Selects all bold tags from within the title of an Atom feed's entries (perhaps to nab a section name prefix)
232
+ # must_select "feed[xmlns='http://www.w3.org/2005/Atom']" do
233
+ # # Select each entry item and then the title item
234
+ # must_select "entry>title" do
235
+ # # Run expectations on the encoded title elements
236
+ # must_select_encoded do
237
+ # must_select "b"
238
+ # end
239
+ # end
240
+ # end
241
+ #
242
+ #
243
+ # # Selects all paragraph tags from within the description of an RSS feed
244
+ # must_select "rss[version=2.0]" do
245
+ # # Select description element of each feed item.
246
+ # must_select "channel>item>description" do
247
+ # # Run expectations on the encoded elements.
248
+ # must_select_encoded do
249
+ # must_select "p"
250
+ # end
251
+ # end
252
+ # end
253
+ #
254
+ # See also ActionView::TestCase#assert_select_encoded
255
+ # See also ActionDispatch::IntegrationTest#assert_select_encoded
256
+ #
257
+ # :method: must_select_encoded
258
+ # :call-seq: must_select_encoded(element = nil, &block)
259
+
260
+ ##
261
+ # Checks that two HTML strings are equivalent. That they contain the same elements and attributes with the associated values.
262
+ # Checks the numeric difference between the return value of an expression as a result of what is evaluated.
263
+ #
264
+ # apple_link = '<a href="http://www.example.com">Apples</a>'
265
+ # value(link_to("Apples", "http://www.example.com")).must_dom_equal apple_link
266
+ #
267
+ # See also ActionView::TestCase#assert_dom_equal
268
+ # See also ActionDispatch::IntegrationTest#assert_dom_equal
269
+ #
270
+ # :method: must_dom_equal
271
+ # :args: expected, message = nil
272
+ infect_an_assertion :assert_dom_equal, :must_dom_equal
273
+
274
+ ##
275
+ # Checks that the numeric result of evaluating an expression is not changed before and after invoking.
276
+ #
277
+ # orange_link = '<a href="http://www.example.com">Oranges</a>'
278
+ # link_to("Apples", "http://www.example.com").wont_dom_equal orange_link
279
+ #
280
+ # See also ActionView::TestCase#refute_dom_equal
281
+ # See also ActionDispatch::IntegrationTest#refute_dom_equal
282
+ # See also ActionView::TestCase#assert_dom_not_equal
283
+ # See also ActionDispatch::IntegrationTest#assert_dom_not_equal
284
+ #
285
+ # :method: wont_dom_equal
286
+ # :args: expected, message = nil
287
+ infect_an_assertion :refute_dom_equal, :wont_dom_equal
288
+
289
+ extend ::ActiveSupport::Concern
290
+
291
+ included do
292
+ alias_method :must_respond_with, :assert_response
293
+ alias_method :must_redirect_to, :assert_redirected_to
294
+ alias_method :must_select, :assert_select
295
+ alias_method :must_select_email, :assert_select_email
296
+ alias_method :must_select_encoded, :assert_select_encoded
297
+ end
298
+ end
299
+ end
300
+ end
301
+ end
302
+
303
+ unless ENV["MT_NO_EXPECTATIONS"]
304
+ class ActionDispatch::IntegrationTest # :nodoc:
305
+ include Minitest::Rails::Expectations::ActionDispatch
306
+ end
307
+ end