aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAkira Matsuda <ronnie@dio.jp>2012-06-05 04:59:34 +0900
committerAkira Matsuda <ronnie@dio.jp>2012-06-06 19:33:38 +0900
commitedee2c7b3bec824aa653b09d63aff06ab5542e06 (patch)
treee4cb8cbca333c14ce9ad2886e5c52a3791edb300
parent9fb70033d36f467d4eb858e9fac1282a0394876a (diff)
downloadrails-edee2c7b3bec824aa653b09d63aff06ab5542e06.tar.gz
rails-edee2c7b3bec824aa653b09d63aff06ab5542e06.tar.bz2
rails-edee2c7b3bec824aa653b09d63aff06ab5542e06.zip
stop `to_s`ing method names
Module#methods are Symbols in Ruby >= 1.9
-rw-r--r--actionpack/test/controller/helper_test.rb32
-rw-r--r--activerecord/test/cases/finder_respond_to_test.rb3
-rw-r--r--activerecord/test/cases/finder_test.rb2
-rw-r--r--activesupport/lib/active_support/core_ext/date_time/conversions.rb2
-rw-r--r--activesupport/lib/active_support/log_subscriber.rb2
-rw-r--r--railties/test/railties/engine_test.rb4
6 files changed, 21 insertions, 24 deletions
diff --git a/actionpack/test/controller/helper_test.rb b/actionpack/test/controller/helper_test.rb
index deb234b04f..248c81193e 100644
--- a/actionpack/test/controller/helper_test.rb
+++ b/actionpack/test/controller/helper_test.rb
@@ -109,13 +109,13 @@ class HelperTest < ActiveSupport::TestCase
def test_helper_method
assert_nothing_raised { @controller_class.helper_method :delegate_method }
- assert master_helper_methods.include?('delegate_method')
+ assert master_helper_methods.include?(:delegate_method)
end
def test_helper_attr
assert_nothing_raised { @controller_class.helper_attr :delegate_attr }
- assert master_helper_methods.include?('delegate_attr')
- assert master_helper_methods.include?('delegate_attr=')
+ assert master_helper_methods.include?(:delegate_attr)
+ assert master_helper_methods.include?(:delegate_attr=)
end
def call_controller(klass, action)
@@ -160,16 +160,16 @@ class HelperTest < ActiveSupport::TestCase
end
def test_all_helpers
- methods = AllHelpersController._helpers.instance_methods.map {|m| m.to_s}
+ methods = AllHelpersController._helpers.instance_methods
# abc_helper.rb
- assert methods.include?('bare_a')
+ assert methods.include?(:bare_a)
# fun/games_helper.rb
- assert methods.include?('stratego')
+ assert methods.include?(:stratego)
# fun/pdf_helper.rb
- assert methods.include?('foobar')
+ assert methods.include?(:foobar)
end
def test_all_helpers_with_alternate_helper_dir
@@ -180,35 +180,35 @@ class HelperTest < ActiveSupport::TestCase
@controller_class.helper :all
# helpers/abc_helper.rb should not be included
- assert !master_helper_methods.include?('bare_a')
+ assert !master_helper_methods.include?(:bare_a)
# alternate_helpers/foo_helper.rb
- assert master_helper_methods.include?('baz')
+ assert master_helper_methods.include?(:baz)
end
def test_helper_proxy
- methods = AllHelpersController.helpers.methods.map(&:to_s)
+ methods = AllHelpersController.helpers.methods
# Action View
- assert methods.include?('pluralize')
+ assert methods.include?(:pluralize)
# abc_helper.rb
- assert methods.include?('bare_a')
+ assert methods.include?(:bare_a)
# fun/games_helper.rb
- assert methods.include?('stratego')
+ assert methods.include?(:stratego)
# fun/pdf_helper.rb
- assert methods.include?('foobar')
+ assert methods.include?(:foobar)
end
private
def expected_helper_methods
- TestHelper.instance_methods.map {|m| m.to_s }
+ TestHelper.instance_methods
end
def master_helper_methods
- @controller_class._helpers.instance_methods.map {|m| m.to_s }
+ @controller_class._helpers.instance_methods
end
def missing_methods
diff --git a/activerecord/test/cases/finder_respond_to_test.rb b/activerecord/test/cases/finder_respond_to_test.rb
index 810c1500cc..eedbaac3bd 100644
--- a/activerecord/test/cases/finder_respond_to_test.rb
+++ b/activerecord/test/cases/finder_respond_to_test.rb
@@ -80,7 +80,6 @@ class FinderRespondToTest < ActiveRecord::TestCase
private
def ensure_topic_method_is_not_cached(method_id)
- class << Topic; self; end.send(:remove_method, method_id) if Topic.public_methods.any? { |m| m.to_s == method_id.to_s }
+ class << Topic; self; end.send(:remove_method, method_id) if Topic.public_methods.include? method_id
end
-
end
diff --git a/activerecord/test/cases/finder_test.rb b/activerecord/test/cases/finder_test.rb
index f7ecab28ce..8c16972c12 100644
--- a/activerecord/test/cases/finder_test.rb
+++ b/activerecord/test/cases/finder_test.rb
@@ -629,7 +629,7 @@ class FinderTest < ActiveRecord::TestCase
def test_dynamic_finder_on_one_attribute_with_conditions_returns_same_results_after_caching
# ensure this test can run independently of order
- class << Account; self; end.send(:remove_method, :find_by_credit_limit) if Account.public_methods.any? { |m| m.to_s == 'find_by_credit_limit' }
+ class << Account; self; end.send(:remove_method, :find_by_credit_limit) if Account.public_methods.include?(:find_by_credit_limit)
a = Account.where('firm_id = ?', 6).find_by_credit_limit(50)
assert_equal a, Account.where('firm_id = ?', 6).find_by_credit_limit(50) # find_by_credit_limit has been cached
end
diff --git a/activesupport/lib/active_support/core_ext/date_time/conversions.rb b/activesupport/lib/active_support/core_ext/date_time/conversions.rb
index 19925198c0..13d659f52a 100644
--- a/activesupport/lib/active_support/core_ext/date_time/conversions.rb
+++ b/activesupport/lib/active_support/core_ext/date_time/conversions.rb
@@ -39,7 +39,7 @@ class DateTime
to_default_s
end
end
- alias_method :to_default_s, :to_s unless (instance_methods(false) & [:to_s, 'to_s']).empty?
+ alias_method :to_default_s, :to_s if instance_methods(false).include?(:to_s)
alias_method :to_s, :to_formatted_s
#
diff --git a/activesupport/lib/active_support/log_subscriber.rb b/activesupport/lib/active_support/log_subscriber.rb
index d2a6e1bd82..125e7b0e75 100644
--- a/activesupport/lib/active_support/log_subscriber.rb
+++ b/activesupport/lib/active_support/log_subscriber.rb
@@ -61,7 +61,7 @@ module ActiveSupport
@@flushable_loggers = nil
log_subscriber.public_methods(false).each do |event|
- next if 'call' == event.to_s
+ next if :call == event
notifier.subscribe("#{event}.#{namespace}", log_subscriber)
end
diff --git a/railties/test/railties/engine_test.rb b/railties/test/railties/engine_test.rb
index 4437e2c8af..52c7fae6c6 100644
--- a/railties/test/railties/engine_test.rb
+++ b/railties/test/railties/engine_test.rb
@@ -1009,9 +1009,7 @@ YAML
boot_rails
- methods = Bukkits::Engine.helpers.public_instance_methods.collect(&:to_s).sort
- expected = ["bar", "baz"]
- assert_equal expected, methods
+ assert_equal [:bar, :baz], Bukkits::Engine.helpers.public_instance_methods.sort
end
test "setting priority for engines with config.railties_order" do