Skip to content

Commit

Permalink
Enable Layout/LeadingCommentSpace to not allow cosmetic changes in …
Browse files Browse the repository at this point in the history
…the future

Follow up of #31432.
  • Loading branch information
kamipo committed Dec 14, 2017
1 parent 65e994c commit 245c1da
Show file tree
Hide file tree
Showing 32 changed files with 83 additions and 88 deletions.
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ Layout/IndentationConsistency:
Layout/IndentationWidth:
Enabled: true

Layout/LeadingCommentSpace:
Enabled: true

Layout/SpaceAfterColon:
Enabled: true

Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ group :job do
gem "sneakers", require: false
gem "que", require: false
gem "backburner", require: false
#TODO: add qu after it support Rails 5.1
# TODO: add qu after it support Rails 5.1
# gem 'qu-rails', github: "bkeepers/qu", branch: "master", require: false
# gem "qu-redis", require: false
gem "delayed_job_active_record", require: false
Expand Down
20 changes: 10 additions & 10 deletions actionpack/lib/action_dispatch/journey/nfa/dot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ def to_dot
" #{from} -> #{to} [label=\"#{sym || 'ε'}\"];"
}

#memo_nodes = memos.values.flatten.map { |n|
# label = n
# if Journey::Route === n
# label = "#{n.verb.source} #{n.path.spec}"
# end
# " #{n.object_id} [label=\"#{label}\", shape=box];"
#}
#memo_edges = memos.flat_map { |k, memos|
# (memos || []).map { |v| " #{k} -> #{v.object_id};" }
#}.uniq
# memo_nodes = memos.values.flatten.map { |n|
# label = n
# if Journey::Route === n
# label = "#{n.verb.source} #{n.path.spec}"
# end
# " #{n.object_id} [label=\"#{label}\", shape=box];"
# }
# memo_edges = memos.flat_map { |k, memos|
# (memos || []).map { |v| " #{k} -> #{v.object_id};" }
# }.uniq

