This is the meaty part of Cucumber that ties everything together.
# File lib/cucumber/step_mother.rb, line 376
376: def after_configuration(configuration) #:nodoc
377: @programming_languages.each do |programming_language|
378: programming_language.after_configuration(configuration)
379: end
380: 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 149
149: def announce(msg)
150: msg.respond_to?(:join) ? @visitor.announce(msg.join("\n")) : @visitor.announce(msg.to_s)
151: end
Suspends execution and prompts question to the console (STDOUT).
An operator (manual tester) can then enter a line of text and hit
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 #.
# File lib/cucumber/step_mother.rb, line 166
166: def ask(question, timeout_seconds)
167: STDOUT.puts(question)
168: STDOUT.flush
169: announce(question)
170:
171: if(Cucumber::JRUBY)
172: answer = jruby_gets(timeout_seconds)
173: else
174: answer = mri_gets(timeout_seconds)
175: end
176:
177: if(answer)
178: announce(answer)
179: answer
180: else
181: raise("Waited for input for #{timeout_seconds} seconds, then timed out.")
182: end
183: end
# File lib/cucumber/step_mother.rb, line 83
83: def check_tag_limits(tag_counts)
84: error_messages = []
85: options[:tag_expression].limits.each do |tag_name, tag_limit|
86: tag_locations = (tag_counts[tag_name] || [])
87: tag_count = tag_locations.length
88: if tag_count > tag_limit
89: error = "#{tag_name} occurred #{tag_count} times, but the limit was set to #{tag_limit}\n " +
90: tag_locations.join("\n ")
91: error_messages << error
92: end
93: end
94: raise TagExcess.new(error_messages) if error_messages.any?
95: 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 188
188: def embed(file, mime_type)
189: @visitor.embed(file, mime_type)
190: end
# File lib/cucumber/step_mother.rb, line 201
201: def invoke(step_name, multiline_argument=nil)
202: begin
203: step_match(step_name).invoke(multiline_argument)
204: rescue Exception => e
205: e.nested! if Undefined === e
206: raise e
207: end
208: 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 216
216: def invoke_steps(steps_text, i18n, file_colon_line)
217: file, line = file_colon_line.split(':')
218: parser = Gherkin::Parser::Parser.new(StepInvoker.new(self), true, 'steps')
219: parser.parse(steps_text, file, line.to_i)
220: end
# File lib/cucumber/step_mother.rb, line 105
105: def load_code_file(step_def_file)
106: if programming_language = programming_language_for(step_def_file)
107: log.debug(" * #{step_def_file}\n")
108: programming_language.load_code_file(step_def_file)
109: else
110: log.debug(" * #{step_def_file} [NOT SUPPORTED]\n")
111: end
112: end
# File lib/cucumber/step_mother.rb, line 97
97: def load_code_files(step_def_files)
98: log.debug("Code:\n")
99: step_def_files.each do |step_def_file|
100: load_code_file(step_def_file)
101: end
102: log.debug("\n")
103: end
# File lib/cucumber/step_mother.rb, line 61
61: def load_plain_text_features(feature_files)
62: features = Ast::Features.new
63:
64: tag_counts = {}
65: start = Time.new
66: log.debug("Features:\n")
67: feature_files.each do |f|
68: feature_file = FeatureFile.new(f)
69: feature = feature_file.parse(options, tag_counts)
70: if feature
71: features.add_feature(feature)
72: log.debug(" * #{f}\n")
73: end
74: end
75: duration = Time.now - start
76: log.debug("Parsing feature files took #{format_duration(duration)}\n\n")
77:
78: check_tag_limits(tag_counts)
79:
80: features
81: 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 118
118: def load_programming_language(ext)
119: return @language_map[ext] if @language_map[ext]
120: programming_language_class = constantize("Cucumber::#{ext.capitalize}Support::#{ext.capitalize}Language")
121: programming_language = programming_language_class.new(self)
122: @programming_languages << programming_language
123: @language_map[ext] = programming_language
124: programming_language
125: end
Returns the options passed on the command line.
# File lib/cucumber/step_mother.rb, line 128
128: def options
129: @options ||= Cli::Options.new
130: end
Returns a regular String for string_with_triple_quotes. Example:
""" hello world """
Is retured as: “ hellonworld“
# File lib/cucumber/step_mother.rb, line 277
277: def py_string(string_with_triple_quotes, file=nil, line_offset=0)
278: Ast::PyString.parse(string_with_triple_quotes)
279: 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 260
260: def table(text_or_table, file=nil, line_offset=0)
261: if Array === text_or_table
262: Ast::Table.new(text_or_table)
263: else
264: Ast::Table.parse(text_or_table, file, line_offset)
265: end
266: end
# File lib/cucumber/step_mother.rb, line 320
320: def unknown_programming_language?
321: @programming_languages.empty?
322: end
# File lib/cucumber/step_mother.rb, line 421
421: def jruby_gets(timeout_seconds)
422: answer = nil
423: t = java.lang.Thread.new do
424: answer = STDIN.gets
425: end
426: t.start
427: t.join(timeout_seconds * 1000)
428: answer
429: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.