Change the empty block style to have space inside of the block

This commit is contained in:
Rafael Mendonça França 2018-09-25 13:18:20 -04:00
parent d34bd0d2d5
commit f679933daa
No known key found for this signature in database
GPG Key ID: FC23B6D0F1EEE948
60 changed files with 142 additions and 141 deletions

@ -137,6 +137,7 @@ Layout/SpaceBeforeBlockBraces:
# Use `foo { bar }` not `foo {bar}`.
Layout/SpaceInsideBlockBraces:
Enabled: true
EnforcedStyleForEmptyBraces: space
# Use `{ a: 1 }` not `{a:1}`.
Layout/SpaceInsideHashLiteralBraces:

@ -25,7 +25,7 @@ def test(options)
def test_assert_select_email
assert_raise ActiveSupport::TestCase::Assertion do
assert_select_email {}
assert_select_email { }
end
AssertSelectMailer.test("<div><p>foo</p><p>bar</p></div>").deliver_now

@ -138,7 +138,7 @@ def test_response_has_default_headers
response_headers = SimpleController.action("hello").call(
"REQUEST_METHOD" => "GET",
"rack.input" => -> {}
"rack.input" => -> { }
)[1]
assert response_headers.key?("X-Frame-Options")

@ -304,7 +304,7 @@ def test_delayed_autoload_after_write_within_interlock_hook
# Simulate InterlockHook
ActiveSupport::Dependencies.interlock.start_running
res = get :write_sleep_autoload
res.each {}
res.each { }
ActiveSupport::Dependencies.interlock.done_running
end

@ -20,7 +20,7 @@ def test_response_does_not_have_default_headers
response_headers = SimpleController.action("hello").call(
"REQUEST_METHOD" => "GET",
"rack.input" => -> {}
"rack.input" => -> { }
)[1]
assert_not response_headers.key?("X-Frame-Options")

@ -78,7 +78,7 @@ def using_defaults
def missing_templates
respond_to do |type|
# This test requires a block that is empty
type.json {}
type.json { }
type.xml
end
end

@ -309,7 +309,7 @@ def test_non_greedy_glob_regexp
def test_specific_controller_action_failure
rs.draw do
mount lambda {} => "/foo"
mount lambda { } => "/foo"
end
assert_raises(ActionController::UrlGenerationError) do

@ -42,7 +42,7 @@ def test_delete_works
end
test "use should push middleware class with block arguments onto the stack" do
proc = Proc.new {}
proc = Proc.new { }
assert_difference "@stack.size" do
@stack.use(BlockMiddleware, &proc)
end

@ -24,7 +24,7 @@ def url_for(options = {})
def stub_request(env = {})
ip_spoofing_check = env.key?(:ip_spoofing_check) ? env.delete(:ip_spoofing_check) : true
@trusted_proxies ||= nil
ip_app = ActionDispatch::RemoteIp.new(Proc.new {}, ip_spoofing_check, @trusted_proxies)
ip_app = ActionDispatch::RemoteIp.new(Proc.new { }, ip_spoofing_check, @trusted_proxies)
ActionDispatch::Http::URL.tld_length = env.delete(:tld_length) if env.key?(:tld_length)
ip_app.call(env)

