提交 7c564d87 编写于 作者: E Eileen M. Uchitelle 提交者: GitHub

Merge pull request #30817 from yalab/friendly_exception_message

Exception message for SystemTestCase#get etc..
......@@ -14,7 +14,7 @@ module UndefMethods # :nodoc:
def method_missing(method, *args, &block)
if METHODS.include?(method)
raise NoMethodError
raise NoMethodError, "System tests cannot make direct requests via ##{method}; use #visit and #click_on instead. See http://www.rubydoc.info/github/teamcapybara/capybara/master#The_DSL for more information."
else
super
end
......
......@@ -36,32 +36,37 @@ class SetHostTest < DrivenByRackTest
class UndefMethodsTest < DrivenBySeleniumWithChrome
test "get" do
assert_raise NoMethodError do
exception = assert_raise NoMethodError do
get "http://example.com"
end
assert_equal "System tests cannot make direct requests via #get; use #visit and #click_on instead. See http://www.rubydoc.info/github/teamcapybara/capybara/master#The_DSL for more information.", exception.message
end
test "post" do
assert_raise NoMethodError do
exception = assert_raise NoMethodError do
post "http://example.com"
end
assert_equal "System tests cannot make direct requests via #post; use #visit and #click_on instead. See http://www.rubydoc.info/github/teamcapybara/capybara/master#The_DSL for more information.", exception.message
end
test "put" do
assert_raise NoMethodError do
exception = assert_raise NoMethodError do
put "http://example.com"
end
assert_equal "System tests cannot make direct requests via #put; use #visit and #click_on instead. See http://www.rubydoc.info/github/teamcapybara/capybara/master#The_DSL for more information.", exception.message
end
test "patch" do
assert_raise NoMethodError do
exception = assert_raise NoMethodError do
patch "http://example.com"
end
assert_equal "System tests cannot make direct requests via #patch; use #visit and #click_on instead. See http://www.rubydoc.info/github/teamcapybara/capybara/master#The_DSL for more information.", exception.message
end
test "delete" do
assert_raise NoMethodError do
exception = assert_raise NoMethodError do
delete "http://example.com"
end
assert_equal "System tests cannot make direct requests via #delete; use #visit and #click_on instead. See http://www.rubydoc.info/github/teamcapybara/capybara/master#The_DSL for more information.", exception.message
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册