Enable `Layout/SpaceBeforeComma` rubocop rule, and fixed more

Follow up of #31390.
This commit is contained in:
Ryuta Kamizono 2017-12-12 20:00:50 +09:00
parent 38b2904f2c
commit 2b35826389
24 changed files with 46 additions and 43 deletions

View File

@ -73,6 +73,9 @@ Layout/SpaceAroundKeyword:
Layout/SpaceAroundOperators:
Enabled: true
Layout/SpaceBeforeComma:
Enabled: true
Layout/SpaceBeforeFirstArg:
Enabled: true

View File

@ -39,7 +39,7 @@ class MessageDeliveryTest < ActiveSupport::TestCase
end
test "its message should be a Mail::Message" do
assert_equal Mail::Message , @mail.message.class
assert_equal Mail::Message, @mail.message.class
end
test "should respond to .deliver_later" do

View File

@ -105,7 +105,7 @@ class ActionMailerUrlTest < ActionMailer::TestCase
assert_url_for "/dummy_model", DummyModel
# array
assert_url_for "/dummy_model" , [DummyModel]
assert_url_for "/dummy_model", [DummyModel]
end
def test_signed_up_with_url

View File

@ -307,7 +307,7 @@ class ResourcesTest < ActionController::TestCase
set.draw do
resources :messages do
member do
match :mark , via: method
match :mark, via: method
match :unmark, via: method
end
end

View File

@ -1687,7 +1687,7 @@ class RouteSetTest < ActiveSupport::TestCase
def test_routes_with_symbols
set.draw do
get "unnamed", controller: :pages, action: :show, name: :as_symbol
get "named" , controller: :pages, action: :show, name: :as_symbol, as: :named
get "named", controller: :pages, action: :show, name: :as_symbol, as: :named
end
assert_equal({ controller: "pages", action: "show", name: :as_symbol }, set.recognize_path("/unnamed"))
assert_equal({ controller: "pages", action: "show", name: :as_symbol }, set.recognize_path("/named"))
@ -1893,7 +1893,7 @@ class RouteSetTest < ActiveSupport::TestCase
assert_equal({ controller: "blog", action: "show_date", year: "2006", month: "07", day: "28" }, controller.request.path_parameters)
assert_equal("/blog/2006/07/25", controller.url_for(day: 25, only_path: true))
assert_equal("/blog/2005", controller.url_for(year: 2005, only_path: true))
assert_equal("/blog/show/123", controller.url_for(action: "show" , id: 123, only_path: true))
assert_equal("/blog/show/123", controller.url_for(action: "show", id: 123, only_path: true))
assert_equal("/blog/2006", controller.url_for(year: 2006, only_path: true))
assert_equal("/blog/2006", controller.url_for(year: 2006, month: nil, only_path: true))
end

View File

@ -18,7 +18,7 @@ module ActionDispatch
def test_filename_is_different_object
file_str = "foo"
uf = Http::UploadedFile.new(filename: file_str, tempfile: Object.new)
assert_not_equal file_str.object_id , uf.original_filename.object_id
assert_not_equal file_str.object_id, uf.original_filename.object_id
end
def test_filename_should_be_in_utf_8

View File

@ -687,7 +687,7 @@ class DateHelperTest < ActionView::TestCase
expected << %(<option value=""></option>\n<option value="00">00</option>\n<option value="15">15</option>\n<option value="30">30</option>\n<option value="45">45</option>\n)
expected << "</select>\n"
assert_dom_equal expected, select_minute(Time.mktime(2003, 8, 16, 8, 4, 18), include_blank: true , minute_step: 15)
assert_dom_equal expected, select_minute(Time.mktime(2003, 8, 16, 8, 4, 18), include_blank: true, minute_step: 15)
end
def test_select_minute_nil_with_blank
@ -703,7 +703,7 @@ class DateHelperTest < ActionView::TestCase
expected << %(<option value=""></option>\n<option value="00">00</option>\n<option value="15">15</option>\n<option value="30">30</option>\n<option value="45">45</option>\n)
expected << "</select>\n"
assert_dom_equal expected, select_minute(nil, include_blank: true , minute_step: 15)
assert_dom_equal expected, select_minute(nil, include_blank: true, minute_step: 15)
end
def test_select_minute_with_hidden

View File