@ -373,7 +373,7 @@ def test_no_routes_matched_filter_when_expanded
end
def test_not_routes_when_expanded
output = draw(grep: "rails/dummy", formatter: ActionDispatch::Routing::ConsoleFormatter::Expanded.new) {}
output = draw(grep: "rails/dummy", formatter: ActionDispatch::Routing::ConsoleFormatter::Expanded.new) { }
assert_equal [
"You don't have any routes defined!",
@ -450,7 +450,7 @@ def test_no_routes_matched_filter
end
def test_no_routes_were_defined
output = draw(grep: "Rails::DummyController") {}
output = draw(grep: "Rails::DummyController") { }
assert_equal [
"You don't have any routes defined!",

@ -1,5 +1,5 @@
# frozen_string_literal: true
module FooHelper
redefine_method(:baz) {}
redefine_method(:baz) { }
end

@ -13,7 +13,7 @@ def test_debug
end
def test_debug_with_marshal_error
obj = -> {}
obj = -> { }
assert_match obj.inspect, Nokogiri.XML(debug(obj)).content
end
end

@ -219,7 +219,7 @@ def test_with_output_buffer_sets_proper_encoding
def test_with_output_buffer_does_not_assume_there_is_an_output_buffer
assert_nil @av.output_buffer
assert_equal "", @av.with_output_buffer {}
assert_equal "", @av.with_output_buffer { }
end
def alt_encoding(output_buffer)

@ -2246,7 +2246,7 @@ def test_form_with_with_new_object
post.persisted = false
def post.to_key; nil; end
form_with(model: post) {}
form_with(model: post) { }
expected = whole_form("/posts")
assert_dom_equal expected, output_buffer
@ -2254,14 +2254,14 @@ def post.to_key; nil; end
def test_form_with_with_existing_object_in_list
@comment.save
form_with(model: [@post, @comment]) {}
form_with(model: [@post, @comment]) { }
expected = whole_form(post_comment_path(@post, @comment), method: "patch")
assert_dom_equal expected, output_buffer
end
def test_form_with_with_new_object_in_list
form_with(model: [@post, @comment]) {}
form_with(model: [@post, @comment]) { }
expected = whole_form(post_comments_path(@post))
assert_dom_equal expected, output_buffer
@ -2269,14 +2269,14 @@ def test_form_with_with_new_object_in_list
def test_form_with_with_existing_object_and_namespace_in_list
@comment.save
form_with(model: [:admin, @post, @comment]) {}
form_with(model: [:admin, @post, @comment]) { }
expected = whole_form(admin_post_comment_path(@post, @comment), method: "patch")
assert_dom_equal expected, output_buffer
end
def test_form_with_with_new_object_and_namespace_in_list
form_with(model: [:admin, @post, @comment]) {}
form_with(model: [:admin, @post, @comment]) { }
expected = whole_form(admin_post_comments_path(@post))
assert_dom_equal expected, output_buffer
@ -2290,13 +2290,13 @@ def test_form_with_with_existing_object_and_custom_url
end
def test_form_with_with_default_method_as_patch
form_with(model: @post) {}
form_with(model: @post) { }
expected = whole_form("/posts/123", method: "patch")
assert_dom_equal expected, output_buffer
end
def test_form_with_with_data_attributes
form_with(model: @post, data: { behavior: "stuff" }) {}
form_with(model: @post, data: { behavior: "stuff" }) { }
assert_match %r|data-behavior="stuff"|, output_buffer
assert_match %r|data-remote="true"|, output_buffer
end
@ -2315,7 +2315,7 @@ def test_form_with_only_instantiates_builder_once
end
end
form_with(model: @post, builder: builder_class) {}
form_with(model: @post, builder: builder_class) { }
assert_equal 1, initialization_count, "form builder instantiated more than once"
end

@ -3488,14 +3488,14 @@ def post.to_key; nil; end
def test_form_for_with_existing_object_in_list
@comment.save
form_for([@post, @comment]) {}
form_for([@post, @comment]) { }
expected = whole_form(post_comment_path(@post, @comment), "edit_comment_1", "edit_comment", method: "patch")
assert_dom_equal expected, output_buffer
end
def test_form_for_with_new_object_in_list
form_for([@post, @comment]) {}
form_for([@post, @comment]) { }
expected = whole_form(post_comments_path(@post), "new_comment", "new_comment")
assert_dom_equal expected, output_buffer
@ -3503,14 +3503,14 @@ def test_form_for_with_new_object_in_list
def test_form_for_with_existing_object_and_namespace_in_list
@comment.save
form_for([:admin, @post, @comment]) {}
form_for([:admin, @post, @comment]) { }
expected = whole_form(admin_post_comment_path(@post, @comment), "edit_comment_1", "edit_comment", method: "patch")
assert_dom_equal expected, output_buffer
end
def test_form_for_with_new_object_and_namespace_in_list
form_for([:admin, @post, @comment]) {}
form_for([:admin, @post, @comment]) { }
expected = whole_form(admin_post_comments_path(@post), "new_comment", "new_comment")
assert_dom_equal expected, output_buffer
@ -3524,13 +3524,13 @@ def test_form_for_with_existing_object_and_custom_url
end
def test_form_for_with_default_method_as_patch
form_for(@post) {}
form_for(@post) { }
expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch")
assert_dom_equal expected, output_buffer
end
def test_form_for_with_data_attributes
form_for(@post, data: { behavior: "stuff" }, remote: true) {}
form_for(@post, data: { behavior: "stuff" }, remote: true) { }
assert_match %r|data-behavior="stuff"|, output_buffer
assert_match %r|data-remote="true"|, output_buffer
end
@ -3549,7 +3549,7 @@ def test_form_for_only_instantiates_builder_once
end
end
form_for(@post, builder: builder_class) {}
form_for(@post, builder: builder_class) { }
assert_equal 1, initialization_count, "form builder instantiated more than once"
end

@ -668,7 +668,7 @@ def test_select_under_fields_for_with_block_without_options
@post = Post.new
output_buffer = fields_for :post, @post do |f|
concat(f.select(:category) {})
concat(f.select(:category) { })
end
assert_dom_equal(

@ -242,7 +242,7 @@ def self.routes
@routes ||= ActionDispatch::Routing::RouteSet.new
end
routes.draw { get "bar", to: lambda {} }
routes.draw { get "bar", to: lambda { } }
def self.call(*)
end

@ -504,7 +504,7 @@ def test_assert_enqueued_with_failure
assert_raise ActiveSupport::TestCase::Assertion do
LoggingJob.perform_later
assert_enqueued_with(job: LoggingJob) {}
assert_enqueued_with(job: LoggingJob) { }
end
error = assert_raise ActiveSupport::TestCase::Assertion do

@ -112,7 +112,7 @@ def initialize
def callback1; history << "callback1"; end
def callback2; history << "callback2"; end
def create
run_callbacks(:create) {}
run_callbacks(:create) { }
self
end
end

@ -176,7 +176,7 @@ def self.email
end
x.report "Model.log" do
Exhibit.connection.send(:log, "hello", "world") {}
Exhibit.connection.send(:log, "hello", "world") { }
end
x.report "AR.execute(query)" do

@ -101,7 +101,7 @@ def test_only_catch_active_record_errors_others_bubble_up
@connection.extend ProgrammerMistake
assert_raises ArgumentError do
@connection.disable_referential_integrity {}
@connection.disable_referential_integrity { }
end
end

@ -87,7 +87,7 @@ def test_primary_key_returns_nil_for_no_pk
def test_connection_no_db
assert_raises(ArgumentError) do
Base.sqlite3_connection {}
Base.sqlite3_connection { }
end
end

@ -89,6 +89,6 @@ def test_association_with_default_scope
private
def extend!(model)
ActiveRecord::Associations::Builder::HasMany.define_extensions(model, :association_name) {}
ActiveRecord::Associations::Builder::HasMany.define_extensions(model, :association_name) { }
end
end

@ -80,7 +80,7 @@ def test_should_construct_new_finder_sql_after_create
def test_force_reload
firm = Firm.new("name" => "A New Firm, Inc")
firm.save
firm.clients.each {} # forcing to load all clients
firm.clients.each { } # forcing to load all clients
assert firm.clients.empty?, "New firm shouldn't have client objects"
assert_equal 0, firm.clients.size, "New firm should have 0 clients"

@ -24,7 +24,7 @@ def test_each_should_execute_one_query_per_batch
def test_each_should_not_return_query_chain_and_execute_only_one_query
assert_queries(1) do
result = Post.find_each(batch_size: 100000) {}
result = Post.find_each(batch_size: 100000) { }
assert_nil result
end
end
@ -183,7 +183,7 @@ def test_find_in_batches_should_ignore_the_order_default_scope
def test_find_in_batches_should_error_on_ignore_the_order
assert_raise(ArgumentError) do
PostWithDefaultScope.find_in_batches(error_on_ignore: true) {}
PostWithDefaultScope.find_in_batches(error_on_ignore: true) { }
end
end
@ -192,7 +192,7 @@ def test_find_in_batches_should_not_error_if_config_overridden
prev = ActiveRecord::Base.error_on_ignored_order
ActiveRecord::Base.error_on_ignored_order = true
assert_nothing_raised do
PostWithDefaultScope.find_in_batches(error_on_ignore: false) {}
PostWithDefaultScope.find_in_batches(error_on_ignore: false) { }
end
ensure
# Set back to default
@ -204,7 +204,7 @@ def test_find_in_batches_should_error_on_config_specified_to_error
prev = ActiveRecord::Base.error_on_ignored_order
ActiveRecord::Base.error_on_ignored_order = true
assert_raise(ArgumentError) do
PostWithDefaultScope.find_in_batches() {}
PostWithDefaultScope.find_in_batches() { }
end
ensure
# Set back to default
@ -213,7 +213,7 @@ def test_find_in_batches_should_error_on_config_specified_to_error
def test_find_in_batches_should_not_error_by_default
assert_nothing_raised do
PostWithDefaultScope.find_in_batches() {}
PostWithDefaultScope.find_in_batches() { }
end
end
@ -228,7 +228,7 @@ def test_find_in_batches_should_not_ignore_the_default_scope_if_it_is_other_then
def test_find_in_batches_should_not_modify_passed_options
assert_nothing_raised do
Post.find_in_batches({ batch_size: 42, start: 1 }.freeze) {}
Post.find_in_batches({ batch_size: 42, start: 1 }.freeze) { }
end
end
@ -446,7 +446,7 @@ def test_in_batches_should_not_ignore_default_scope_without_order_statements
def test_in_batches_should_not_modify_passed_options
assert_nothing_raised do
Post.in_batches({ of: 42, start: 1 }.freeze) {}
Post.in_batches({ of: 42, start: 1 }.freeze) { }
end
end
@ -597,15 +597,15 @@ def test_find_in_batches_should_return_a_sized_enumerator
table: table_alias,
predicate_builder: predicate_builder
)
posts.find_each {}
posts.find_each { }
end
end
test ".find_each bypasses the query cache for its own queries" do
Post.cache do
assert_queries(2) do
Post.find_each {}
Post.find_each {}
Post.find_each { }
Post.find_each { }
end
end
end
@ -624,8 +624,8 @@ def test_find_in_batches_should_return_a_sized_enumerator
test ".find_in_batches bypasses the query cache for its own queries" do
Post.cache do
assert_queries(2) do
Post.find_in_batches {}
Post.find_in_batches {}
Post.find_in_batches { }
Post.find_in_batches { }
end
end
end
@ -644,8 +644,8 @@ def test_find_in_batches_should_return_a_sized_enumerator
test ".in_batches bypasses the query cache for its own queries" do
Post.cache do
assert_queries(2) do
Post.in_batches {}
Post.in_batches {}
Post.in_batches { }
Post.in_batches { }
end
end
end

@ -480,7 +480,7 @@ def test_inheritance_of_callbacks
def test_before_save_doesnt_allow_on_option
exception = assert_raises ArgumentError do
Class.new(ActiveRecord::Base) do
before_save(on: :create) {}
before_save(on: :create) { }
end
end
assert_equal "Unknown key: :on. Valid keys are: :if, :unless, :prepend", exception.message
@ -489,7 +489,7 @@ def test_before_save_doesnt_allow_on_option
def test_around_save_doesnt_allow_on_option
exception = assert_raises ArgumentError do
Class.new(ActiveRecord::Base) do
around_save(on: :create) {}
around_save(on: :create) { }
end
end
assert_equal "Unknown key: :on. Valid keys are: :if, :unless, :prepend", exception.message
@ -498,7 +498,7 @@ def test_around_save_doesnt_allow_on_option
def test_after_save_doesnt_allow_on_option
exception = assert_raises ArgumentError do
Class.new(ActiveRecord::Base) do
after_save(on: :create) {}
after_save(on: :create) { }
end
end
assert_equal "Unknown key: :on. Valid keys are: :if, :unless, :prepend", exception.message

@ -106,7 +106,7 @@ def executor
def middleware(app)
lambda do |env|
a, b, c = executor.wrap { app.call(env) }
[a, b, Rack::BodyProxy.new(c) {}]
[a, b, Rack::BodyProxy.new(c) { }]
end
end
end

@ -661,7 +661,7 @@ def conn.requires_reloading? # make sure it gets removed from the pool by clear_
end
stuck_thread = Thread.new do
pool.with_connection {}
pool.with_connection { }
end
# wait for stuck_thread to get in queue

@ -12,7 +12,7 @@ def test_should_preserve_normal_respond_to_behaviour_on_base
end
def test_should_preserve_normal_respond_to_behaviour_and_respond_to_newly_added_method
class << Topic; self; end.send(:define_method, :method_added_for_finder_respond_to_test) {}
class << Topic; self; end.send(:define_method, :method_added_for_finder_respond_to_test) { }
assert_respond_to Topic, :method_added_for_finder_respond_to_test
ensure
class << Topic; self; end.send(:remove_method, :method_added_for_finder_respond_to_test)

@ -974,7 +974,7 @@ def fire_connection_notification(connection)
connection_id: connection.object_id
}
message_bus.instrument("!connection.active_record", payload) {}
message_bus.instrument("!connection.active_record", payload) { }
end
end
end

@ -117,13 +117,13 @@ def test_invert_create_table
end
def test_invert_create_table_with_options_and_block
block = Proc.new {}
block = Proc.new { }
drop_table = @recorder.inverse_of :create_table, [:people_reminders, id: false], &block
assert_equal [:drop_table, [:people_reminders, id: false], block], drop_table
end
def test_invert_drop_table
block = Proc.new {}
block = Proc.new { }
create_table = @recorder.inverse_of :drop_table, [:people_reminders, id: false], &block
assert_equal [:create_table, [:people_reminders, id: false], block], create_table
end
@ -145,7 +145,7 @@ def test_invert_create_join_table_with_table_name
end
def test_invert_drop_join_table
block = Proc.new {}
block = Proc.new { }
create_join_table = @recorder.inverse_of :drop_join_table, [:musics, :artists, table_name: :catalog], &block
assert_equal [:create_join_table, [:musics, :artists, table_name: :catalog], block], create_join_table
end

@ -25,7 +25,7 @@ def test_errors_if_pending
ActiveRecord::Base.connection.drop_table "schema_migrations", if_exists: true
assert_raises ActiveRecord::PendingMigrationError do
CheckPending.new(Proc.new {}).call({})
CheckPending.new(Proc.new { }).call({})
end
end
@ -34,7 +34,7 @@ def test_checks_if_supported
migrator = Base.connection.migration_context
capture(:stdout) { migrator.migrate }
assert_nil CheckPending.new(Proc.new {}).call({})
assert_nil CheckPending.new(Proc.new { }).call({})
end
end
end

@ -1144,7 +1144,7 @@ def test_copying_migrations_to_empty_directory
def test_check_pending_with_stdlib_logger
old, ActiveRecord::Base.logger = ActiveRecord::Base.logger, ::Logger.new($stdout)
quietly do
assert_nothing_raised { ActiveRecord::Migration::CheckPending.new(Proc.new {}).call({}) }
assert_nothing_raised { ActiveRecord::Migration::CheckPending.new(Proc.new { }).call({}) }
end
ensure
ActiveRecord::Base.logger = old

@ -489,7 +489,7 @@ def private_method; end
[:public_method, :protected_method, :private_method].each do |reserved_method|
assert Topic.respond_to?(reserved_method, true)
assert_called(ActiveRecord::Base.logger, :warn) do
silence_warnings { Topic.scope(reserved_method, -> {}) }
silence_warnings { Topic.scope(reserved_method, -> { }) }
end
end
end

@ -66,7 +66,7 @@ def test_suppresses_validations_on_create
def test_suppresses_when_nested_multiple_times
assert_no_difference -> { Notification.count } do
Notification.suppress do
Notification.suppress {}
Notification.suppress { }
Notification.create
Notification.create!
Notification.new.save

@ -90,7 +90,7 @@ class Tag2 < ActiveRecord::Base
test "setting isolation when joining a transaction raises an error" do
Tag.transaction do
assert_raises(ActiveRecord::TransactionIsolationError) do
Tag.transaction(isolation: :serializable) {}
Tag.transaction(isolation: :serializable) { }
end
end
end
@ -98,7 +98,7 @@ class Tag2 < ActiveRecord::Base
test "setting isolation when starting a nested transaction raises error" do
Tag.transaction do
assert_raises(ActiveRecord::TransactionIsolationError) do
Tag.transaction(requires_new: true, isolation: :serializable) {}
Tag.transaction(requires_new: true, isolation: :serializable) { }
end
end
end

@ -930,7 +930,7 @@ def test_transaction_rollback_with_primarykeyless_tables
klass = Class.new(ActiveRecord::Base) do
self.table_name = "transaction_without_primary_keys"
after_commit {} # necessary to trigger the has_transactional_callbacks branch
after_commit { } # necessary to trigger the has_transactional_callbacks branch
end
assert_no_difference(-> { klass.count }) do
@ -945,7 +945,7 @@ def test_transaction_rollback_with_primarykeyless_tables
def test_empty_transaction_is_not_materialized
assert_no_queries do
Topic.transaction {}
Topic.transaction { }
end
end
@ -968,7 +968,7 @@ def test_prepared_statement_materializes_transaction
def test_savepoint_does_not_materialize_transaction
assert_no_queries do
Topic.transaction do
Topic.transaction(requires_new: true) {}
Topic.transaction(requires_new: true) { }
end
end
end
@ -991,7 +991,7 @@ def test_accessing_raw_connection_disables_lazy_transactions
Topic.connection.raw_connection
assert_sql(/BEGIN/i, /COMMIT/i) do
Topic.transaction {}
Topic.transaction { }
end
end
@ -1001,7 +1001,7 @@ def test_checking_in_connection_reenables_lazy_transactions
Topic.connection_pool.checkin connection
assert_no_queries do
connection.transaction {}
connection.transaction { }
end
end

@ -81,7 +81,7 @@ def ratings
after_add: [:log_after_adding, Proc.new { |o, r| o.post_log << "after_adding_proc#{r.id || '<new>'}" }]
has_many :unchangeable_posts, class_name: "Post", before_add: :raise_exception, after_add: :log_after_adding
has_many :categorizations, -> {}
has_many :categorizations, -> { }
has_many :categories, through: :categorizations
has_many :named_categories, through: :categorizations

@ -24,7 +24,7 @@ def private_lifo
end
scope "approved_as_string", -> { where(approved: true) }
scope :anonymous_extension, -> {} do
scope :anonymous_extension, -> { } do
def one
1
end

@ -947,7 +947,7 @@
end
[:circles, :squares, :triangles, :non_poly_ones, :non_poly_twos].each do |t|
create_table(t, force: true) {}
create_table(t, force: true) { }
end
create_table :men, force: true do |t|

@ -77,7 +77,7 @@ module ActiveStorage::Service::SharedServiceTests
test "downloading a nonexistent file in chunks" do
assert_raises(ActiveStorage::FileNotFoundError) do
@service.download(SecureRandom.base58(24)) {}
@service.download(SecureRandom.base58(24)) { }
end
end

@ -694,7 +694,7 @@ def handle_expired_entry(entry, key, options)
end
def get_entry_value(entry, name, options)
instrument(:fetch_hit, name, options) {}
instrument(:fetch_hit, name, options) { }
entry.value
end

@ -3,7 +3,7 @@
class Class
begin
# Test if this Ruby supports each_object against singleton_class
ObjectSpace.each_object(Numeric.singleton_class) {}
ObjectSpace.each_object(Numeric.singleton_class) { }
# Returns an array with all classes that are < than its receiver.
#

@ -43,7 +43,7 @@ class Deprecation
deprecation_horizon: deprecation_horizon)
},
silence: ->(message, callstack, deprecation_horizon, gem_name) {},
silence: ->(message, callstack, deprecation_horizon, gem_name) { },
}
# Behavior module allows to determine how to display deprecation messages.

@ -59,13 +59,13 @@ def test_with_silence
def test_within_level
logger.level = ActiveSupport::Logger::DEBUG
benchmark("included_debug_run", level: :debug) {}
benchmark("included_debug_run", level: :debug) { }
assert_last_logged "included_debug_run"
end
def test_outside_level
logger.level = ActiveSupport::Logger::ERROR
benchmark("skipped_debug_run", level: :debug) {}
benchmark("skipped_debug_run", level: :debug) { }
assert_no_match(/skipped_debug_run/, buffer.last)
ensure
logger.level = ActiveSupport::Logger::DEBUG

@ -424,7 +424,7 @@ def test_cache_hit_instrumentation
@events << ActiveSupport::Notifications::Event.new(*args)
end
assert @cache.write(key, "1", raw: true)
assert @cache.fetch(key) {}
assert @cache.fetch(key) { }
assert_equal 1, @events.length
assert_equal "cache_read.active_support", @events[0].name
assert_equal :fetch, @events[0].payload[:super_operation]
@ -438,7 +438,7 @@ def test_cache_miss_instrumentation
ActiveSupport::Notifications.subscribe(/^cache_(.*)\.active_support$/) do |*args|
@events << ActiveSupport::Notifications::Event.new(*args)
end
assert_not @cache.fetch("bad_key") {}
assert_not @cache.fetch("bad_key") { }
assert_equal 3, @events.length
assert_equal "cache_read.active_support", @events[0].name
assert_equal "cache_generate.active_support", @events[1].name

@ -17,7 +17,7 @@ def test_local_cache_cleared_on_close
})
_, _, body = middleware.call({})
assert LocalCacheRegistry.cache_for(key), "should still have a cache"
body.each {}
body.each { }
assert LocalCacheRegistry.cache_for(key), "should still have a cache"
body.close
assert_nil LocalCacheRegistry.cache_for(key)

@ -953,7 +953,7 @@ def test_proc_arity_1
def test_proc_arity_2
assert_raises(ArgumentError) do
klass = build_class(->(x, y) {})
klass = build_class(->(x, y) { })
klass.new.run
end
end
@ -1032,7 +1032,7 @@ def test_proc_arity1
def test_proc_arity2
assert_raises(ArgumentError) do
object = build_class(->(a, b) {}).new
object = build_class(->(a, b) { }).new
object.run
end
end

@ -35,7 +35,7 @@ def test_extract_on_empty_array
empty_array = []
array_id = empty_array.object_id
new_empty_array = empty_array.extract! {}
new_empty_array = empty_array.extract! { }
assert_equal [], new_empty_array
assert_equal [], empty_array

@ -5,7 +5,7 @@
class ModuleConcerningTest < ActiveSupport::TestCase
def test_concerning_declares_a_concern_and_includes_it_immediately
klass = Class.new { concerning(:Foo) {} }
klass = Class.new { concerning(:Foo) { } }
assert_includes klass.ancestors, klass::Foo, klass.ancestors.inspect
end
end

