I know it''s bad form to reply to one''s own post, but what I
came up with
was to create yet another backtrace manager local to my code:
def scrap_backtrace(pattern)
yield
rescue Test::Unit::AssertionFailedError => e
path = File.expand_path(__FILE__)
puts e.class
raise Test::Unit::AssertionFailedError, e.message,
e.backtrace.reject { |line| File.expand_path(line) =~ /#{path}/ }
end
def method_missing(m, *args)
scrap_backtrace do
my_assert_code_that_shouldnt_show_in_backtrace
end
end
If there''s a cooler way to do this, I''d love to know.
On Tuesday, July 25, 2006, at 8:46 PM, steve ross wrote:>I''m writing a method_missing handler to "automagically"
create
>assertions from predicate functions. So, for example, one use might be:
>
>assert_not_include ''joes@shmoe.com'', response.to
>
>-or-
>
>assert_include ''info@mydomain.com'', response.from
>
>The code is working properly, but when I trigger an assert, the
>backtrace shows something like:
>
> 1) Failure:
>test_confirm(ContactMailerTest)
> [./test/unit/../test_helper.rb:74:in `method_missing''
> ./test/unit/../test_helper.rb:61:in `method_missing''
> ./test/unit/contact_mailer_test.rb:39:in `test_confirm'']:
>assert_not_include: expected joes@shmoe.com not in joes@shmoe.com
>
>What I''d prefer is to remove the items in the backtrace array that
refer
>to the test method because they don''t add information but am not
certain
>how. Rails uses clean_backtrace, which looks like it should work, but no
>luck with that.
>
>Any help appreciated.
>--
>Posted with http://DevLists.com. Sign up and save your mailbox.
>_______________________________________________
>Rails mailing list
>Rails@lists.rubyonrails.org
>http://lists.rubyonrails.org/mailman/listinfo/rails
--
Posted with http://DevLists.com. Sign up and save your mailbox.