Module: Cucumber::World
- Defined in:
- lib/cucumber/world.rb
Overview
All steps are run in the context of an object that extends this module
Instance Attribute Summary collapse
-
#__cucumber_current_step ⇒ Object
writeonly
Sets the attribute __cucumber_current_step.
-
#__cucumber_step_mother ⇒ Object
writeonly
Sets the attribute __cucumber_step_mother.
-
#__cucumber_visitor ⇒ Object
writeonly
Sets the attribute __cucumber_visitor.
Class Method Summary collapse
Instance Method Summary collapse
-
#__cucumber_invoke(name, multiline_argument = nil) ⇒ Object
Call a step from within a step definition.
-
#announce(announcement) ⇒ Object
Output
announcement
alongside the formatted output. - #pending(message = "TODO") ⇒ Object
- #table(text, file = nil, line_offset = 0) ⇒ Object
Instance Attribute Details
#__cucumber_current_step=(value) ⇒ Object (writeonly)
Sets the attribute __cucumber_current_step
10 11 12 |
# File 'lib/cucumber/world.rb', line 10 def __cucumber_current_step=(value) @__cucumber_current_step = value end |
#__cucumber_step_mother=(value) ⇒ Object (writeonly)
Sets the attribute __cucumber_step_mother
10 11 12 |
# File 'lib/cucumber/world.rb', line 10 def __cucumber_step_mother=(value) @__cucumber_step_mother = value end |
#__cucumber_visitor=(value) ⇒ Object (writeonly)
Sets the attribute __cucumber_visitor
10 11 12 |
# File 'lib/cucumber/world.rb', line 10 def __cucumber_visitor=(value) @__cucumber_visitor = value end |
Class Method Details
.alias_adverb(adverb) ⇒ Object
5 6 7 |
# File 'lib/cucumber/world.rb', line 5 def alias_adverb(adverb) alias_method adverb, :__cucumber_invoke end |
Instance Method Details
#__cucumber_invoke(name, multiline_argument = nil) ⇒ Object
Call a step from within a step definition
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/cucumber/world.rb', line 13 def __cucumber_invoke(name, multiline_argument=nil) #:nodoc: begin step_match = @__cucumber_step_mother.step_match(name) step_match.invoke(self, multiline_argument) rescue Exception => e e.nested! if Undefined === e @__cucumber_current_step.exception = e if @__cucumber_current_step raise e end end |
#announce(announcement) ⇒ Object
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)
Beware that the output will be printed before the corresponding step. This is because the step itself will not be printed until after it has run, so it can be coloured according to its status.
36 37 38 |
# File 'lib/cucumber/world.rb', line 36 def announce(announcement) @__cucumber_visitor.announce(announcement) end |
#pending(message = "TODO") ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/cucumber/world.rb', line 40 def pending( = "TODO") if block_given? begin yield rescue Exception => e raise Pending.new() end raise Pending.new("Expected pending '#{}' to fail. No Error was raised. No longer pending?") else raise Pending.new() end end |
#table(text, file = nil, line_offset = 0) ⇒ Object
24 25 26 27 |
# File 'lib/cucumber/world.rb', line 24 def table(text, file=nil, line_offset=0) @table_parser ||= Parser::TableParser.new @table_parser.parse_or_fail(text.strip, file, line_offset) end |