Class: Cucumber::Runtime

Inherits:
Object show all
Includes:
Core, Formatter::Duration, UserInterface
Defined in:
lib/cucumber/runtime.rb,
lib/cucumber/runtime/support_code.rb,
lib/cucumber/runtime/user_interface.rb,
lib/cucumber/runtime/for_programming_languages.rb

Defined Under Namespace

Modules: UserInterface Classes: ForProgrammingLanguages, NormalisedEncodingFile, 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

#initialize(configuration = Configuration.default) ⇒ Runtime



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

def initialize(configuration = Configuration.default)
  @configuration = Configuration.parse(configuration)
  @support_code = SupportCode.new(self, @configuration)
  @results = Formatter::LegacyApi::Results.new
end

Instance Attribute Details

#configurationObject (readonly)

Returns the value of attribute configuration



44
45
46
# File 'lib/cucumber/runtime.rb', line 44

def configuration
  @configuration
end

#resultsObject (readonly)

Returns the value of attribute results



44
45
46
# File 'lib/cucumber/runtime.rb', line 44

def results
  @results
end

#support_codeObject (readonly)

Returns the value of attribute support_code



44
45
46
# File 'lib/cucumber/runtime.rb', line 44

def support_code
  @support_code
end

Instance Method Details

#begin_scenario(scenario) ⇒ Object



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

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

#configure(new_configuration) ⇒ Object

Allows you to take an existing runtime and change its configuration



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

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

#doc_string(string_without_triple_quotes, content_type = '', line_offset = 0) ⇒ Object

Returns Ast::DocString for string_without_triple_quotes.



112
113
114
115
# File 'lib/cucumber/runtime.rb', line 112

def doc_string(string_without_triple_quotes, content_type='', line_offset=0)
  location = Core::Ast::Location.of_caller
  Core::Ast::DocString.new(string_without_triple_quotes, content_type, location)
end

#dry_run?Boolean



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

def dry_run?
  @configuration.dry_run?
end

#failure?Boolean



205
206
207
208
209
210
211
212
# File 'lib/cucumber/runtime.rb', line 205

def failure?
  if @configuration.wip?
    summary_report.test_cases.total_passed > 0
  else
    summary_report.test_cases.total_failed > 0 || summary_report.test_steps.total_failed > 0 ||
      (@configuration.strict? && (summary_report.test_steps.total_undefined > 0 || summary_report.test_steps.total_skipped > 0))
  end
end

#features_pathsObject



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

def features_paths
  @configuration.paths
end

#load_programming_language(language) ⇒ Object



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

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

#run!Object



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

#scenarios(status = nil) ⇒ Object



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

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

#snippet_text(step_keyword, step_name, multiline_arg) ⇒ Object

:nodoc:



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

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

#step_match(step_name, name_to_report = nil) ⇒ Object

:nodoc:



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

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

#steps(status = nil) ⇒ Object



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

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

#unknown_programming_language?Boolean



106
107
108
# File 'lib/cucumber/runtime.rb', line 106

def unknown_programming_language?
  @support_code.unknown_programming_language?
end

#unmatched_step_definitionsObject



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

def unmatched_step_definitions
  @support_code.unmatched_step_definitions
end