Class: RSpecLive::Example
- Inherits:
-
Object
- Object
- RSpecLive::Example
- Defined in:
- lib/rspec-live/example.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#status ⇒ Object
Returns the value of attribute status.
Instance Method Summary collapse
- #backtrace_components(verbosity) ⇒ Object
- #details(verbosity) ⇒ Object
- #exception_components ⇒ Object
- #failed? ⇒ Boolean
- #failure_message(verbosity) ⇒ Object
- #file_touched(name) ⇒ Object
- #in_file?(filename) ⇒ Boolean
-
#initialize ⇒ Example
constructor
A new instance of Example.
- #name_component ⇒ Object
- #passed? ⇒ Boolean
- #stale? ⇒ Boolean
- #update(data) ⇒ Object
Constructor Details
#initialize ⇒ Example
Returns a new instance of Example.
7 8 9 10 11 |
# File 'lib/rspec-live/example.rb', line 7 def initialize @name = "" @status = :unknown @backtrace = [] end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/rspec-live/example.rb', line 5 def name @name end |
#status ⇒ Object
Returns the value of attribute status.
5 6 7 |
# File 'lib/rspec-live/example.rb', line 5 def status @status end |
Instance Method Details
#backtrace_components(verbosity) ⇒ Object
49 50 51 52 |
# 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) ⇒ Object
37 38 39 |
# File 'lib/rspec-live/example.rb', line 37 def details(verbosity) failed? ? (verbosity) : name_component end |
#exception_components ⇒ Object
54 55 56 |
# File 'lib/rspec-live/example.rb', line 54 def exception_components [@message.gsub("\n", " ").strip.inspect] end |
#failed? ⇒ Boolean
29 30 31 |
# File 'lib/rspec-live/example.rb', line 29 def failed? @status == :failed end |
#failure_message(verbosity) ⇒ Object
45 46 47 |
# File 'lib/rspec-live/example.rb', line 45 def (verbosity) ([name_component] + backtrace_components(verbosity) + exception_components).compact.join " -> " end |
#file_touched(name) ⇒ Object
58 59 60 |
# File 'lib/rspec-live/example.rb', line 58 def file_touched(name) @status = :unknown if @files_touched.include? name end |
#in_file?(filename) ⇒ Boolean
62 63 64 |
# File 'lib/rspec-live/example.rb', line 62 def in_file?(filename) absolute_path == filename end |
#name_component ⇒ Object
41 42 43 |
# File 'lib/rspec-live/example.rb', line 41 def name_component "(" + @name.gsub(/^.\//, "") + ")" end |
#passed? ⇒ Boolean
25 26 27 |
# File 'lib/rspec-live/example.rb', line 25 def passed? @status == :passed end |
#stale? ⇒ Boolean
33 34 35 |
# File 'lib/rspec-live/example.rb', line 33 def stale? @status == :unknown end |
#update(data) ⇒ Object
13 14 15 16 17 18 19 |
# 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 |