class RSpecLive::Example
Attributes
name[R]
status[R]
Public Class Methods
new()
click to toggle source
# File lib/rspec-live/example.rb, line 7 def initialize @name = "" @status = :unknown @backtrace = [] end
Public Instance Methods
backtrace_components(verbosity)
click to toggle source
# File lib/rspec-live/example.rb, line 49 def backtrace_components(verbosity) return [] if verbosity < 1 Backtrace.new(@backtrace, verbosity).components.reverse.map { |c| "(#{c})" } end
details(verbosity)
click to toggle source
# File lib/rspec-live/example.rb, line 37 def details(verbosity) failed? ? failure_message(verbosity) : name_component end
exception_components()
click to toggle source
# File lib/rspec-live/example.rb, line 54 def exception_components [@message.gsub("\n", " ").strip.inspect] end
failed?()
click to toggle source
# File lib/rspec-live/example.rb, line 29 def failed? @status == :failed end
failure_message(verbosity)
click to toggle source
# File lib/rspec-live/example.rb, line 45 def failure_message(verbosity) ([name_component] + backtrace_components(verbosity) + exception_components).compact.join " -> " end
file_touched(name)
click to toggle source
# File lib/rspec-live/example.rb, line 58 def file_touched(name) @status = :unknown if @files_touched.include? name end
in_file?(filename)
click to toggle source
# File lib/rspec-live/example.rb, line 62 def in_file?(filename) absolute_path == filename end
name_component()
click to toggle source
# File lib/rspec-live/example.rb, line 41 def name_component "(" + @name.gsub(/^.\//, "") + ")" end
passed?()
click to toggle source
# File lib/rspec-live/example.rb, line 25 def passed? @status == :passed end
stale?()
click to toggle source
# File lib/rspec-live/example.rb, line 33 def stale? @status == :unknown end
status=(value)
click to toggle source
# File lib/rspec-live/example.rb, line 21 def status=(value) @status = value.to_sym end
update(data)
click to toggle source
# File lib/rspec-live/example.rb, line 13 def update(data) @name = data["name"] if data["name"] @status = data["status"].to_sym if data["status"] @backtrace = data["backtrace"] if data["backtrace"] @message = data["message"] if data["message"] @files_touched = data["files_touched"] || [] end
Private Instance Methods
absolute_path()
click to toggle source
# File lib/rspec-live/example.rb, line 68 def absolute_path @name.split(":").first.gsub(/^\./, Dir.pwd) end