зеркало из https://github.com/github/ruby.git
Make test for no method error more reliable
This test should not depend on the bahaviour of the did_you_mean gem.
This commit is contained in:
Родитель
2a042f08a5
Коммит
6d4ab96c47
|
@ -55,26 +55,30 @@ class TestNoMethodError < Test::Unit::TestCase
|
||||||
error = NoMethodError.new("Message", :foo)
|
error = NoMethodError.new("Message", :foo)
|
||||||
assert_raise(ArgumentError) {error.receiver}
|
assert_raise(ArgumentError) {error.receiver}
|
||||||
|
|
||||||
msg = defined?(DidYouMean.formatter) ?
|
msg = "Message"
|
||||||
"Message\nDid you mean? for" : "Message"
|
|
||||||
|
|
||||||
error = NoMethodError.new("Message", :foo, receiver: receiver)
|
error = NoMethodError.new("Message", :foo, receiver: receiver)
|
||||||
assert_equal([msg, :foo, receiver],
|
assert_match msg, error.message
|
||||||
[error.message, error.name, error.receiver])
|
assert_equal :foo, error.name
|
||||||
|
assert_equal receiver, error.receiver
|
||||||
|
|
||||||
error = NoMethodError.new("Message", :foo, [1, 2])
|
error = NoMethodError.new("Message", :foo, [1, 2])
|
||||||
assert_raise(ArgumentError) {error.receiver}
|
assert_raise(ArgumentError) {error.receiver}
|
||||||
|
|
||||||
error = NoMethodError.new("Message", :foo, [1, 2], receiver: receiver)
|
error = NoMethodError.new("Message", :foo, [1, 2], receiver: receiver)
|
||||||
assert_equal([msg, :foo, [1, 2], receiver],
|
assert_match msg, error.message
|
||||||
[error.message, error.name, error.args, error.receiver])
|
assert_equal :foo, error.name
|
||||||
|
assert_equal [1, 2], error.args
|
||||||
|
assert_equal receiver, error.receiver
|
||||||
|
|
||||||
error = NoMethodError.new("Message", :foo, [1, 2], true)
|
error = NoMethodError.new("Message", :foo, [1, 2], true)
|
||||||
assert_raise(ArgumentError) {error.receiver}
|
assert_raise(ArgumentError) {error.receiver}
|
||||||
|
|
||||||
error = NoMethodError.new("Message", :foo, [1, 2], true, receiver: receiver)
|
error = NoMethodError.new("Message", :foo, [1, 2], true, receiver: receiver)
|
||||||
assert_equal([:foo, [1, 2], true, receiver],
|
assert_equal :foo, error.name
|
||||||
[error.name, error.args, error.private_call?, error.receiver])
|
assert_equal [1, 2], error.args
|
||||||
|
assert_equal receiver, error.receiver
|
||||||
|
assert error.private_call?, "private_call? was false."
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_message_encoding
|
def test_message_encoding
|
||||||
|
|
Загрузка…
Ссылка в новой задаче