Permalink
Browse files

Merge pull request #30817 from yalab/friendly_exception_message

Exception message for SystemTestCase#get etc..
  • Loading branch information...
eileencodes committed Oct 8, 2017
2 parents 8ad8bba + 54b18a2 commit 7c564d87408ca1e205d34574228d6f981c7571c8
@@ -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

0 comments on commit 7c564d8

Please sign in to comment.