<<-eodot
digraph nfa {
Expand Down
1 change: 0 additions & 1 deletion actionpack/test/controller/url_for_integration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class URLForIntegrationTest < ActiveSupport::TestCase
as: "blog"

resources :people
#match 'legacy/people' => "people#index", :legacy => "true"

get "symbols", controller: :symbols, action: :show, name: :as_symbol
get "id_default(/:id)" => "foo#id_default", :id => 1
Expand Down
2 changes: 1 addition & 1 deletion actionpack/test/controller/url_rewriter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def rewrite(routes, options)

def setup
@params = {}
@rewriter = Rewriter.new(@request) #.new(@request, @params)
@rewriter = Rewriter.new(@request)
@routes = ActionDispatch::Routing::RouteSet.new.tap do |r|
r.draw do
ActiveSupport::Deprecation.silence do
Expand Down
2 changes: 1 addition & 1 deletion actionpack/test/dispatch/routing_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4225,7 +4225,7 @@ class TestGlobRoutingMapper < ActionDispatch::IntegrationTest
end
end

#include Routes.url_helpers
# include Routes.url_helpers
APP = build_app Routes
def app; APP end

Expand Down
2 changes: 1 addition & 1 deletion actionpack/test/journey/router_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_dashes
def test_unicode
get "/ほげ", to: "foo#bar"

#match the escaped version of /ほげ
# match the escaped version of /ほげ
env = rails_env "PATH_INFO" => "/%E3%81%BB%E3%81%92"
called = false
router.recognize(env) do |r, params|
Expand Down
2 changes: 1 addition & 1 deletion actionview/test/actionpack/controller/render_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class ApplicationController < ActionController::Base
end

module Quiz
#Models
# Models
Question = Struct.new(:name, :id) do
extend ActiveModel::Naming
include ActiveModel::Conversion
Expand Down
2 changes: 1 addition & 1 deletion actionview/test/active_record_unit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def setup
end
rescue Exception => e # errors from ActiveRecord setup
$stderr.puts "\nSkipping ActiveRecord assertion tests: #{e}"
#$stderr.puts " #{e.backtrace.join("\n ")}\n"
# $stderr.puts " #{e.backtrace.join("\n ")}\n"
self.able_to_connect = false
end

Expand Down
2 changes: 1 addition & 1 deletion actionview/test/template/number_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def test_number_to_human_escape_units
assert_equal "1.23 &lt;b&gt;km3&lt;/b&gt;", number_to_human(1_234_567_000_000, units: volume)
assert_equal "1.23 &lt;b&gt;Pl&lt;/b&gt;", number_to_human(1_234_567_000_000_000, units: volume)

#Including fractionals
# Including fractionals
distance = { mili: "<b>mm</b>", centi: "<b>cm</b>", deci: "<b>dm</b>", unit: "<b>m</b>",
ten: "<b>dam</b>", hundred: "<b>hm</b>", thousand: "<b>km</b>",
micro: "<b>um</b>", nano: "<b>nm</b>", pico: "<b>pm</b>", femto: "<b>fm</b>" }
Expand Down
2 changes: 1 addition & 1 deletion activejob/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require "rake/testtask"

#TODO: add qu back to the list after it support Rails 5.1
# TODO: add qu back to the list after it support Rails 5.1
ACTIVEJOB_ADAPTERS = %w(async inline delayed_job que queue_classic resque sidekiq sneakers sucker_punch backburner test)
ACTIVEJOB_ADAPTERS.delete("queue_classic") if defined?(JRUBY_VERSION)

Expand Down
2 changes: 1 addition & 1 deletion activejob/test/support/delayed_job/delayed/backend/test.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

#copied from https://github.com/collectiveidea/delayed_job/blob/master/spec/delayed/backend/test.rb
# copied from https://github.com/collectiveidea/delayed_job/blob/master/spec/delayed/backend/test.rb
require "ostruct"

# An in-memory backend suitable only for testing. Tries to behave as if it were an ORM.
Expand Down
2 changes: 1 addition & 1 deletion activerecord/test/cases/associations/eager_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1073,7 +1073,7 @@ def messages_for(name)
end

def test_load_with_sti_sharing_association
assert_queries(2) do #should not do 1 query per subclass
assert_queries(2) do # should not do 1 query per subclass
Comment.includes(:post).to_a
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,15 @@ def test_has_one_through_polymorphic
end

def test_has_one_through_eager_loading
members = assert_queries(3) do #base table, through table, clubs table
members = assert_queries(3) do # base table, through table, clubs table
Member.all.merge!(includes: :club, where: ["name = ?", "Groucho Marx"]).to_a
end
assert_equal 1, members.size
assert_not_nil assert_no_queries { members[0].club }
end

def test_has_one_through_eager_loading_through_polymorphic
members = assert_queries(3) do #base table, through table, clubs table
members = assert_queries(3) do # base table, through table, clubs table
Member.all.merge!(includes: :sponsor_club, where: ["name = ?", "Groucho Marx"]).to_a
end
assert_equal 1, members.size
Expand Down Expand Up @@ -139,15 +139,15 @@ def test_eager_has_one_through_polymorphic_with_source_type

def test_has_one_through_nonpreload_eagerloading
members = assert_queries(1) do
Member.all.merge!(includes: :club, where: ["members.name = ?", "Groucho Marx"], order: "clubs.name").to_a #force fallback
Member.all.merge!(includes: :club, where: ["members.name = ?", "Groucho Marx"], order: "clubs.name").to_a # force fallback
end
assert_equal 1, members.size
assert_not_nil assert_no_queries { members[0].club }
end

def test_has_one_through_nonpreload_eager_loading_through_polymorphic
members = assert_queries(1) do
Member.all.merge!(includes: :sponsor_club, where: ["members.name = ?", "Groucho Marx"], order: "clubs.name").to_a #force fallback
Member.all.merge!(includes: :sponsor_club, where: ["members.name = ?", "Groucho Marx"], order: "clubs.name").to_a # force fallback
end
assert_equal 1, members.size
assert_not_nil assert_no_queries { members[0].sponsor_club }
Expand All @@ -156,7 +156,7 @@ def test_has_one_through_nonpreload_eager_loading_through_polymorphic
def test_has_one_through_nonpreload_eager_loading_through_polymorphic_with_more_than_one_through_record
Sponsor.new(sponsor_club: clubs(:crazy_club), sponsorable: members(:groucho)).save!
members = assert_queries(1) do
Member.all.merge!(includes: :sponsor_club, where: ["members.name = ?", "Groucho Marx"], order: "clubs.name DESC").to_a #force fallback
Member.all.merge!(includes: :sponsor_club, where: ["members.name = ?", "Groucho Marx"], order: "clubs.name DESC").to_a # force fallback
end
assert_equal 1, members.size
assert_not_nil assert_no_queries { members[0].sponsor_club }
Expand Down
2 changes: 1 addition & 1 deletion activerecord/test/cases/associations/join_model_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ def test_associating_unsaved_records_with_has_many_through
new_tag = Tag.new(name: "new")

saved_post.tags << new_tag
assert new_tag.persisted? #consistent with habtm!
assert new_tag.persisted? # consistent with habtm!
assert saved_post.persisted?
assert_includes saved_post.tags, new_tag

Expand Down
6 changes: 3 additions & 3 deletions activerecord/test/cases/dup_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ def test_dup_with_changes

topic.attributes = dbtopic.attributes.except("id")

#duped has no timestamp values
# duped has no timestamp values
duped = dbtopic.dup

#clear topic timestamp values
# clear topic timestamp values
topic.send(:clear_timestamp_attributes)

assert_equal topic.changes, duped.changes
Expand Down Expand Up @@ -100,7 +100,7 @@ def test_dup_timestamps_are_cleared
# temporary change to the topic object
topic.updated_at -= 3.days

#dup should not preserve the timestamps if present
# dup should not preserve the timestamps if present
new_topic = topic.dup
assert_nil new_topic.updated_at
assert_nil new_topic.created_at
Expand Down
2 changes: 1 addition & 1 deletion activerecord/test/cases/finder_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ def test_second_to_last
assert_nil Topic.offset(4).second_to_last
assert_nil Topic.offset(5).second_to_last

#test with limit
# test with limit
assert_nil Topic.limit(1).second
assert_nil Topic.limit(1).second_to_last
end
Expand Down
2 changes: 1 addition & 1 deletion activerecord/test/cases/fixtures_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def test_empty_yaml_fixture_with_a_comment_in_it
def test_nonexistent_fixture_file
nonexistent_fixture_path = FIXTURES_ROOT + "/imnothere"

#sanity check to make sure that this file never exists
# sanity check to make sure that this file never exists
assert Dir[nonexistent_fixture_path + "*"].empty?

assert_raise(Errno::ENOENT) do
Expand Down
3 changes: 0 additions & 3 deletions activerecord/test/cases/statement_cache_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ def setup
@connection = ActiveRecord::Base.connection
end

#Cache v 1.1 tests
def test_statement_cache
Book.create(name: "my book")
Book.create(name: "my other book")
Expand Down Expand Up @@ -51,8 +50,6 @@ def test_find_or_create_by
assert_equal("my other book", b.name)
end

#End

def test_statement_cache_with_simple_statement
cache = ActiveRecord::StatementCache.create(Book.connection) do |params|
Book.where(name: "my book").where("author_id > 3")
Expand Down
4 changes: 0 additions & 4 deletions activestorage/test/dummy/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
require "action_view/railtie"
require "sprockets/railtie"
require "active_storage/engine"
#require "action_mailer/railtie"
#require "rails/test_unit/railtie"
#require "action_cable/engine"


Bundler.require(*Rails.groups)

Expand Down
2 changes: 1 addition & 1 deletion activesupport/test/cache/stores/redis_cache_store_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class StoreTest < ActiveSupport::TestCase
@namespace = "namespace"

@cache = ActiveSupport::Cache::RedisCacheStore.new(timeout: 0.1, namespace: @namespace, expires_in: 60)
#@cache.logger = Logger.new($stdout) # For test debugging
# @cache.logger = Logger.new($stdout) # For test debugging

# For LocalCacheBehavior tests
@peek = ActiveSupport::Cache::RedisCacheStore.new(timeout: 0.1, namespace: @namespace)
Expand Down
28 changes: 14 additions & 14 deletions activesupport/test/core_ext/date_and_time_behavior.rb
Original file line number Diff line number Diff line change
Expand Up @@ -297,24 +297,24 @@ def test_days_to_week_start_with_default_set

def test_beginning_of_week
assert_equal date_time_init(2005, 1, 31, 0, 0, 0), date_time_init(2005, 2, 4, 10, 10, 10).beginning_of_week
assert_equal date_time_init(2005, 11, 28, 0, 0, 0), date_time_init(2005, 11, 28, 0, 0, 0).beginning_of_week #monday
assert_equal date_time_init(2005, 11, 28, 0, 0, 0), date_time_init(2005, 11, 29, 0, 0, 0).beginning_of_week #tuesday
assert_equal date_time_init(2005, 11, 28, 0, 0, 0), date_time_init(2005, 11, 30, 0, 0, 0).beginning_of_week #wednesday
assert_equal date_time_init(2005, 11, 28, 0, 0, 0), date_time_init(2005, 12, 01, 0, 0, 0).beginning_of_week #thursday
assert_equal date_time_init(2005, 11, 28, 0, 0, 0), date_time_init(2005, 12, 02, 0, 0, 0).beginning_of_week #friday
assert_equal date_time_init(2005, 11, 28, 0, 0, 0), date_time_init(2005, 12, 03, 0, 0, 0).beginning_of_week #saturday
assert_equal date_time_init(2005, 11, 28, 0, 0, 0), date_time_init(2005, 12, 04, 0, 0, 0).beginning_of_week #sunday
assert_equal date_time_init(2005, 11, 28, 0, 0, 0), date_time_init(2005, 11, 28, 0, 0, 0).beginning_of_week # monday
assert_equal date_time_init(2005, 11, 28, 0, 0, 0), date_time_init(2005, 11, 29, 0, 0, 0).beginning_of_week # tuesday
assert_equal date_time_init(2005, 11, 28, 0, 0, 0), date_time_init(2005, 11, 30, 0, 0, 0).beginning_of_week # wednesday
assert_equal date_time_init(2005, 11, 28, 0, 0, 0), date_time_init(2005, 12, 01, 0, 0, 0).beginning_of_week # thursday
assert_equal date_time_init(2005, 11, 28, 0, 0, 0), date_time_init(2005, 12, 02, 0, 0, 0).beginning_of_week # friday
assert_equal date_time_init(2005, 11, 28, 0, 0, 0), date_time_init(2005, 12, 03, 0, 0, 0).beginning_of_week # saturday
assert_equal date_time_init(2005, 11, 28, 0, 0, 0), date_time_init(2005, 12, 04, 0, 0, 0).beginning_of_week # sunday
end

def test_end_of_week
assert_equal date_time_init(2008, 1, 6, 23, 59, 59, Rational(999999999, 1000)), date_time_init(2007, 12, 31, 10, 10, 10).end_of_week
assert_equal date_time_init(2007, 9, 2, 23, 59, 59, Rational(999999999, 1000)), date_time_init(2007, 8, 27, 0, 0, 0).end_of_week #monday
assert_equal date_time_init(2007, 9, 2, 23, 59, 59, Rational(999999999, 1000)), date_time_init(2007, 8, 28, 0, 0, 0).end_of_week #tuesday
assert_equal date_time_init(2007, 9, 2, 23, 59, 59, Rational(999999999, 1000)), date_time_init(2007, 8, 29, 0, 0, 0).end_of_week #wednesday
assert_equal date_time_init(2007, 9, 2, 23, 59, 59, Rational(999999999, 1000)), date_time_init(2007, 8, 30, 0, 0, 0).end_of_week #thursday
assert_equal date_time_init(2007, 9, 2, 23, 59, 59, Rational(999999999, 1000)), date_time_init(2007, 8, 31, 0, 0, 0).end_of_week #friday
assert_equal date_time_init(2007, 9, 2, 23, 59, 59, Rational(999999999, 1000)), date_time_init(2007, 9, 01, 0, 0, 0).end_of_week #saturday
assert_equal date_time_init(2007, 9, 2, 23, 59, 59, Rational(999999999, 1000)), date_time_init(2007, 9, 02, 0, 0, 0).end_of_week #sunday
assert_equal date_time_init(2007, 9, 2, 23, 59, 59, Rational(999999999, 1000)), date_time_init(2007, 8, 27, 0, 0, 0).end_of_week # monday
assert_equal date_time_init(2007, 9, 2, 23, 59, 59, Rational(999999999, 1000)), date_time_init(2007, 8, 28, 0, 0, 0).end_of_week # tuesday
assert_equal date_time_init(2007, 9, 2, 23, 59, 59, Rational(999999999, 1000)), date_time_init(2007, 8, 29, 0, 0, 0).end_of_week # wednesday
assert_equal date_time_init(2007, 9, 2, 23, 59, 59, Rational(999999999, 1000)), date_time_init(2007, 8, 30, 0, 0, 0).end_of_week # thursday
assert_equal date_time_init(2007, 9, 2, 23, 59, 59, Rational(999999999, 1000)), date_time_init(2007, 8, 31, 0, 0, 0).end_of_week # friday
assert_equal date_time_init(2007, 9, 2, 23, 59, 59, Rational(999999999, 1000)), date_time_init(2007, 9, 01, 0, 0, 0).end_of_week # saturday
assert_equal date_time_init(2007, 9, 2, 23, 59, 59, Rational(999999999, 1000)), date_time_init(2007, 9, 02, 0, 0, 0).end_of_week # sunday
end

def test_end_of_month
Expand Down
6 changes: 3 additions & 3 deletions activesupport/test/core_ext/date_ext_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ def test_sunday
end

def test_beginning_of_week_in_calendar_reform
assert_equal Date.new(1582, 10, 1), Date.new(1582, 10, 15).beginning_of_week #friday
assert_equal Date.new(1582, 10, 1), Date.new(1582, 10, 15).beginning_of_week # friday
end

def test_end_of_week_in_calendar_reform
assert_equal Date.new(1582, 10, 17), Date.new(1582, 10, 4).end_of_week #thursday
assert_equal Date.new(1582, 10, 17), Date.new(1582, 10, 4).end_of_week # thursday
end

def test_end_of_year
Expand Down Expand Up @@ -144,7 +144,7 @@ def test_advance
assert_equal Date.new(2012, 9, 28), Date.new(2005, 2, 28).advance(years: 7, months: 7)
assert_equal Date.new(2013, 10, 3), Date.new(2005, 2, 28).advance(years: 7, months: 19, days: 5)
assert_equal Date.new(2013, 10, 17), Date.new(2005, 2, 28).advance(years: 7, months: 19, weeks: 2, days: 5)
assert_equal Date.new(2005, 2, 28), Date.new(2004, 2, 29).advance(years: 1) #leap day plus one year
assert_equal Date.new(2005, 2, 28), Date.new(2004, 2, 29).advance(years: 1) # leap day plus one year
end

def test_advance_does_first_years_and_then_days
Expand Down
2 changes: 1 addition & 1 deletion activesupport/test/core_ext/date_time_ext_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def test_advance
assert_equal DateTime.civil(2013, 10, 3, 15, 15, 10), DateTime.civil(2005, 2, 28, 15, 15, 10).advance(years: 7, months: 19, days: 5)
assert_equal DateTime.civil(2013, 10, 17, 15, 15, 10), DateTime.civil(2005, 2, 28, 15, 15, 10).advance(years: 7, months: 19, weeks: 2, days: 5)
assert_equal DateTime.civil(2001, 12, 27, 15, 15, 10), DateTime.civil(2005, 2, 28, 15, 15, 10).advance(years: -3, months: -2, days: -1)
assert_equal DateTime.civil(2005, 2, 28, 15, 15, 10), DateTime.civil(2004, 2, 29, 15, 15, 10).advance(years: 1) #leap day plus one year
assert_equal DateTime.civil(2005, 2, 28, 15, 15, 10), DateTime.civil(2004, 2, 29, 15, 15, 10).advance(years: 1) # leap day plus one year
assert_equal DateTime.civil(2005, 2, 28, 20, 15, 10), DateTime.civil(2005, 2, 28, 15, 15, 10).advance(hours: 5)
assert_equal DateTime.civil(2005, 2, 28, 15, 22, 10), DateTime.civil(2005, 2, 28, 15, 15, 10).advance(minutes: 7)
assert_equal DateTime.civil(2005, 2, 28, 15, 15, 19), DateTime.civil(2005, 2, 28, 15, 15, 10).advance(seconds: 9)
Expand Down
12 changes: 6 additions & 6 deletions activesupport/test/core_ext/numeric_ext_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ def test_to_s__human_size_with_options_hash
assert_equal "40 KB", 41100.to_s(:human_size, precision: 2)
assert_equal "1.0 KB", kilobytes(1.0123).to_s(:human_size, precision: 2, strip_insignificant_zeros: false)
assert_equal "1.012 KB", kilobytes(1.0123).to_s(:human_size, precision: 3, significant: false)
assert_equal "1 KB", kilobytes(1.0123).to_s(:human_size, precision: 0, significant: true) #ignores significant it precision is 0
assert_equal "1 KB", kilobytes(1.0123).to_s(:human_size, precision: 0, significant: true) # ignores significant it precision is 0
end

def test_to_s__human_size_with_custom_delimiter_and_separator
Expand Down Expand Up @@ -330,17 +330,17 @@ def test_number_to_human
assert_equal "489.0 Thousand", 489000.to_s(:human, precision: 4, strip_insignificant_zeros: false)
assert_equal "1.2346 Million", 1234567.to_s(:human, precision: 4, significant: false)
assert_equal "1,2 Million", 1234567.to_s(:human, precision: 1, significant: false, separator: ",")
assert_equal "1 Million", 1234567.to_s(:human, precision: 0, significant: true, separator: ",") #significant forced to false
assert_equal "1 Million", 1234567.to_s(:human, precision: 0, significant: true, separator: ",") # significant forced to false
end

def test_number_to_human_with_custom_units
#Only integers
# Only integers
volume = { unit: "ml", thousand: "lt", million: "m3" }
assert_equal "123 lt", 123456.to_s(:human, units: volume)
assert_equal "12 ml", 12.to_s(:human, units: volume)
assert_equal "1.23 m3", 1234567.to_s(:human, units: volume)

#Including fractionals
# Including fractionals
distance = { mili: "mm", centi: "cm", deci: "dm", unit: "m", ten: "dam", hundred: "hm", thousand: "km" }
assert_equal "1.23 mm", 0.00123.to_s(:human, units: distance)
assert_equal "1.23 cm", 0.0123.to_s(:human, units: distance)
Expand All @@ -353,14 +353,14 @@ def test_number_to_human_with_custom_units
assert_equal "1.23 km", 1230.to_s(:human, units: distance)
assert_equal "12.3 km", 12300.to_s(:human, units: distance)

#The quantifiers don't need to be a continuous sequence
# The quantifiers don't need to be a continuous sequence
gangster = { hundred: "hundred bucks", million: "thousand quids" }
assert_equal "1 hundred bucks", 100.to_s(:human, units: gangster)
assert_equal "25 hundred bucks", 2500.to_s(:human, units: gangster)
assert_equal "25 thousand quids", 25000000.to_s(:human, units: gangster)
assert_equal "12300 thousand quids", 12345000000.to_s(:human, units: gangster)

#Spaces are stripped from the resulting string
# Spaces are stripped from the resulting string
assert_equal "4", 4.to_s(:human, units: { unit: "", ten: "tens " })
assert_equal "4.5 tens", 45.to_s(:human, units: { unit: "", ten: " tens " })
end
Expand Down
Loading

0 comments on commit 245c1da

Please sign in to comment.