@ -108,14 +108,14 @@ def test_no_overlaps_on_time
def test_each_on_time_with_zone
twz = ActiveSupport::TimeWithZone.new(nil, ActiveSupport::TimeZone["Eastern Time (US & Canada)"], Time.utc(2006, 11, 28, 10, 30))
assert_raises TypeError do
((twz - 1.hour)..twz).each {}
((twz - 1.hour)..twz).each { }
end
end
def test_step_on_time_with_zone
twz = ActiveSupport::TimeWithZone.new(nil, ActiveSupport::TimeZone["Eastern Time (US & Canada)"], Time.utc(2006, 11, 28, 10, 30))
assert_raises TypeError do
((twz - 1.hour)..twz).step(1) {}
((twz - 1.hour)..twz).step(1) { }
end
end
@ -131,11 +131,11 @@ def test_case_equals_on_time_with_zone
def test_date_time_with_each
datetime = DateTime.now
assert(((datetime - 1.hour)..datetime).each {})
assert(((datetime - 1.hour)..datetime).each { })
end
def test_date_time_with_step
datetime = DateTime.now
assert(((datetime - 1.hour)..datetime).step(1) {})
assert(((datetime - 1.hour)..datetime).step(1) { })
end
end

@ -1105,7 +1105,7 @@ def test_use_zone_with_exception_raised
def test_use_zone_raises_on_invalid_timezone
Time.zone = "Alaska"
assert_raise ArgumentError do
Time.use_zone("No such timezone exists") {}
Time.use_zone("No such timezone exists") { }
end
assert_equal ActiveSupport::TimeZone["Alaska"], Time.zone
end

