Merge pull request #44718 from ghousemohamed/extend-test-cases-for-object-in-activesupport

Add missing test cases for Object in activesupport
This commit is contained in:
Aaron Patterson 2022-03-18 16:14:06 -07:00 committed by GitHub
commit da22687eef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 21 additions and 0 deletions

View File

@ -2,6 +2,7 @@
require_relative "../../abstract_unit"
require "active_support/core_ext/date/acts_like"
require "active_support/core_ext/string/behavior"
require "active_support/core_ext/time/acts_like"
require "active_support/core_ext/date_time/acts_like"
require "active_support/core_ext/object/acts_like"
@ -13,6 +14,15 @@ class ObjectTests < ActiveSupport::TestCase
end
end
class Stringish < String
end
class DuckString
def acts_like_string?
true
end
end
def test_duck_typing
object = Object.new
time = Time.now
@ -35,4 +45,15 @@ class ObjectTests < ActiveSupport::TestCase
assert duck.acts_like?(:time)
assert_not duck.acts_like?(:date)
end
def test_acts_like_string
string = Stringish.new
duck_string = DuckString.new
assert string.acts_like?(:string)
assert_not string.acts_like?(:invalid)
assert duck_string.acts_like?(:string)
assert_not string.acts_like?(:invalid)
end
end