Class: Example
- Inherits:
-
Object
- Object
- Example
- Defined in:
- lib/specify_html_reporter/example.rb
Instance Attribute Summary collapse
-
#duration ⇒ Object
readonly
Returns the value of attribute duration.
-
#exception ⇒ Object
readonly
Returns the value of attribute exception.
-
#file_path ⇒ Object
readonly
Returns the value of attribute file_path.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#run_time ⇒ Object
readonly
Returns the value of attribute run_time.
-
#screen_grab ⇒ Object
readonly
Returns the value of attribute screen_grab.
-
#spec ⇒ Object
readonly
Returns the value of attribute spec.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#video_record ⇒ Object
readonly
Returns the value of attribute video_record.
Class Method Summary collapse
Instance Method Summary collapse
- #comment ⇒ Object
- #comment? ⇒ Boolean
- #create_spec_line(spec_text) ⇒ Object
- #example_title ⇒ Object
- #exception? ⇒ Boolean
-
#initialize(example) ⇒ Example
constructor
A new instance of Example.
- #result_type(prefix = 'label-') ⇒ Object
- #screen_grab? ⇒ Boolean
- #spec? ⇒ Boolean
- #video_record? ⇒ Boolean
Constructor Details
#initialize(example) ⇒ Example
Returns a new instance of Example.
11 12 13 14 15 16 17 18 |
# File 'lib/specify_html_reporter/example.rb', line 11 def initialize(example) @spec = nil @example = example setup_execution_result setup_example_data setup_exception end |
Instance Attribute Details
#duration ⇒ Object (readonly)
Returns the value of attribute duration.
8 9 10 |
# File 'lib/specify_html_reporter/example.rb', line 8 def duration @duration end |
#exception ⇒ Object (readonly)
Returns the value of attribute exception.
8 9 10 |
# File 'lib/specify_html_reporter/example.rb', line 8 def exception @exception end |
#file_path ⇒ Object (readonly)
Returns the value of attribute file_path.
8 9 10 |
# File 'lib/specify_html_reporter/example.rb', line 8 def file_path @file_path end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
8 9 10 |
# File 'lib/specify_html_reporter/example.rb', line 8 def @metadata end |
#run_time ⇒ Object (readonly)
Returns the value of attribute run_time.
8 9 10 |
# File 'lib/specify_html_reporter/example.rb', line 8 def run_time @run_time end |
#screen_grab ⇒ Object (readonly)
Returns the value of attribute screen_grab.
8 9 10 |
# File 'lib/specify_html_reporter/example.rb', line 8 def screen_grab @screen_grab end |
#spec ⇒ Object (readonly)
Returns the value of attribute spec.
8 9 10 |
# File 'lib/specify_html_reporter/example.rb', line 8 def spec @spec end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
8 9 10 |
# File 'lib/specify_html_reporter/example.rb', line 8 def status @status end |
#video_record ⇒ Object (readonly)
Returns the value of attribute video_record.
8 9 10 |
# File 'lib/specify_html_reporter/example.rb', line 8 def video_record @video_record end |
Class Method Details
.load_spec_comments!(examples) ⇒ Object
66 67 68 69 70 71 72 73 74 75 |
# File 'lib/specify_html_reporter/example.rb', line 66 def self.load_spec_comments!(examples) examples.group_by(&:file_path).each do |file_path, file_examples| lines = File.readlines(file_path) file_examples.zip(file_examples.rotate).each do |example, next_ex| determine_lexical_next(example, next_ex) process_spec_lines(example, next_ex, lines) end end end |
Instance Method Details
#comment ⇒ Object
52 53 54 |
# File 'lib/specify_html_reporter/example.rb', line 52 def comment ERB::Util.html_escape(@comment) end |
#comment? ⇒ Boolean
56 57 58 |
# File 'lib/specify_html_reporter/example.rb', line 56 def comment? !@comment.nil? end |
#create_spec_line(spec_text) ⇒ Object
60 61 62 63 64 |
# File 'lib/specify_html_reporter/example.rb', line 60 def create_spec_line(spec_text) formatter = Rouge::Formatters::HTML.new(css_class: 'highlight') lexer = Rouge::Lexers::Gherkin.new @spec = formatter.format(lexer.lex(spec_text.gsub('#->', ''))) end |
#example_title ⇒ Object
30 31 32 33 34 |
# File 'lib/specify_html_reporter/example.rb', line 30 def example_title full_title = @example_group.to_s.split('::') - %w[RSpec ExampleGroups] full_title.push @description full_title.join(' → ') end |
#exception? ⇒ Boolean
36 37 38 |
# File 'lib/specify_html_reporter/example.rb', line 36 def exception? !@exception.problem.nil? end |
#result_type(prefix = 'label-') ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/specify_html_reporter/example.rb', line 20 def result_type(prefix = 'label-') class_map = { passed: "#{prefix}success", failed: "#{prefix}danger", pending: "#{prefix}warning" } class_map[@status.to_sym] end |
#screen_grab? ⇒ Boolean
44 45 46 |
# File 'lib/specify_html_reporter/example.rb', line 44 def screen_grab? !@screen_grab.nil? && !@screen_grab.empty? end |
#spec? ⇒ Boolean
40 41 42 |
# File 'lib/specify_html_reporter/example.rb', line 40 def spec? !@spec.nil? end |
#video_record? ⇒ Boolean
48 49 50 |
# File 'lib/specify_html_reporter/example.rb', line 48 def video_record? !@video_record.nil? end |