@ -367,7 +367,7 @@ class FormOptionsHelperTest < ActionView::TestCase
assert_dom_equal(
"<optgroup label=\"----------\"><option value=\"US\">US</option>\n<option value=\"Canada\">Canada</option></optgroup><optgroup label=\"----------\"><option value=\"GB\">GB</option>\n<option value=\"Germany\">Germany</option></optgroup>",
grouped_options_for_select([["US", "Canada"] , ["GB", "Germany"]], nil, divider: "----------")
grouped_options_for_select([["US", "Canada"], ["GB", "Germany"]], nil, divider: "----------")
)
end

View File

@ -307,8 +307,8 @@ class TagHelperTest < ActionView::TestCase
def test_tag_builder_disable_escaping
assert_equal '<a href="&amp;"></a>', tag.a(href: "&amp;", escape_attributes: false)
assert_equal '<a href="&amp;">cnt</a>', tag.a(href: "&amp;" , escape_attributes: false) { "cnt" }
assert_equal '<br data-hidden="&amp;">', tag.br("data-hidden": "&amp;" , escape_attributes: false)
assert_equal '<a href="&amp;">cnt</a>', tag.a(href: "&amp;", escape_attributes: false) { "cnt" }
assert_equal '<br data-hidden="&amp;">', tag.br("data-hidden": "&amp;", escape_attributes: false)
assert_equal '<a href="&amp;">content</a>', tag.a("content", href: "&amp;", escape_attributes: false)
assert_equal '<a href="&amp;">content</a>', tag.a(href: "&amp;", escape_attributes: false) { "content" }
end

View File

@ -68,7 +68,7 @@ end
(Dir["test/cases/**/*_test.rb"].reject {
|x| x.include?("/adapters/")
} + Dir["test/cases/adapters/#{adapter_short}/**/*_test.rb"]).all? do |file|
sh(Gem.ruby, "-w" , "-Itest", file)
sh(Gem.ruby, "-w", "-Itest", file)
end || raise("Failures")
end
end

View File

@ -1277,10 +1277,10 @@ module ActiveRecord
end
def validate(migrations)
name , = migrations.group_by(&:name).find { |_, v| v.length > 1 }
name, = migrations.group_by(&:name).find { |_, v| v.length > 1 }
raise DuplicateMigrationNameError.new(name) if name
version , = migrations.group_by(&:version).find { |_, v| v.length > 1 }
version, = migrations.group_by(&:version).find { |_, v| v.length > 1 }
raise DuplicateMigrationVersionError.new(version) if version
end

View File

@ -136,7 +136,7 @@ class CascadedEagerLoadingTest < ActiveRecord::TestCase
end
def test_eager_association_loading_with_multiple_stis_and_order
author = Author.all.merge!(includes: { posts: [ :special_comments , :very_special_comment ] }, order: ["authors.name", "comments.body", "very_special_comments_posts.body"], where: "posts.id = 4").first
author = Author.all.merge!(includes: { posts: [ :special_comments, :very_special_comment ] }, order: ["authors.name", "comments.body", "very_special_comments_posts.body"], where: "posts.id = 4").first
assert_equal authors(:david), author
assert_no_queries do
author.posts.first.special_comments

View File

@ -2350,7 +2350,7 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
test "does not duplicate associations when used with natural primary keys" do
speedometer = Speedometer.create!(id: "4")
speedometer.minivans.create!(minivan_id: "a-van-red" , name: "a van", color: "red")
speedometer.minivans.create!(minivan_id: "a-van-red", name: "a van", color: "red")
assert_equal 1, speedometer.minivans.to_a.size, "Only one association should be present:\n#{speedometer.minivans.to_a}"
assert_equal 1, speedometer.reload.minivans.to_a.size

View File

@ -629,7 +629,7 @@ class BasicsTest < ActiveRecord::TestCase
end
def test_readonly_attributes
assert_equal Set.new([ "title" , "comments_count" ]), ReadonlyTitlePost.readonly_attributes
assert_equal Set.new([ "title", "comments_count" ]), ReadonlyTitlePost.readonly_attributes
post = ReadonlyTitlePost.create(title: "cannot change this", body: "changeable")
post.reload

View File

@ -1238,7 +1238,7 @@ class FinderTest < ActiveRecord::TestCase
test "find_by with associations" do
assert_equal authors(:david), Post.find_by(author: authors(:david)).author
assert_equal authors(:mary) , Post.find_by(author: authors(:mary)).author
assert_equal authors(:mary), Post.find_by(author: authors(:mary)).author
end
test "find_by doesn't have implicit ordering" do

View File

@ -90,7 +90,7 @@ class TimestampTest < ActiveRecord::TestCase
@developer.touch(:created_at)
end
assert !@developer.created_at_changed? , "created_at should not be changed"
assert !@developer.created_at_changed?, "created_at should not be changed"
assert !@developer.changed?, "record should not be changed"
assert_not_equal previously_created_at, @developer.created_at
assert_not_equal @previously_updated_at, @developer.updated_at

View File

@ -77,7 +77,7 @@ module CallbacksTest
skip_callback :save, :after, :after_save_method, unless: :yes
skip_callback :save, :after, :after_save_method, if: :no
skip_callback :save, :before, :before_save_method, unless: :no
skip_callback :save, :before, CallbackClass , if: :yes
skip_callback :save, :before, CallbackClass, if: :yes
def yes; true; end
def no; false; end
end

View File

@ -116,7 +116,7 @@ class SplitTest < ActiveSupport::TestCase
def test_split_with_block
a = (1..10).to_a
assert_equal [[1, 2], [4, 5], [7, 8], [10]], a.split { |i| i % 3 == 0 }
assert_equal [1, 2, 3, 4, 5, 6, 7, 8, 9 , 10], a
assert_equal [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], a
end
def test_split_with_edge_values

View File

@ -160,7 +160,7 @@ class DurationTest < ActiveSupport::TestCase
end
def test_time_plus_duration_returns_same_time_datatype
twz = ActiveSupport::TimeWithZone.new(nil, ActiveSupport::TimeZone["Moscow"] , Time.utc(2016, 4, 28, 00, 45))
twz = ActiveSupport::TimeWithZone.new(nil, ActiveSupport::TimeZone["Moscow"], Time.utc(2016, 4, 28, 00, 45))
now = Time.now.utc
%w( second minute hour day week month year ).each do |unit|
assert_equal((now + 1.send(unit)).class, Time, "Time + 1.#{unit} must be Time")

View File

@ -106,26 +106,26 @@ class RangeTest < ActiveSupport::TestCase
end
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))
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 {}
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))
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) {}
end
end
def test_include_on_time_with_zone
twz = ActiveSupport::TimeWithZone.new(nil, ActiveSupport::TimeZone["Eastern Time (US & Canada)"] , Time.utc(2006, 11, 28, 10, 30))
twz = ActiveSupport::TimeWithZone.new(nil, ActiveSupport::TimeZone["Eastern Time (US & Canada)"], Time.utc(2006, 11, 28, 10, 30))
assert ((twz - 1.hour)..twz).include?(twz)
end
def test_case_equals_on_time_with_zone
twz = ActiveSupport::TimeWithZone.new(nil, ActiveSupport::TimeZone["Eastern Time (US & Canada)"] , Time.utc(2006, 11, 28, 10, 30))
twz = ActiveSupport::TimeWithZone.new(nil, ActiveSupport::TimeZone["Eastern Time (US & Canada)"], Time.utc(2006, 11, 28, 10, 30))
assert ((twz - 1.hour)..twz) === twz
end

View File

@ -307,13 +307,13 @@ class TimeWithZoneTest < ActiveSupport::TestCase
end
def test_plus_with_integer
assert_equal Time.utc(1999, 12, 31, 19, 0 , 5), (@twz + 5).time
assert_equal Time.utc(1999, 12, 31, 19, 0, 5), (@twz + 5).time
end
def test_plus_with_integer_when_self_wraps_datetime
datetime = DateTime.civil(2000, 1, 1, 0)
twz = ActiveSupport::TimeWithZone.new(datetime, @time_zone)
assert_equal DateTime.civil(1999, 12, 31, 19, 0 , 5), (twz + 5).time
assert_equal DateTime.civil(1999, 12, 31, 19, 0, 5), (twz + 5).time
end
def test_plus_when_crossing_time_class_limit
@ -322,21 +322,21 @@ class TimeWithZoneTest < ActiveSupport::TestCase
end
def test_plus_with_duration
assert_equal Time.utc(2000, 1, 5, 19, 0 , 0), (@twz + 5.days).time
assert_equal Time.utc(2000, 1, 5, 19, 0, 0), (@twz + 5.days).time
end
def test_minus_with_integer
assert_equal Time.utc(1999, 12, 31, 18, 59 , 55), (@twz - 5).time
assert_equal Time.utc(1999, 12, 31, 18, 59, 55), (@twz - 5).time
end
def test_minus_with_integer_when_self_wraps_datetime
datetime = DateTime.civil(2000, 1, 1, 0)
twz = ActiveSupport::TimeWithZone.new(datetime, @time_zone)
assert_equal DateTime.civil(1999, 12, 31, 18, 59 , 55), (twz - 5).time
assert_equal DateTime.civil(1999, 12, 31, 18, 59, 55), (twz - 5).time
end
def test_minus_with_duration
assert_equal Time.utc(1999, 12, 26, 19, 0 , 0), (@twz - 5.days).time
assert_equal Time.utc(1999, 12, 26, 19, 0, 0), (@twz - 5.days).time
end
def test_minus_with_time
@ -507,7 +507,7 @@ class TimeWithZoneTest < ActiveSupport::TestCase
def test_method_missing_with_time_return_value
assert_instance_of ActiveSupport::TimeWithZone, @twz.months_since(1)
assert_equal Time.utc(2000, 1, 31, 19, 0 , 0), @twz.months_since(1).time
assert_equal Time.utc(2000, 1, 31, 19, 0, 0), @twz.months_since(1).time
end
def test_marshal_dump_and_load

View File

@ -187,7 +187,7 @@ class TestJSONEncoding < ActiveSupport::TestCase
def test_array_should_pass_encoding_options_to_children_in_as_json
people = [
{ name: "John", address: { city: "London", country: "UK" } },
{ name: "Jean", address: { city: "Paris" , country: "France" } }
{ name: "Jean", address: { city: "Paris", country: "France" } }
]
json = people.as_json only: [:address, :city]
expected = [
@ -201,7 +201,7 @@ class TestJSONEncoding < ActiveSupport::TestCase
def test_array_should_pass_encoding_options_to_children_in_to_json
people = [
{ name: "John", address: { city: "London", country: "UK" } },
{ name: "Jean", address: { city: "Paris" , country: "France" } }
{ name: "Jean", address: { city: "Paris", country: "France" } }
]
json = people.to_json only: [:address, :city]
@ -213,7 +213,7 @@ class TestJSONEncoding < ActiveSupport::TestCase
def initialize
@people = [
{ name: "John", address: { city: "London", country: "UK" } },
{ name: "Jean", address: { city: "Paris" , country: "France" } }
{ name: "Jean", address: { city: "Paris", country: "France" } }
]
end
def each(*, &blk)

View File

@ -35,7 +35,7 @@ module ActiveSupport
thousand: "t",
million: "m",
billion: "b",
trillion: "t" ,
trillion: "t",
quadrillion: "q"
}
}

View File

@ -980,14 +980,14 @@ YAML
boot_rails
app_generators = Rails.application.config.generators.options[:rails]
assert_equal :mongoid , app_generators[:orm]
assert_equal :liquid , app_generators[:template_engine]
assert_equal :mongoid, app_generators[:orm]
assert_equal :liquid, app_generators[:template_engine]
assert_equal :test_unit, app_generators[:test_framework]
generators = Bukkits::Engine.config.generators.options[:rails]
assert_equal :data_mapper, generators[:orm]
assert_equal :haml , generators[:template_engine]
assert_equal :rspec , generators[:test_framework]
assert_equal :haml, generators[:template_engine]
assert_equal :rspec, generators[:test_framework]
end
test "engine should get default generators with ability to overwrite them" do
@ -1003,10 +1003,10 @@ YAML
generators = Bukkits::Engine.config.generators.options[:rails]
assert_equal :active_record, generators[:orm]
assert_equal :rspec , generators[:test_framework]
assert_equal :rspec, generators[:test_framework]
app_generators = Rails.application.config.generators.options[:rails]
assert_equal :test_unit , app_generators[:test_framework]
assert_equal :test_unit, app_generators[:test_framework]
end
test "do not create table_name_prefix method if it already exists" do