This is the meaty part of Cucumber that ties everything together.
# File lib/cucumber/step_mother.rb, line 358 def after_configuration(configuration) #:nodoc @programming_languages.each do |programming_language| programming_language.after_configuration(configuration) end end
Output announcement alongside the formatted output. This is an alternative to using Kernel#puts - it will display nicer, and in all outputs (in case you use several formatters)
# File lib/cucumber/step_mother.rb, line 125 def announce(msg) msg.respond_to?(:join) ? @visitor.announce(msg.join("\n")) : @visitor.announce(msg.to_s) end
Suspends execution and prompts question to the console (STDOUT). An operator (manual tester) can then enter a line of text and hit <ENTER>. The entered text is returned, and both question and the result is added to the output using announce.
If you want a beep to happen (to grab the manual tester’s attention), just prepend ASCII character 7 to the question:
ask("#{7.chr}How many cukes are in the external system?")
If that doesn’t issue a beep, you can shell out to something else that makes a sound before invoking ask.
# File lib/cucumber/step_mother.rb, line 142 def ask(question, timeout_seconds) STDOUT.puts(question) STDOUT.flush announce(question) if(Cucumber::JRUBY) answer = jruby_gets(timeout_seconds) else answer = mri_gets(timeout_seconds) end if(answer) announce(answer) answer else raise("Waited for input for #{timeout_seconds} seconds, then timed out.") end end
Embed file of MIME type mime_type into the output. This may or may not be ignored, depending on what kind of formatter(s) are active.
# File lib/cucumber/step_mother.rb, line 164 def embed(file, mime_type) @visitor.embed(file, mime_type) end
# File lib/cucumber/step_mother.rb, line 177 def invoke(step_name, multiline_argument=nil) begin step_match(step_name).invoke(multiline_argument) rescue Exception => e e.nested! if Undefined === e raise e end end
Invokes a series of steps steps_text. Example:
invoke(%Q{ Given I have 8 cukes in my belly Then I should not be thirsty })
# File lib/cucumber/step_mother.rb, line 192 def invoke_steps(steps_text, i18n) lexer = i18n.lexer(Gherkin::Parser::Parser.new(StepInvoker.new(self), true, 'steps')) lexer.scan(steps_text) end
# File lib/cucumber/step_mother.rb, line 81 def load_code_file(step_def_file) if programming_language = programming_language_for(step_def_file) log.debug(" * #{step_def_file}\n") programming_language.load_code_file(step_def_file) else log.debug(" * #{step_def_file} [NOT SUPPORTED]\n") end end
# File lib/cucumber/step_mother.rb, line 73 def load_code_files(step_def_files) log.debug("Code:\n") step_def_files.each do |step_def_file| load_code_file(step_def_file) end log.debug("\n") end
# File lib/cucumber/step_mother.rb, line 55 def load_plain_text_features(feature_files) features = Ast::Features.new start = Time.new log.debug("Features:\n") feature_files.each do |f| feature_file = FeatureFile.new(f) feature = feature_file.parse(self, options) if feature features.add_feature(feature) log.debug(" * #{f}\n") end end duration = Time.now - start log.debug("Parsing feature files took #{format_duration(duration)}\n\n") features end
Loads and registers programming language implementation. Instances are cached, so calling with the same argument twice will return the same instance.
# File lib/cucumber/step_mother.rb, line 94 def load_programming_language(ext) return @language_map[ext] if @language_map[ext] programming_language_class = constantize("Cucumber::#{ext.capitalize}Support::#{ext.capitalize}Language") programming_language = programming_language_class.new(self) @programming_languages << programming_language @language_map[ext] = programming_language programming_language end
Returns the options passed on the command line.
# File lib/cucumber/step_mother.rb, line 104 def options @options ||= Cli::Options.new end
Returns a regular String for string_with_triple_quotes. Example:
""" hello world """
Is retured as: “ hellonworld”
# File lib/cucumber/step_mother.rb, line 267 def py_string(string_with_triple_quotes, file=nil, line_offset=0) Ast::PyString.parse(string_with_triple_quotes) end
Returns a Cucumber::Ast::Table for text_or_table, which can either be a String:
table(%{ | account | description | amount | | INT-100 | Taxi | 114 | | CUC-101 | Peeler | 22 | })
or a 2D Array:
table([ %w{ account description amount }, %w{ INT-100 Taxi 114 }, %w{ CUC-101 Peeler 22 } ])
# File lib/cucumber/step_mother.rb, line 250 def table(text_or_table, file=nil, line_offset=0) if Array === text_or_table Ast::Table.new(text_or_table) else Ast::Table.parse(text_or_table) end end
Generated with the Darkfish Rdoc Generator 2.