mirror of
https://github.com/github/rails.git
synced 2026-04-04 03:00:58 -04:00
Namespaced StringQuestioneer under ActiveSupport.
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
class StringQuestioneer < String
|
||||
def method_missing(method_name, *arguments)
|
||||
if method_name.to_s.ends_with?("?")
|
||||
self == method_name.to_s[0..-2]
|
||||
else
|
||||
super
|
||||
module ActiveSupport
|
||||
class StringQuestioneer < String
|
||||
def method_missing(method_name, *arguments)
|
||||
if method_name.to_s.ends_with?("?")
|
||||
self == method_name.to_s[0..-2]
|
||||
else
|
||||
super
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,14 +2,14 @@ require 'abstract_unit'
|
||||
|
||||
class StringQuestioneerTest < Test::Unit::TestCase
|
||||
def test_match
|
||||
assert StringQuestioneer.new("production").production?
|
||||
assert ActiveSupport::StringQuestioneer.new("production").production?
|
||||
end
|
||||
|
||||
def test_miss
|
||||
assert !StringQuestioneer.new("production").development?
|
||||
assert !ActiveSupport::StringQuestioneer.new("production").development?
|
||||
end
|
||||
|
||||
def test_missing_question_mark
|
||||
assert_raises(NoMethodError) { StringQuestioneer.new("production").production }
|
||||
assert_raises(NoMethodError) { ActiveSupport::StringQuestioneer.new("production").production }
|
||||
end
|
||||
end
|
||||
@@ -37,7 +37,7 @@ module Rails
|
||||
end
|
||||
|
||||
def env
|
||||
StringQuestioneer.new(RAILS_ENV)
|
||||
ActiveSupport::StringQuestioneer.new(RAILS_ENV)
|
||||
end
|
||||
|
||||
def cache
|
||||
|
||||
Reference in New Issue
Block a user