@ -816,7 +816,7 @@ def test_unloadable_constants_should_receive_callback
end
def test_new_contants_in_without_constants
assert_equal [], (ActiveSupport::Dependencies.new_constants_in(Object) {})
assert_equal [], (ActiveSupport::Dependencies.new_constants_in(Object) { })
assert ActiveSupport::Dependencies.constant_watch_stack.all? { |k, v| v.empty? }
end
@ -892,7 +892,7 @@ def test_new_constants_in_with_inherited_constants
def test_new_constants_in_with_illegal_module_name_raises_correct_error
assert_raise(NameError) do
ActiveSupport::Dependencies.new_constants_in("Illegal-Name") {}
ActiveSupport::Dependencies.new_constants_in("Illegal-Name") { }
end
end

@ -38,7 +38,7 @@ def touch(files)
FileUtils.touch(tmpfiles)
checker = new_checker(tmpfiles) {}
checker = new_checker(tmpfiles) { }
assert_not_predicate checker, :updated?
# Pipes used for flow control across fork.

@ -23,7 +23,7 @@ def test_callbacks_share_state
executor.to_run { @foo = true }
executor.to_complete { result = @foo }
executor.wrap {}
executor.wrap { }
assert result
end
@ -85,7 +85,7 @@ def test_hooks_carry_state
executor.register_hook(hook)
executor.wrap {}
executor.wrap { }
assert_equal :some_state, supplied_state
end
@ -105,7 +105,7 @@ def test_nil_state_is_sufficient
executor.register_hook(hook)
executor.wrap {}
executor.wrap { }
assert_nil supplied_state
end
@ -129,7 +129,7 @@ def test_exception_skips_uninvoked_hook
executor.register_hook(hook)
assert_raises(DummyError) do
executor.wrap {}
executor.wrap { }
end
assert_equal :none, supplied_state
@ -154,7 +154,7 @@ def test_exception_unwinds_invoked_hook
end
assert_raises(DummyError) do
executor.wrap {}
executor.wrap { }
end
assert_equal :some_state, supplied_state
@ -187,7 +187,7 @@ def test_hook_insertion_order
executor.register_hook(hook_class.new(:c), outer: true)
executor.register_hook(hook_class.new(:d))
executor.wrap {}
executor.wrap { }
assert_equal [:run_c, :run_a, :run_b, :run_d, :complete_a, :complete_b, :complete_d, :complete_c], invoked
assert_equal [:state_a, :state_b, :state_d, :state_c], supplied_state
@ -209,9 +209,9 @@ def test_class_serial_is_unaffected
executor.register_hook(hook)
before = RubyVM.stat(:class_serial)
executor.wrap {}
executor.wrap {}
executor.wrap {}
executor.wrap { }
executor.wrap { }
executor.wrap { }
after = RubyVM.stat(:class_serial)
assert_equal before, after

