aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch/exception_wrapper_test.rb
diff options
context:
space:
mode:
authorGuillermo Iguaran <guilleiguaran@gmail.com>2014-11-16 10:41:35 -0500
committerGuillermo Iguaran <guilleiguaran@gmail.com>2014-11-16 10:41:35 -0500
commit7ae7ae5b281360243a4d8be9e3c24aaf9def71be (patch)
tree9d8558c201bd4c8e27d4c4cee067c51c988ba3f8 /actionpack/test/dispatch/exception_wrapper_test.rb
parent4b4dca48a590fe9380cc0b727788a36a8c40296f (diff)
parente05714fdbc4d6a767f207b08a94ba3ebf147213e (diff)
downloadrails-7ae7ae5b281360243a4d8be9e3c24aaf9def71be.tar.gz
rails-7ae7ae5b281360243a4d8be9e3c24aaf9def71be.tar.bz2
rails-7ae7ae5b281360243a4d8be9e3c24aaf9def71be.zip
Merge pull request #17636 from gsamokovarov/exception-wrapper-less-nils
Don't let #{application,framework,full}_trace be nil
Diffstat (limited to 'actionpack/test/dispatch/exception_wrapper_test.rb')
-rw-r--r--actionpack/test/dispatch/exception_wrapper_test.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/actionpack/test/dispatch/exception_wrapper_test.rb b/actionpack/test/dispatch/exception_wrapper_test.rb
index 3ddaa7294b..57292d3191 100644
--- a/actionpack/test/dispatch/exception_wrapper_test.rb
+++ b/actionpack/test/dispatch/exception_wrapper_test.rb
@@ -10,6 +10,12 @@ module ActionDispatch
end
end
+ class BadlyDefinedError < StandardError
+ def backtrace
+ nil
+ end
+ end
+
setup do
Rails.stubs(:root).returns(Pathname.new('.'))
@@ -28,6 +34,7 @@ module ActionDispatch
assert_equal [ code: 'foo', file: 'lib/file.rb', line_number: 42 ], wrapper.source_extract
end
+
test '#application_trace returns traces only from the application' do
exception = TestError.new(caller.prepend("lib/file.rb:42:in `index'"))
wrapper = ExceptionWrapper.new(@environment, exception)
@@ -35,6 +42,14 @@ module ActionDispatch
assert_equal [ "lib/file.rb:42:in `index'" ], wrapper.application_trace
end
+ test '#application_trace cannot be nil' do
+ nil_backtrace_wrapper = ExceptionWrapper.new(@environment, BadlyDefinedError.new)
+ nil_cleaner_wrapper = ExceptionWrapper.new({}, BadlyDefinedError.new)
+
+ assert_equal [], nil_backtrace_wrapper.application_trace
+ assert_equal [], nil_cleaner_wrapper.application_trace
+ end
+
test '#framework_trace returns traces outside the application' do
exception = TestError.new(caller.prepend("lib/file.rb:42:in `index'"))
wrapper = ExceptionWrapper.new(@environment, exception)
@@ -42,6 +57,14 @@ module ActionDispatch
assert_equal caller, wrapper.framework_trace
end
+ test '#framework_trace cannot be nil' do
+ nil_backtrace_wrapper = ExceptionWrapper.new(@environment, BadlyDefinedError.new)
+ nil_cleaner_wrapper = ExceptionWrapper.new({}, BadlyDefinedError.new)
+
+ assert_equal [], nil_backtrace_wrapper.framework_trace
+ assert_equal [], nil_cleaner_wrapper.framework_trace
+ end
+
test '#full_trace returns application and framework traces' do
exception = TestError.new(caller.prepend("lib/file.rb:42:in `index'"))
wrapper = ExceptionWrapper.new(@environment, exception)
@@ -49,6 +72,14 @@ module ActionDispatch
assert_equal exception.backtrace, wrapper.full_trace
end
+ test '#full_trace cannot be nil' do
+ nil_backtrace_wrapper = ExceptionWrapper.new(@environment, BadlyDefinedError.new)
+ nil_cleaner_wrapper = ExceptionWrapper.new({}, BadlyDefinedError.new)
+
+ assert_equal [], nil_backtrace_wrapper.full_trace
+ assert_equal [], nil_cleaner_wrapper.full_trace
+ end
+
test '#traces returns every trace by category enumerated with an index' do
exception = TestError.new("lib/file.rb:42:in `index'", "/gems/rack.rb:43:in `index'")
wrapper = ExceptionWrapper.new(@environment, exception)