Module: TestRig::SmarterMessage

Defined in:
lib/test_rig/smarter_message.rb

Constant Summary collapse

@@context_lines =
2

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.backtrace_regexObject



9
10
11
# File 'lib/test_rig/smarter_message.rb', line 9

def self.backtrace_regex
  @@backtrace_regex ||= /_test\.rb/
end

.included(klass) ⇒ Object



13
14
15
16
17
# File 'lib/test_rig/smarter_message.rb', line 13

def self.included(klass)
  klass.class_eval do
    alias_method_chain :assert_block, :smarter_message
  end
end

Instance Method Details

#assert_block_with_smarter_message(*args, &blk) ⇒ Object



19
20
21
22
23
24
25
26
27
28
# File 'lib/test_rig/smarter_message.rb', line 19

def assert_block_with_smarter_message(*args, &blk)
  assert_block_without_smarter_message(*args, &blk)
rescue Test::Unit::AssertionFailedError => e
  backtrace = e.backtrace
  relevant_traces = relevant_traces(backtrace)
  raise if relevant_traces.blank?
  new_error = Test::Unit::AssertionFailedError.new e.message + "\n" + message_for_backtrace(backtrace)
  new_error.set_backtrace(relevant_traces)
  raise new_error
end