@ -90,7 +90,7 @@ def test_subsribing_to_instrumentation_while_inside_it
ActiveSupport::Notifications.subscribe("foo", TestSubscriber.new)
ActiveSupport::Notifications.instrument("foo") do
ActiveSupport::Notifications.subscribe("foo") {}
ActiveSupport::Notifications.subscribe("foo") { }
end
ensure
ActiveSupport::Notifications.notifier = old_notifier

@ -35,13 +35,13 @@ def test_only_run_when_check_passes
r = new_reloader { true }
invoked = false
r.to_run { invoked = true }
r.wrap {}
r.wrap { }
assert invoked
r = new_reloader { false }
invoked = false
r.to_run { invoked = true }
r.wrap {}
r.wrap { }
assert_not invoked
end
@ -53,7 +53,7 @@ def test_full_reload_sequence
reloader.executor.to_run { called << :executor_run }
reloader.executor.to_complete { called << :executor_complete }
reloader.wrap {}
reloader.wrap { }
assert_equal [:executor_run, :reloader_run, :prepare, :reloader_complete, :executor_complete], called
called = []
@ -63,7 +63,7 @@ def test_full_reload_sequence
reloader.check = lambda { false }
called = []
reloader.wrap {}
reloader.wrap { }
assert_equal [:executor_run, :executor_complete], called
called = []

