mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Namespaced StringQuestioneer under ActiveSupport.
This commit is contained in:
parent
1e4fae42d4
commit
6e85f14817
3 changed files with 13 additions and 11 deletions
|
@ -1,3 +1,4 @@
|
|||
module ActiveSupport
|
||||
class StringQuestioneer < String
|
||||
def method_missing(method_name, *arguments)
|
||||
if method_name.to_s.ends_with?("?")
|
||||
|
@ -7,3 +8,4 @@ class StringQuestioneer < String
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue