mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Use parentheses when using assert_match followed by a regexp to avoid warnings.
This commit is contained in:
parent
be9883b09d
commit
2d274a5208
17 changed files with 58 additions and 58 deletions
|
@ -37,6 +37,6 @@ class ControllerRuntimeLogSubscriberTest < ActionController::TestCase
|
|||
wait
|
||||
|
||||
assert_equal 2, @logger.logged(:info).size
|
||||
assert_match /\(Views: [\d\.]+ms | ActiveRecord: [\d\.]+ms\)/, @logger.logged(:info)[1]
|
||||
assert_match(/\(Views: [\d\.]+ms | ActiveRecord: [\d\.]+ms\)/, @logger.logged(:info)[1])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -314,7 +314,7 @@ class ActionPackAssertionsControllerTest < ActionController::TestCase
|
|||
def test_redirect_url_match
|
||||
process :redirect_external
|
||||
assert @response.redirect?
|
||||
assert_match /rubyonrails/, @response.redirect_url
|
||||
assert_match(/rubyonrails/, @response.redirect_url)
|
||||
assert !/perloffrails/.match(@response.redirect_url)
|
||||
end
|
||||
|
||||
|
|
|
@ -728,7 +728,7 @@ CACHED
|
|||
get :html_fragment_cached_with_partial
|
||||
assert_response :success
|
||||
assert_match(/Old fragment caching in a partial/, @response.body)
|
||||
assert_match "Old fragment caching in a partial", @store.read('views/test.host/functional_caching/html_fragment_cached_with_partial')
|
||||
assert_match("Old fragment caching in a partial", @store.read('views/test.host/functional_caching/html_fragment_cached_with_partial'))
|
||||
end
|
||||
|
||||
def test_render_inline_before_fragment_caching
|
||||
|
@ -736,14 +736,14 @@ CACHED
|
|||
assert_response :success
|
||||
assert_match(/Some inline content/, @response.body)
|
||||
assert_match(/Some cached content/, @response.body)
|
||||
assert_match "Some cached content", @store.read('views/test.host/functional_caching/inline_fragment_cached')
|
||||
assert_match("Some cached content", @store.read('views/test.host/functional_caching/inline_fragment_cached'))
|
||||
end
|
||||
|
||||
def test_fragment_caching_in_rjs_partials
|
||||
xhr :get, :js_fragment_cached_with_partial
|
||||
assert_response :success
|
||||
assert_match(/Old fragment caching in a partial/, @response.body)
|
||||
assert_match "Old fragment caching in a partial", @store.read('views/test.host/functional_caching/js_fragment_cached_with_partial')
|
||||
assert_match("Old fragment caching in a partial", @store.read('views/test.host/functional_caching/js_fragment_cached_with_partial'))
|
||||
end
|
||||
|
||||
def test_html_formatted_fragment_caching
|
||||
|
|
|
@ -72,8 +72,8 @@ class ACLogSubscriberTest < ActionController::TestCase
|
|||
get :show
|
||||
wait
|
||||
assert_equal 2, logs.size
|
||||
assert_match /Completed/, logs.last
|
||||
assert_match /200 OK/, logs.last
|
||||
assert_match(/Completed/, logs.last)
|
||||
assert_match(/200 OK/, logs.last)
|
||||
end
|
||||
|
||||
def test_process_action_without_parameters
|
||||
|
@ -93,7 +93,7 @@ class ACLogSubscriberTest < ActionController::TestCase
|
|||
def test_process_action_with_view_runtime
|
||||
get :show
|
||||
wait
|
||||
assert_match /\(Views: [\d\.]+ms\)/, logs[1]
|
||||
assert_match(/\(Views: [\d\.]+ms\)/, logs[1])
|
||||
end
|
||||
|
||||
def test_process_action_with_filter_parameters
|
||||
|
@ -103,9 +103,9 @@ class ACLogSubscriberTest < ActionController::TestCase
|
|||
wait
|
||||
|
||||
params = logs[1]
|
||||
assert_match /"amount"=>"\[FILTERED\]"/, params
|
||||
assert_match /"lifo"=>"\[FILTERED\]"/, params
|
||||
assert_match /"step"=>"1"/, params
|
||||
assert_match(/"amount"=>"\[FILTERED\]"/, params)
|
||||
assert_match(/"lifo"=>"\[FILTERED\]"/, params)
|
||||
assert_match(/"step"=>"1"/, params)
|
||||
end
|
||||
|
||||
def test_redirect_to
|
||||
|
@ -121,7 +121,7 @@ class ACLogSubscriberTest < ActionController::TestCase
|
|||
wait
|
||||
|
||||
assert_equal 3, logs.size
|
||||
assert_match /Sent data file\.txt/, logs[1]
|
||||
assert_match(/Sent data file\.txt/, logs[1])
|
||||
end
|
||||
|
||||
def test_send_file
|
||||
|
@ -129,8 +129,8 @@ class ACLogSubscriberTest < ActionController::TestCase
|
|||
wait
|
||||
|
||||
assert_equal 3, logs.size
|
||||
assert_match /Sent file/, logs[1]
|
||||
assert_match /test\/fixtures\/company\.rb/, logs[1]
|
||||
assert_match(/Sent file/, logs[1])
|
||||
assert_match(/test\/fixtures\/company\.rb/, logs[1])
|
||||
end
|
||||
|
||||
def test_with_fragment_cache
|
||||
|
@ -139,8 +139,8 @@ class ACLogSubscriberTest < ActionController::TestCase
|
|||
wait
|
||||
|
||||
assert_equal 4, logs.size
|
||||
assert_match /Exist fragment\? views\/foo/, logs[1]
|
||||
assert_match /Write fragment views\/foo/, logs[2]
|
||||
assert_match(/Exist fragment\? views\/foo/, logs[1])
|
||||
assert_match(/Write fragment views\/foo/, logs[2])
|
||||
ensure
|
||||
@controller.config.perform_caching = true
|
||||
end
|
||||
|
@ -163,8 +163,8 @@ class ACLogSubscriberTest < ActionController::TestCase
|
|||
wait
|
||||
|
||||
assert_equal 3, logs.size
|
||||
assert_match /Write page/, logs[1]
|
||||
assert_match /\/index\.html/, logs[1]
|
||||
assert_match(/Write page/, logs[1])
|
||||
assert_match(/\/index\.html/, logs[1])
|
||||
ensure
|
||||
@controller.config.perform_caching = true
|
||||
end
|
||||
|
|
|
@ -784,8 +784,8 @@ class RespondWithControllerTest < ActionController::TestCase
|
|||
get :using_resource_with_collection
|
||||
assert_equal "application/xml", @response.content_type
|
||||
assert_equal 200, @response.status
|
||||
assert_match /<name>david<\/name>/, @response.body
|
||||
assert_match /<name>jamis<\/name>/, @response.body
|
||||
assert_match(/<name>david<\/name>/, @response.body)
|
||||
assert_match(/<name>jamis<\/name>/, @response.body)
|
||||
end
|
||||
|
||||
def test_using_resource_with_action
|
||||
|
|
|
@ -224,15 +224,15 @@ class RenderOtherTest < ActionController::TestCase
|
|||
get :update_page_with_instance_variables
|
||||
assert_template nil
|
||||
assert_equal 'text/javascript; charset=utf-8', @response.headers["Content-Type"]
|
||||
assert_match /balance/, @response.body
|
||||
assert_match /\$37/, @response.body
|
||||
assert_match(/balance/, @response.body)
|
||||
assert_match(/\$37/, @response.body)
|
||||
end
|
||||
|
||||
def test_update_page_with_view_method
|
||||
get :update_page_with_view_method
|
||||
assert_template nil
|
||||
assert_equal 'text/javascript; charset=utf-8', @response.headers["Content-Type"]
|
||||
assert_match /2 people/, @response.body
|
||||
assert_match(/2 people/, @response.body)
|
||||
end
|
||||
|
||||
def test_should_render_html_formatted_partial_with_rjs
|
||||
|
|
|
@ -591,7 +591,7 @@ XML
|
|||
assert false, "expected RuntimeError, got nothing"
|
||||
rescue RuntimeError => error
|
||||
assert true
|
||||
assert_match %r{@#{variable} is nil}, error.message
|
||||
assert_match(%r{@#{variable} is nil}, error.message)
|
||||
rescue => error
|
||||
assert false, "expected RuntimeError, got #{error.class}"
|
||||
end
|
||||
|
|
|
@ -219,7 +219,7 @@ module AbstractController
|
|||
|
||||
def test_hash_recursive_and_array_parameters
|
||||
url = W.new.url_for(:only_path => true, :controller => 'c', :action => 'a', :id => 101, :query => {:person => {:name => 'Bob', :position => ['prof', 'art director']}, :hobby => 'piercing'})
|
||||
assert_match %r(^/c/a/101), url
|
||||
assert_match(%r(^/c/a/101), url)
|
||||
params = extract_params(url)
|
||||
assert_equal params[0], { 'query[hobby]' => 'piercing' }.to_query
|
||||
assert_equal params[1], { 'query[person][name]' => 'Bob' }.to_query
|
||||
|
|
|
@ -47,7 +47,7 @@ class CookiesTest < ActionController::TestCase
|
|||
cookies["user_name"] = { :value => "david", :httponly => true }
|
||||
head :ok
|
||||
end
|
||||
|
||||
|
||||
def authenticate_with_secure
|
||||
cookies["user_name"] = { :value => "david", :secure => true }
|
||||
head :ok
|
||||
|
@ -133,7 +133,7 @@ class CookiesTest < ActionController::TestCase
|
|||
assert_cookie_header "user_name=david; path=/; HttpOnly"
|
||||
assert_equal({"user_name" => "david"}, @response.cookies)
|
||||
end
|
||||
|
||||
|
||||
def test_setting_cookie_with_secure
|
||||
get :authenticate_with_secure
|
||||
assert_cookie_header "user_name=david; path=/; secure"
|
||||
|
@ -169,8 +169,8 @@ class CookiesTest < ActionController::TestCase
|
|||
|
||||
def test_permanent_cookie
|
||||
get :set_permanent_cookie
|
||||
assert_match /Jamie/, @response.headers["Set-Cookie"]
|
||||
assert_match %r(#{20.years.from_now.utc.year}), @response.headers["Set-Cookie"]
|
||||
assert_match(/Jamie/, @response.headers["Set-Cookie"])
|
||||
assert_match(%r(#{20.years.from_now.utc.year}), @response.headers["Set-Cookie"])
|
||||
end
|
||||
|
||||
def test_signed_cookie
|
||||
|
@ -185,7 +185,7 @@ class CookiesTest < ActionController::TestCase
|
|||
|
||||
def test_permanent_signed_cookie
|
||||
get :set_permanent_signed_cookie
|
||||
assert_match %r(#{20.years.from_now.utc.year}), @response.headers["Set-Cookie"]
|
||||
assert_match(%r(#{20.years.from_now.utc.year}), @response.headers["Set-Cookie"])
|
||||
assert_equal 100, @controller.send(:cookies).signed[:remember_me]
|
||||
end
|
||||
|
||||
|
|
|
@ -45,9 +45,9 @@ class RequestTest < ActiveSupport::TestCase
|
|||
e = assert_raise(ActionDispatch::RemoteIp::IpSpoofAttackError) {
|
||||
request.remote_ip
|
||||
}
|
||||
assert_match /IP spoofing attack/, e.message
|
||||
assert_match /HTTP_X_FORWARDED_FOR="1.1.1.1"/, e.message
|
||||
assert_match /HTTP_CLIENT_IP="2.2.2.2"/, e.message
|
||||
assert_match(/IP spoofing attack/, e.message)
|
||||
assert_match(/HTTP_X_FORWARDED_FOR="1.1.1.1"/, e.message)
|
||||
assert_match(/HTTP_CLIENT_IP="2.2.2.2"/, e.message)
|
||||
|
||||
# turn IP Spoofing detection off.
|
||||
# This is useful for sites that are aimed at non-IP clients. The typical
|
||||
|
|
|
@ -279,7 +279,7 @@ class CookieStoreTest < ActionDispatch::IntegrationTest
|
|||
def test_session_store_with_explicit_domain
|
||||
with_test_route_set(:domain => "example.es") do
|
||||
get '/set_session_value'
|
||||
assert_match /domain=example\.es/, headers['Set-Cookie']
|
||||
assert_match(/domain=example\.es/, headers['Set-Cookie'])
|
||||
headers['Set-Cookie']
|
||||
end
|
||||
end
|
||||
|
|
|
@ -58,15 +58,15 @@ class ShowExceptionsTest < ActionDispatch::IntegrationTest
|
|||
|
||||
get "/", {}, {'action_dispatch.show_exceptions' => true}
|
||||
assert_response 500
|
||||
assert_match /puke/, body
|
||||
assert_match(/puke/, body)
|
||||
|
||||
get "/not_found", {}, {'action_dispatch.show_exceptions' => true}
|
||||
assert_response 404
|
||||
assert_match /#{ActionController::UnknownAction.name}/, body
|
||||
assert_match(/#{ActionController::UnknownAction.name}/, body)
|
||||
|
||||
get "/method_not_allowed", {}, {'action_dispatch.show_exceptions' => true}
|
||||
assert_response 405
|
||||
assert_match /ActionController::MethodNotAllowed/, body
|
||||
assert_match(/ActionController::MethodNotAllowed/, body)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -96,15 +96,15 @@ class ShowExceptionsTest < ActionDispatch::IntegrationTest
|
|||
|
||||
get "/", {}, {'action_dispatch.show_exceptions' => true}
|
||||
assert_response 500
|
||||
assert_match /puke/, body
|
||||
assert_match(/puke/, body)
|
||||
|
||||
get "/not_found", {}, {'action_dispatch.show_exceptions' => true}
|
||||
assert_response 404
|
||||
assert_match /#{ActionController::UnknownAction.name}/, body
|
||||
assert_match(/#{ActionController::UnknownAction.name}/, body)
|
||||
|
||||
get "/method_not_allowed", {}, {'action_dispatch.show_exceptions' => true}
|
||||
assert_response 405
|
||||
assert_match /ActionController::MethodNotAllowed/, body
|
||||
assert_match(/ActionController::MethodNotAllowed/, body)
|
||||
end
|
||||
|
||||
test "does not show filtered parameters" do
|
||||
|
@ -113,6 +113,6 @@ class ShowExceptionsTest < ActionDispatch::IntegrationTest
|
|||
get "/", {"foo"=>"bar"}, {'action_dispatch.show_exceptions' => true,
|
||||
'action_dispatch.parameter_filter' => [:foo]}
|
||||
assert_response 500
|
||||
assert_match ""foo"=>"[FILTERED]"", body
|
||||
assert_match(""foo"=>"[FILTERED]"", body)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -975,7 +975,7 @@ class AssetTagHelperNonVhostTest < ActionView::TestCase
|
|||
|
||||
def test_should_wildcard_asset_host_between_zero_and_four
|
||||
@controller.config.asset_host = 'http://a%d.example.com'
|
||||
assert_match %r(http://a[0123].example.com/collaboration/hieraki/images/xml.png), image_path('xml.png')
|
||||
assert_match(%r(http://a[0123].example.com/collaboration/hieraki/images/xml.png), image_path('xml.png'))
|
||||
end
|
||||
|
||||
def test_asset_host_without_protocol_should_use_request_protocol
|
||||
|
|
|
@ -203,7 +203,7 @@ class AtomFeedTest < ActionController::TestCase
|
|||
def test_feed_should_use_default_language_if_none_is_given
|
||||
with_restful_routing(:scrolls) do
|
||||
get :index, :id => "defaults"
|
||||
assert_match %r{xml:lang="en-US"}, @response.body
|
||||
assert_match(%r{xml:lang="en-US"}, @response.body)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ class AVLogSubscriberTest < ActiveSupport::TestCase
|
|||
wait
|
||||
|
||||
assert_equal 1, @logger.logged(:info).size
|
||||
assert_match /Rendered test\/hello_world\.erb/, @logger.logged(:info).last
|
||||
assert_match(/Rendered test\/hello_world\.erb/, @logger.logged(:info).last)
|
||||
end
|
||||
|
||||
def test_render_text_template
|
||||
|
@ -37,7 +37,7 @@ class AVLogSubscriberTest < ActiveSupport::TestCase
|
|||
wait
|
||||
|
||||
assert_equal 1, @logger.logged(:info).size
|
||||
assert_match /Rendered text template/, @logger.logged(:info).last
|
||||
assert_match(/Rendered text template/, @logger.logged(:info).last)
|
||||
end
|
||||
|
||||
def test_render_inline_template
|
||||
|
@ -45,7 +45,7 @@ class AVLogSubscriberTest < ActiveSupport::TestCase
|
|||
wait
|
||||
|
||||
assert_equal 1, @logger.logged(:info).size
|
||||
assert_match /Rendered inline template/, @logger.logged(:info).last
|
||||
assert_match(/Rendered inline template/, @logger.logged(:info).last)
|
||||
end
|
||||
|
||||
def test_render_partial_template
|
||||
|
@ -53,7 +53,7 @@ class AVLogSubscriberTest < ActiveSupport::TestCase
|
|||
wait
|
||||
|
||||
assert_equal 1, @logger.logged(:info).size
|
||||
assert_match /Rendered test\/_customer.erb/, @logger.logged(:info).last
|
||||
assert_match(/Rendered test\/_customer.erb/, @logger.logged(:info).last)
|
||||
end
|
||||
|
||||
def test_render_partial_with_implicit_path
|
||||
|
@ -62,7 +62,7 @@ class AVLogSubscriberTest < ActiveSupport::TestCase
|
|||
wait
|
||||
|
||||
assert_equal 1, @logger.logged(:info).size
|
||||
assert_match /Rendered customers\/_customer\.html\.erb/, @logger.logged(:info).last
|
||||
assert_match(/Rendered customers\/_customer\.html\.erb/, @logger.logged(:info).last)
|
||||
end
|
||||
|
||||
def test_render_collection_template
|
||||
|
@ -70,7 +70,7 @@ class AVLogSubscriberTest < ActiveSupport::TestCase
|
|||
wait
|
||||
|
||||
assert_equal 1, @logger.logged(:info).size
|
||||
assert_match /Rendered test\/_customer.erb/, @logger.logged(:info).last
|
||||
assert_match(/Rendered test\/_customer.erb/, @logger.logged(:info).last)
|
||||
end
|
||||
|
||||
def test_render_collection_with_implicit_path
|
||||
|
@ -79,7 +79,7 @@ class AVLogSubscriberTest < ActiveSupport::TestCase
|
|||
wait
|
||||
|
||||
assert_equal 1, @logger.logged(:info).size
|
||||
assert_match /Rendered customers\/_customer\.html\.erb/, @logger.logged(:info).last
|
||||
assert_match(/Rendered customers\/_customer\.html\.erb/, @logger.logged(:info).last)
|
||||
end
|
||||
|
||||
def test_render_collection_template_without_path
|
||||
|
@ -88,6 +88,6 @@ class AVLogSubscriberTest < ActiveSupport::TestCase
|
|||
wait
|
||||
|
||||
assert_equal 1, @logger.logged(:info).size
|
||||
assert_match /Rendered collection/, @logger.logged(:info).last
|
||||
assert_match(/Rendered collection/, @logger.logged(:info).last)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,8 +11,8 @@ class TagHelperTest < ActionView::TestCase
|
|||
|
||||
def test_tag_options
|
||||
str = tag("p", "class" => "show", :class => "elsewhere")
|
||||
assert_match /class="show"/, str
|
||||
assert_match /class="elsewhere"/, str
|
||||
assert_match(/class="show"/, str)
|
||||
assert_match(/class="elsewhere"/, str)
|
||||
end
|
||||
|
||||
def test_tag_options_rejects_nil_option
|
||||
|
|
|
@ -112,7 +112,7 @@ module ActionView
|
|||
@controller.controller_path = 'test'
|
||||
|
||||
@customers = [stub(:name => 'Eloy'), stub(:name => 'Manfred')]
|
||||
assert_match /Hello: EloyHello: Manfred/, render(:partial => 'test/from_helper')
|
||||
assert_match(/Hello: EloyHello: Manfred/, render(:partial => 'test/from_helper'))
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -201,7 +201,7 @@ module ActionView
|
|||
@controller.controller_path = "test"
|
||||
|
||||
@customers = [stub(:name => 'Eloy'), stub(:name => 'Manfred')]
|
||||
assert_match /Hello: EloyHello: Manfred/, render(:file => 'test/list')
|
||||
assert_match(/Hello: EloyHello: Manfred/, render(:file => 'test/list'))
|
||||
end
|
||||
|
||||
test "is able to render partials from templates and also use instance variables after view has been referenced" do
|
||||
|
@ -210,7 +210,7 @@ module ActionView
|
|||
view
|
||||
|
||||
@customers = [stub(:name => 'Eloy'), stub(:name => 'Manfred')]
|
||||
assert_match /Hello: EloyHello: Manfred/, render(:file => 'test/list')
|
||||
assert_match(/Hello: EloyHello: Manfred/, render(:file => 'test/list'))
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue