Skip to content

Commit 11aa3fd

Browse files
Merge pull request rails#49236 from shouichi/enable-literal-as-actual-argument
Enable Minitest/LiteralAsActualArgument
2 parents 699dfdb + 51ac8b9 commit 11aa3fd

File tree

52 files changed

+121
-116
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+121
-116
lines changed

.rubocop.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,9 @@ Minitest/AssertRaisesWithRegexpArgument:
350350
Minitest/AssertWithExpectedArgument:
351351
Enabled: true
352352

353+
Minitest/LiteralAsActualArgument:
354+
Enabled: true
355+
353356
Minitest/SkipEnsure:
354357
Enabled: true
355358

actionmailer/test/base_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -832,8 +832,8 @@ def self.previewing_email(mail); end
832832
end
833833

834834
test "proc default values can have arity of 1 where arg is a mailer instance" do
835-
assert_equal(ProcMailer.welcome["X-Lambda-Arity-1-arg"].to_s, "complex_value")
836-
assert_equal(ProcMailer.welcome["X-Lambda-Arity-1-self"].to_s, "complex_value")
835+
assert_equal("complex_value", ProcMailer.welcome["X-Lambda-Arity-1-arg"].to_s)
836+
assert_equal("complex_value", ProcMailer.welcome["X-Lambda-Arity-1-self"].to_s)
837837
end
838838

839839
test "proc default values with fixed arity of 0 can be called" do

actionpack/test/controller/parameters/mutators_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ class ParametersMutatorsTest < ActiveSupport::TestCase
181181
params = ActionController::Parameters.new(name: "Alex", age: "40", location: "Beijing")
182182
params.permit!
183183
params_hash = params.to_h { |key, value| [:"#{key}_modified", value] }
184-
assert_equal params_hash.keys, %w(name_modified age_modified location_modified)
184+
assert_equal %w(name_modified age_modified location_modified), params_hash.keys
185185
end
186186
# rubocop:enable Style/HashTransformKeys
187187

@@ -190,7 +190,7 @@ class ParametersMutatorsTest < ActiveSupport::TestCase
190190
params = ActionController::Parameters.new(name: "Alex", age: "40", location: "Beijing")
191191
params.permit!
192192
params_hash = params.to_h { |key, value| [key, value.is_a?(String) ? "#{value}_modified" : value] }
193-
assert_equal params_hash.values, %w(Alex_modified 40_modified Beijing_modified)
193+
assert_equal %w(Alex_modified 40_modified Beijing_modified), params_hash.values
194194
end
195195
# rubocop:enable Style/HashTransformValues
196196

actionpack/test/controller/routing_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1694,7 +1694,7 @@ def test_route_with_subdomain_and_constraints_must_receive_params
16941694
end
16951695
assert_equal({ controller: "pages", action: "show", name: "mypage" },
16961696
set.recognize_path("http://subdomain.example.org/page/mypage"))
1697-
assert_equal(name_param, "mypage")
1697+
assert_equal("mypage", name_param)
16981698
end
16991699

17001700
def test_route_requirement_recognize_with_ignore_case

actionpack/test/controller/test_case_test.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ def to_param
259259

260260
post :test_params, params: { foo: klass.new }
261261

262-
assert_equal JSON.parse(@response.body)["foo"], "bar"
262+
assert_equal "bar", JSON.parse(@response.body)["foo"]
263263
end
264264

265265
def test_body_stream
@@ -1146,7 +1146,7 @@ class BarControllerTest < ActionController::TestCase
11461146

11471147
def test_engine_controller_route
11481148
get :index
1149-
assert_equal @response.body, "bar"
1149+
assert_equal "bar", @response.body
11501150
end
11511151
end
11521152

@@ -1159,7 +1159,7 @@ def setup
11591159

11601160
def test_engine_controller_route
11611161
get :index
1162-
assert_equal @response.body, "bar"
1162+
assert_equal "bar", @response.body
11631163
end
11641164
end
11651165
end

actionpack/test/dispatch/mime_type_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@ class MimeTypeTest < ActiveSupport::TestCase
161161
end
162162

163163
test "type should be equal to symbol" do
164-
assert_equal Mime[:html], "application/xhtml+xml"
165-
assert_equal Mime[:html], :html
164+
assert_operator Mime[:html], :==, "application/xhtml+xml"
165+
assert_operator Mime[:html], :==, :html
166166
end
167167

168168
test "type convenience methods" do

actionpack/test/dispatch/response_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ def test_only_set_charset_still_defaults_to_text_html
402402
test "[response.to_a].flatten does not recurse infinitely" do
403403
Timeout.timeout(1) do # use a timeout to prevent it stalling indefinitely
404404
status, headers, body = [@response.to_a].flatten
405-
assert_equal status, 200
405+
assert_equal 200, status
406406
assert_equal headers, @response.headers
407407
assert_nil body
408408
end

actionpack/test/dispatch/test_response_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def assert_response_code_range(range, predicate)
3737
</html>
3838
HTML
3939
assert_kind_of(Nokogiri::XML::Document, response.parsed_body)
40-
assert_equal(response.parsed_body.at_xpath("/html/body/div").text, "Content")
40+
assert_equal("Content", response.parsed_body.at_xpath("/html/body/div").text)
4141
end
4242

4343
if RUBY_VERSION >= "3.1"

actionview/test/actionpack/controller/render_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1497,7 +1497,7 @@ def test_template_annotations_do_not_render_for_non_html_format
14971497
end
14981498

14991499
assert_not_includes @response.body, "BEGIN"
1500-
assert_equal @response.body.split("\n").length, 1
1500+
assert_equal 1, @response.body.split("\n").length
15011501
end
15021502

15031503
def test_line_offset_with_annotations_enabled

actionview/test/template/render_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def test_render_raw_is_html_safe_and_does_not_escape_output
151151
buffer = ActiveSupport::SafeBuffer.new
152152
buffer << @view.render(template: "plain_text")
153153
assert_equal true, buffer.html_safe?
154-
assert_equal buffer, "<%= hello_world %>\n"
154+
assert_equal "<%= hello_world %>\n", buffer
155155
end
156156

157157
def test_render_ruby_template_with_handlers

0 commit comments

Comments
 (0)