lib/cucumber/rb_support/rb_world.rb in cucumber-1.3.20 vs lib/cucumber/rb_support/rb_world.rb in cucumber-2.0.0.beta.1
- old
+ new
@@ -9,32 +9,19 @@
module RbWorld
# @private
AnsiEscapes = Gherkin::Formatter::AnsiEscapes
- class << self
- # @private
- def alias_adverb(adverb)
- alias_method adverb, :__cucumber_invoke
- end
- end
-
# Call a Transform with a string from another Transform definition
def Transform(arg)
rb = @__cucumber_runtime.load_programming_language('rb')
rb.execute_transforms([arg]).first
end
# @private
attr_writer :__cucumber_runtime, :__natural_language
- # @private
- def __cucumber_invoke(name, multiline_argument=nil) #:nodoc:
- STDERR.puts AnsiEscapes.failed + "WARNING: Using 'Given/When/Then' in step definitions is deprecated, use 'step' to call other steps instead:" + caller[0] + AnsiEscapes.reset
- @__cucumber_runtime.invoke(name, multiline_argument)
- end
-
# Run a single Gherkin step
# @example Call another step
# step "I am logged in"
# @example Call a step with quotes in the name
# step %{the user "Dave" is logged in}
@@ -46,12 +33,15 @@
# })
# @example Passing a multiline string
# step "the email should contain:", "Dear sir,\nYou've won a prize!\n"
# @param [String] name The name of the step
# @param [String,Cucumber::Ast::DocString,Cucumber::Ast::Table] multiline_argument
- def step(name, multiline_argument=nil)
- @__cucumber_runtime.invoke(name, multiline_argument)
+ def step(name, raw_multiline_arg=nil)
+ # TODO: this argument parsing should move up out of core
+ location = Core::Ast::Location.new(*caller[0].split(':')[0..1])
+ core_multiline_arg = Core::Ast::MultilineArgument.from(raw_multiline_arg, location)
+ @__cucumber_runtime.invoke(name, MultilineArgument.from(core_multiline_arg))
end
# Run a snippet of Gherkin
# @example
# steps %{
@@ -100,11 +90,11 @@
#
# @note Cucumber might surprise you with the behaviour of this method. Instead
# of sending the output directly to STDOUT, Cucumber will intercept and cache
# the message until the current step has finished, and then display it.
#
- # If you'd prefer to see the message immediately, call {Kernel#puts} instead.
+ # If you'd prefer to see the message immediately, call {Kernel.puts} instead.
def puts(*messages)
@__cucumber_runtime.puts(*messages)
end
# Pause the tests and ask the operator for input
@@ -121,15 +111,20 @@
def pending(message = "TODO")
if block_given?
begin
yield
rescue Exception
- raise Pending.new(message)
+ raise Pending, message
end
- raise Pending.new("Expected pending '#{message}' to fail. No Error was raised. No longer pending?")
+ raise Pending, "Expected pending '#{message}' to fail. No Error was raised. No longer pending?"
else
- raise Pending.new(message)
+ raise Pending, message
end
+ end
+
+ # Skips this step and the remaining steps in the scenario
+ def skip_this_scenario(message = "Scenario skipped")
+ raise Core::Test::Result::Skipped, message
end
# Prints the list of modules that are included in the World
def inspect
modules = [self.class]