Class: Cucumber::Runtime

Inherits:
Object show all
Includes:
Core, Formatter::Duration, UserInterface
Defined in:
lib/cucumber/runtime.rb,
lib/cucumber/runtime/results.rb,
lib/cucumber/runtime/tag_limits.rb,
lib/cucumber/runtime/support_code.rb,
lib/cucumber/runtime/gated_receiver.rb,
lib/cucumber/runtime/user_interface.rb,
lib/cucumber/runtime/tag_limits/filter.rb,
lib/cucumber/runtime/tag_limits/verifier.rb,
lib/cucumber/runtime/for_programming_languages.rb,
lib/cucumber/runtime/tag_limits/test_case_index.rb

Defined Under Namespace

Modules: TagLimits, UserInterface Classes: ForProgrammingLanguages, GatedReceiver, NormalisedEncodingFile, Quit, Randomizer, Results, SupportCode

Instance Attribute Summary (collapse)

Attributes included from UserInterface

#visitor

Instance Method Summary (collapse)

Methods included from UserInterface

#ask, #embed, #puts

Methods included from Formatter::Duration

#format_duration

Constructor Details

- (Runtime) initialize(configuration = Configuration.default)

Returns a new instance of Runtime



48
49
50
51
52
53
# File 'lib/cucumber/runtime.rb', line 48

def initialize(configuration = Configuration.default)
  @current_scenario = nil
  @configuration = Configuration.parse(configuration)
  @support_code = SupportCode.new(self, @configuration)
  @results = Results.new(@configuration)
end

Instance Attribute Details

- (Object) configuration (readonly)

Returns the value of attribute configuration



42
43
44
# File 'lib/cucumber/runtime.rb', line 42

def configuration
  @configuration
end

- (Object) results (readonly)

Returns the value of attribute results



42
43
44
# File 'lib/cucumber/runtime.rb', line 42

def results
  @results
end

- (Object) support_code (readonly)

Returns the value of attribute support_code



42
43
44
# File 'lib/cucumber/runtime.rb', line 42

def support_code
  @support_code
end

Instance Method Details

- (Object) after(scenario)

:nodoc:



144
145
146
147
148
# File 'lib/cucumber/runtime.rb', line 144

def after(scenario) #:nodoc:
  @current_scenario = nil
  return if dry_run?
  @support_code.fire_hook(:after, scenario)
end

- (Object) after_step

:nodoc:



150
151
152
153
# File 'lib/cucumber/runtime.rb', line 150

def after_step #:nodoc:
  return if dry_run?
  @support_code.fire_hook(:execute_after_step, @current_scenario)
end

- (Object) around(scenario, skip_hooks = false, &block)

:nodoc:



114
115
116
117
118
119
120
121
# File 'lib/cucumber/runtime.rb', line 114

def around(scenario, skip_hooks=false, &block) #:nodoc:
  if skip_hooks
    yield
    return
  end

  @support_code.around(scenario, block)
end

- (Object) before(scenario)

:nodoc:



138
139
140
141
142
# File 'lib/cucumber/runtime.rb', line 138

def before(scenario) #:nodoc:
  return if dry_run? || @current_scenario
  @current_scenario = scenario
  @support_code.fire_hook(:before, scenario)
end

- (Object) before_and_after(scenario, skip_hooks = false) {|scenario| ... }

:nodoc:

Yields:

  • (scenario)


123
124
125
126
127
128
# File 'lib/cucumber/runtime.rb', line 123

def before_and_after(scenario, skip_hooks=false) #:nodoc:
  before(scenario) unless skip_hooks
  yield scenario
  after(scenario) unless skip_hooks
  record_result scenario
end

- (Object) begin_scenario(scenario)



134
135
136
# File 'lib/cucumber/runtime.rb', line 134

def begin_scenario(scenario)
  @support_code.fire_hook(:begin_scenario, scenario)
end

- (Object) configure(new_configuration)

Allows you to take an existing runtime and change it's configuration



56
57
58
59
60
# File 'lib/cucumber/runtime.rb', line 56

def configure(new_configuration)
  @configuration = Configuration.parse(new_configuration)
  @support_code.configure(@configuration)
  @results.configure(@configuration)
end

- (Object) doc_string(string_without_triple_quotes, content_type = '', line_offset = 0)

Returns Ast::DocString for string_without_triple_quotes.



161
162
163
164
165
# File 'lib/cucumber/runtime.rb', line 161

def doc_string(string_without_triple_quotes, content_type='', line_offset=0)
  file, line = *caller[0].split(':')[0..1]
  location = Core::Ast::Location.new(file, line)
  Core::Ast::DocString.new(string_without_triple_quotes, content_type, location)
end

- (Boolean) dry_run?

Returns:

  • (Boolean)


78
79
80
# File 'lib/cucumber/runtime.rb', line 78

def dry_run?
  @configuration.dry_run?
end

- (Object) features_paths



74
75
76
# File 'lib/cucumber/runtime.rb', line 74

def features_paths
  @configuration.paths
end

- (Object) load_programming_language(language)



62
63
64
# File 'lib/cucumber/runtime.rb', line 62

def load_programming_language(language)
  @support_code.load_programming_language(language)
end

- (Object) record_result(scenario)



130
131
132
# File 'lib/cucumber/runtime.rb', line 130

def record_result(scenario)
  @results.scenario_visited(scenario)
end

- (Object) run!



66
67
68
69
70
71
72
# File 'lib/cucumber/runtime.rb', line 66

def run!
  load_step_definitions
  fire_after_configuration_hook
  self.visitor = report

  execute features, mappings, report, filters
end

- (Object) scenarios(status = nil)



86
87
88
# File 'lib/cucumber/runtime.rb', line 86

def scenarios(status = nil)
  @results.scenarios(status)
end

- (Object) snippet_text(step_keyword, step_name, multiline_arg)

:nodoc:



102
103
104
# File 'lib/cucumber/runtime.rb', line 102

def snippet_text(step_keyword, step_name, multiline_arg) #:nodoc:
  @support_code.snippet_text(::Gherkin::I18n.code_keyword_for(step_keyword), step_name, multiline_arg)
end

- (Object) step_match(step_name, name_to_report = nil)

:nodoc:



94
95
96
# File 'lib/cucumber/runtime.rb', line 94

def step_match(step_name, name_to_report=nil) #:nodoc:
  @support_code.step_match(step_name, name_to_report)
end

- (Object) step_visited(step)

:nodoc:



82
83
84
# File 'lib/cucumber/runtime.rb', line 82

def step_visited(step) #:nodoc:
  @results.step_visited(step)
end

- (Object) steps(status = nil)



90
91
92
# File 'lib/cucumber/runtime.rb', line 90

def steps(status = nil)
  @results.steps(status)
end

- (Boolean) unknown_programming_language?

Returns:

  • (Boolean)


155
156
157
# File 'lib/cucumber/runtime.rb', line 155

def unknown_programming_language?
  @support_code.unknown_programming_language?
end

- (Object) unmatched_step_definitions



98
99
100
# File 'lib/cucumber/runtime.rb', line 98

def unmatched_step_definitions
  @support_code.unmatched_step_definitions
end

- (Object) with_hooks(scenario, skip_hooks = false)



106
107
108
109
110
111
112
# File 'lib/cucumber/runtime.rb', line 106

def with_hooks(scenario, skip_hooks=false)
  around(scenario, skip_hooks) do
    before_and_after(scenario, skip_hooks) do
      yield scenario
    end
  end
end