Exception: Nitrous::AssertionFailedError
- Defined in:
- lib/nitrous/assertions.rb
Instance Method Summary collapse
- #failure_location ⇒ Object
-
#initialize(message, filename) ⇒ AssertionFailedError
constructor
A new instance of AssertionFailedError.
- #snippet ⇒ Object
- #test_output ⇒ Object
Constructor Details
#initialize(message, filename) ⇒ AssertionFailedError
Returns a new instance of AssertionFailedError.
3 4 5 |
# File 'lib/nitrous/assertions.rb', line 3 def initialize(, filename) @message, @filename = , filename end |
Instance Method Details
#failure_location ⇒ Object
7 8 9 10 11 |
# File 'lib/nitrous/assertions.rb', line 7 def failure_location @failure_location ||= backtrace.detect do |line| line.include?(@filename) end end |
#snippet ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/nitrous/assertions.rb', line 13 def snippet failure_location =~ /^([^:]+):(\d+)/ index = $2.to_i - 1 lines = File.readlines($1) "...\n" + " " + lines[index - 1] + " >>" + lines[index] + " " + lines[index + 1] + "...\n" end |
#test_output ⇒ Object
24 25 26 |
# File 'lib/nitrous/assertions.rb', line 24 def test_output "Assertion failed on #{failure_location}\n#{@message}\n#{snippet}" end |