Class: CucumberScreenshot::Formatter

Inherits:
Cucumber::Ast::Visitor
  • Object
show all
Defined in:
lib/cucumber_screenshot/formatter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(step_mother, io, options) ⇒ Formatter

Currently ignores io and options arguments



7
8
9
10
11
# File 'lib/cucumber_screenshot/formatter.rb', line 7

def initialize(step_mother, io, options)
  super(step_mother)
  @io = io
  @options = options
end

Instance Attribute Details

#current_feature_segmentObject

Returns the value of attribute current_feature_segment.



4
5
6
# File 'lib/cucumber_screenshot/formatter.rb', line 4

def current_feature_segment
  @current_feature_segment
end

#current_scenario_segmentObject

Returns the value of attribute current_scenario_segment.



4
5
6
# File 'lib/cucumber_screenshot/formatter.rb', line 4

def current_scenario_segment
  @current_scenario_segment
end

#response_body_for_last_screenshotObject

Returns the value of attribute response_body_for_last_screenshot.



4
5
6
# File 'lib/cucumber_screenshot/formatter.rb', line 4

def response_body_for_last_screenshot
  @response_body_for_last_screenshot
end

#screenshot_directoryObject

Returns the value of attribute screenshot_directory.



4
5
6
# File 'lib/cucumber_screenshot/formatter.rb', line 4

def screenshot_directory
  @screenshot_directory
end

#screenshot_indexObject

Returns the value of attribute screenshot_index.



4
5
6
# File 'lib/cucumber_screenshot/formatter.rb', line 4

def screenshot_index
  @screenshot_index
end

Instance Method Details

#visit_feature(feature) ⇒ Object



29
30
31
32
# File 'lib/cucumber_screenshot/formatter.rb', line 29

def visit_feature(feature)
  self.current_feature_segment = segment_for_feature(feature)
  super
end

#visit_feature_name(name) ⇒ Object



34
35
36
# File 'lib/cucumber_screenshot/formatter.rb', line 34

def visit_feature_name(name)
  puts(name)
end

#visit_scenario_name(keyword, name, file_colon_line, source_indent) ⇒ Object



22
23
24
25
26
27
# File 'lib/cucumber_screenshot/formatter.rb', line 22

def visit_scenario_name(keyword, name, file_colon_line, source_indent)
  puts "Scenario #{name}"
  self.response_body_for_last_screenshot = nil
  self.screenshot_index = 0
  self.current_scenario_segment = segment_for_scenario_named(name)
end

#visit_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/cucumber_screenshot/formatter.rb', line 13

def visit_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background)
  if screenshot_due?
    self.screenshot_index = screenshot_index.next
    exit unless session.screenshot(screenshot_directory_name, "screenshot-#{format('%03d', screenshot_index)}")
    self.response_body_for_last_screenshot = current_response_body
  end
  super
end