Class: Spinach::Reporter

Inherits:
Object
  • Object
show all
Defined in:
lib/spinach/reporter.rb,
lib/spinach/reporter/stdout.rb,
lib/spinach/reporter/stdout/error_reporting.rb

Overview

Spinach reporter collects information from Runner hooks and outputs the results

Direct Known Subclasses

Stdout

Defined Under Namespace

Classes: Stdout

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Reporter) initialize(options = {})

Initialize a reporter with an empty error container.



10
11
12
13
14
15
16
17
18
# File 'lib/spinach/reporter.rb', line 10

def initialize(options = {})
  @errors = []
  @options = options
  @undefined_features = []
  @successful_steps = []
  @undefined_steps = []
  @failed_steps = []
  @error_steps = []
end

Instance Attribute Details

- (Object) current_feature (readonly)

A Hash with options for the reporter



22
23
24
# File 'lib/spinach/reporter.rb', line 22

def current_feature
  @current_feature
end

- (Object) current_scenario (readonly)

A Hash with options for the reporter



22
23
24
# File 'lib/spinach/reporter.rb', line 22

def current_scenario
  @current_scenario
end

- (Object) error_steps (readonly)

Returns the value of attribute error_steps



24
25
26
# File 'lib/spinach/reporter.rb', line 24

def error_steps
  @error_steps
end

- (Object) failed_steps (readonly)

Returns the value of attribute failed_steps



24
25
26
# File 'lib/spinach/reporter.rb', line 24

def failed_steps
  @failed_steps
end

- (Object) options (readonly)

A Hash with options for the reporter



22
23
24
# File 'lib/spinach/reporter.rb', line 22

def options
  @options
end

- (Object) successful_steps (readonly)

Returns the value of attribute successful_steps



24
25
26
# File 'lib/spinach/reporter.rb', line 24

def successful_steps
  @successful_steps
end

- (Object) undefined_features (readonly)

Returns the value of attribute undefined_features



24
25
26
# File 'lib/spinach/reporter.rb', line 24

def undefined_features
  @undefined_features
end

- (Object) undefined_steps (readonly)

Returns the value of attribute undefined_steps



24
25
26
# File 'lib/spinach/reporter.rb', line 24

def undefined_steps
  @undefined_steps
end

Instance Method Details

- (Object) after_feature_run(*args)



51
# File 'lib/spinach/reporter.rb', line 51

def after_feature_run(*args); end

- (Object) after_run(*args)



49
# File 'lib/spinach/reporter.rb', line 49

def after_run(*args); end

- (Object) after_scenario_run(*args)



57
# File 'lib/spinach/reporter.rb', line 57

def after_scenario_run(*args); end

- (Object) around_scenario_run(*args)



54
55
56
# File 'lib/spinach/reporter.rb', line 54

def around_scenario_run(*args)
  yield
end

- (Object) before_feature_run(*args)



50
# File 'lib/spinach/reporter.rb', line 50

def before_feature_run(*args); end

- (Object) before_scenario_run(*args)



53
# File 'lib/spinach/reporter.rb', line 53

def before_scenario_run(*args); end

- (Object) bind

Hooks the reporter to the runner endpoints



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/spinach/reporter.rb', line 27

def bind
  Spinach.hooks.tap do |hooks|
    hooks.after_run { |*args| after_run(*args) }
    hooks.before_feature { |*args| before_feature_run(*args) }
    hooks.after_feature { |*args| after_feature_run(*args) }
    hooks.on_undefined_feature { |*args| on_feature_not_found(*args) }
    hooks.before_scenario { |*args| before_scenario_run(*args) }
    hooks.around_scenario { |*args, &block| around_scenario_run(*args, &block) }
    hooks.after_scenario { |*args| after_scenario_run(*args) }
    hooks.on_successful_step { |*args| on_successful_step(*args) }
    hooks.on_undefined_step { |*args| on_undefined_step(*args) }
    hooks.on_failed_step { |*args| on_failed_step(*args) }
    hooks.on_error_step { |*args| on_error_step(*args) }
    hooks.on_skipped_step { |*args| on_skipped_step(*args) }

    hooks.before_feature { |*args| set_current_feature(*args) }
    hooks.after_feature { |*args| clear_current_feature(*args) }
    hooks.before_scenario { |*args| set_current_scenario(args.first) }
    hooks.after_scenario { |*args| clear_current_scenario(args.first) }
  end
end

- (Object) clear_current_feature(*args)

Clears this current feature



73
74
75
# File 'lib/spinach/reporter.rb', line 73

def clear_current_feature(*args)
  @current_feature = nil
end

- (Object) clear_current_scenario(*args)

Clears this current scenario



86
87
88
# File 'lib/spinach/reporter.rb', line 86

def clear_current_scenario(*args)
  @current_scenario = nil
end

- (Object) on_error_step(*args)



60
# File 'lib/spinach/reporter.rb', line 60

def on_error_step(*args); end

- (Object) on_failed_step(*args)



59
# File 'lib/spinach/reporter.rb', line 59

def on_failed_step(*args); end

- (Object) on_feature_not_found(*args)



52
# File 'lib/spinach/reporter.rb', line 52

def on_feature_not_found(*args); end

- (Object) on_skipped_step(*args)



62
# File 'lib/spinach/reporter.rb', line 62

def on_skipped_step(*args); end

- (Object) on_successful_step(*args)



58
# File 'lib/spinach/reporter.rb', line 58

def on_successful_step(*args); end

- (Object) on_undefined_step(*args)



61
# File 'lib/spinach/reporter.rb', line 61

def on_undefined_step(*args); end

- (Object) set_current_feature(feature)

Stores the current feature

Parameters:



68
69
70
# File 'lib/spinach/reporter.rb', line 68

def set_current_feature(feature)
  @current_feature = feature
end

- (Object) set_current_scenario(scenario)

Stores the current scenario

Parameters:

  • the (Hash)

    data for this scenario



81
82
83
# File 'lib/spinach/reporter.rb', line 81

def set_current_scenario(scenario)
  @current_scenario = scenario
end