Module: Probatio::ExtraErrorMethods
- Defined in:
- lib/probatio/errors.rb
Instance Attribute Summary collapse
-
#test ⇒ Object
Returns the value of attribute test.
Instance Method Summary collapse
- #line ⇒ Object
- #loc ⇒ Object
- #location ⇒ Object
- #path ⇒ Object
- #source_lines ⇒ Object
- #summary(indent = '') ⇒ Object
- #trail ⇒ Object
Instance Attribute Details
#test ⇒ Object
Returns the value of attribute test.
231 232 233 |
# File 'lib/probatio/errors.rb', line 231 def test @test end |
Instance Method Details
#line ⇒ Object
265 266 267 268 269 270 271 272 273 274 275 276 |
# File 'lib/probatio/errors.rb', line 265 def line backtrace.each do |l| ss = l.split(':') next unless ss.find { |e| e == test.path } return ss.find { |e| e.match?(/^\d+$/) }.to_i end -1 end |
#loc ⇒ Object
235 |
# File 'lib/probatio/errors.rb', line 235 def loc; location.map(&:to_s).join(':'); end |
#location ⇒ Object
234 |
# File 'lib/probatio/errors.rb', line 234 def location; [ path, line ]; end |
#path ⇒ Object
233 |
# File 'lib/probatio/errors.rb', line 233 def path; test.path; end |
#source_lines ⇒ Object
245 246 247 248 249 |
# File 'lib/probatio/errors.rb', line 245 def source_lines @source_lines ||= Probatio::AssertionError.select_source_lines(test.path, line) end |
#summary(indent = '') ⇒ Object
251 252 253 254 255 256 257 258 259 260 261 262 263 |
# File 'lib/probatio/errors.rb', line 251 def summary(indent='') o = StringIO.new o << self.class.name << ': ' << self..inspect << "\n" i = backtrace.index { |l| l.match?(/\/lib\/probatio\.rb:/) } || -1 backtrace[0..i] .inject(o) { |o, l| o << indent << l << "\n" } o.string end |