@ -11,29 +11,29 @@ def setup
def test_reentrancy
thread = Thread.new do
@lock.sharing { @lock.sharing {} }
@lock.exclusive { @lock.exclusive {} }
@lock.sharing { @lock.sharing { } }
@lock.exclusive { @lock.exclusive { } }
end
assert_threads_not_stuck thread
end
def test_sharing_doesnt_block
with_thread_waiting_in_lock_section(:sharing) do |sharing_thread_latch|
assert_threads_not_stuck(Thread.new { @lock.sharing {} })
assert_threads_not_stuck(Thread.new { @lock.sharing { } })
end
end
def test_sharing_blocks_exclusive
with_thread_waiting_in_lock_section(:sharing) do |sharing_thread_release_latch|
@lock.exclusive(no_wait: true) { flunk } # polling should fail
exclusive_thread = Thread.new { @lock.exclusive {} }
exclusive_thread = Thread.new { @lock.exclusive { } }
assert_threads_stuck_but_releasable_by_latch exclusive_thread, sharing_thread_release_latch
end
end
def test_exclusive_blocks_sharing
with_thread_waiting_in_lock_section(:exclusive) do |exclusive_thread_release_latch|
sharing_thread = Thread.new { @lock.sharing {} }
sharing_thread = Thread.new { @lock.sharing { } }
assert_threads_stuck_but_releasable_by_latch sharing_thread, exclusive_thread_release_latch
end
end
@ -42,7 +42,7 @@ def test_multiple_exlusives_are_able_to_progress
with_thread_waiting_in_lock_section(:sharing) do |sharing_thread_release_latch|
exclusive_threads = (1..2).map do
Thread.new do
@lock.exclusive {}
@lock.exclusive { }
end
end
@ -53,7 +53,7 @@ def test_multiple_exlusives_are_able_to_progress
def test_sharing_is_upgradeable_to_exclusive
upgrading_thread = Thread.new do
@lock.sharing do
@lock.exclusive {}
@lock.exclusive { }
end
end
assert_threads_not_stuck upgrading_thread
@ -66,7 +66,7 @@ def test_exclusive_upgrade_waits_for_other_sharers_to_leave
upgrading_thread = Thread.new do
@lock.sharing do
in_sharing.count_down
@lock.exclusive {}
@lock.exclusive { }
end
end
@ -81,7 +81,7 @@ def test_exclusive_matching_purpose
exclusive_threads = (1..2).map do
Thread.new do
@lock.send(use_upgrading ? :sharing : :tap) do
@lock.exclusive(purpose: :load, compatible: [:load, :unload]) {}
@lock.exclusive(purpose: :load, compatible: [:load, :unload]) { }
end
end
end
@ -95,7 +95,7 @@ def test_killed_thread_loses_lock
with_thread_waiting_in_lock_section(:sharing) do |sharing_thread_release_latch|
thread = Thread.new do
@lock.sharing do
@lock.exclusive {}
@lock.exclusive { }
end
end
@ -105,7 +105,7 @@ def test_killed_thread_loses_lock
sharing_thread_release_latch.count_down
thread = Thread.new do
@lock.exclusive {}
@lock.exclusive { }
end
assert_threads_not_stuck thread
@ -121,13 +121,13 @@ def test_exclusive_conflicting_purpose
Thread.new do
@lock.send(use_upgrading ? :sharing : :tap) do
together.wait
@lock.exclusive(purpose: :red, compatible: [:green, :purple]) {}
@lock.exclusive(purpose: :red, compatible: [:green, :purple]) { }
end
end,
Thread.new do
@lock.send(use_upgrading ? :sharing : :tap) do
together.wait
@lock.exclusive(purpose: :blue, compatible: [:green]) {}
@lock.exclusive(purpose: :blue, compatible: [:green]) { }
end
end
]
@ -138,7 +138,7 @@ def test_exclusive_conflicting_purpose
# a sharing block. While it's blocked, it holds no lock, so it
# doesn't interfere with any other attempts.
no_purpose_thread = Thread.new do
@lock.exclusive {}
@lock.exclusive { }
end
assert_threads_stuck no_purpose_thread
@ -147,7 +147,7 @@ def test_exclusive_conflicting_purpose
# lock, but as soon as that's released, it can run --
# regardless of whether those threads hold share locks.
compatible_thread = Thread.new do
@lock.exclusive(purpose: :green, compatible: []) {}
@lock.exclusive(purpose: :green, compatible: []) { }
end
assert_threads_stuck compatible_thread
@ -231,7 +231,7 @@ def test_new_share_attempts_block_on_waiting_exclusive
assert_threads_stuck waiting_exclusive
late_share_attempt = Thread.new do
@lock.sharing {}
@lock.sharing { }
end
assert_threads_stuck late_share_attempt
@ -252,14 +252,14 @@ def test_share_remains_reentrant_ignoring_a_waiting_exclusive
@lock.sharing do
ready.wait
attempt_reentrancy.wait
@lock.sharing {}
@lock.sharing { }
end
end
exclusive = Thread.new do
@lock.sharing do
ready.wait
@lock.exclusive {}
@lock.exclusive { }
end
end
@ -280,7 +280,7 @@ def test_compatible_exclusives_cooperate_to_both_proceed
Thread.new do
@lock.sharing do
ready.wait
@lock.exclusive(purpose: :x, compatible: [:x], after_compatible: [:x]) {}
@lock.exclusive(purpose: :x, compatible: [:x], after_compatible: [:x]) { }
done.wait
end
end
@ -297,7 +297,7 @@ def test_manual_yield
Thread.new do
@lock.sharing do
ready.wait
@lock.exclusive(purpose: :x) {}
@lock.exclusive(purpose: :x) { }
done.wait
end
end,
@ -323,7 +323,7 @@ def test_manual_incompatible_yield
Thread.new do
@lock.sharing do
ready.wait
@lock.exclusive(purpose: :x) {}
@lock.exclusive(purpose: :x) { }
done.wait
end
end,
@ -352,7 +352,7 @@ def test_manual_recursive_yield
Thread.new do
@lock.sharing do
ready.wait
@lock.exclusive(purpose: :x) {}
@lock.exclusive(purpose: :x) { }
done.wait
end
end,
@ -386,7 +386,7 @@ def test_manual_recursive_yield_cannot_expand_outer_compatible
incompatible_thread = Thread.new do
@lock.sharing do
ready.wait
@lock.exclusive(purpose: :x) {}
@lock.exclusive(purpose: :x) { }
end
end
@ -418,7 +418,7 @@ def test_manual_recursive_yield_restores_previous_compatible
incompatible_thread = Thread.new do
ready.wait
@lock.exclusive(purpose: :z) {}
@lock.exclusive(purpose: :z) { }
end
recursive_yield_shares_thread = Thread.new do
@ -427,7 +427,7 @@ def test_manual_recursive_yield_restores_previous_compatible
@lock.yield_shares(compatible: [:y]) do
do_nesting.wait
@lock.sharing do
@lock.yield_shares(compatible: [:x, :y]) {}
@lock.yield_shares(compatible: [:x, :y]) { }
end
after_nesting.wait
end
@ -439,12 +439,12 @@ def test_manual_recursive_yield_restores_previous_compatible
assert_threads_stuck incompatible_thread
compatible_thread = Thread.new do
@lock.exclusive(purpose: :y) {}
@lock.exclusive(purpose: :y) { }
end
assert_threads_not_stuck compatible_thread
post_nesting_incompatible_thread = Thread.new do
@lock.exclusive(purpose: :x) {}
@lock.exclusive(purpose: :x) { }
end
assert_threads_stuck post_nesting_incompatible_thread

@ -12,8 +12,8 @@ class Runner
class << self
def attach_before_load_options(opts)
opts.on("--warnings", "-w", "Run with Ruby warnings enabled") {}
opts.on("-e", "--environment ENV", "Run tests in the ENV environment") {}
opts.on("--warnings", "-w", "Run with Ruby warnings enabled") { }
opts.on("-e", "--environment ENV", "Run tests in the ENV environment") { }
end
def parse_options(argv)

@ -56,7 +56,7 @@ def teardown
end
def test_notification
logger = TestLogger.new {}
logger = TestLogger.new { }
assert_difference("subscriber.starts.length") do
assert_difference("subscriber.finishes.length") do