1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
# frozen_string_literal: true
require 'cucumber/core/test/result'
require 'cucumber/core/test/action'
require 'cucumber/core/test/empty_multiline_argument'
module Cucumber
module Core
module Test
class Step
attr_reader :id, :text, :location, :multiline_arg
def initialize(id, text, location, multiline_arg = Test::EmptyMultilineArgument.new, action = Test::Action::Undefined.new(location))
raise ArgumentError if text.nil? || text.empty?
@id = id
@text = text
@location = location
@multiline_arg = multiline_arg
@action = action
end
def describe_to(visitor, *)
visitor.test_step(self, *)
end
def hook?
false
end
def skip(*)
@action.skip(*)
end
def execute(*)
@action.execute(*)
end
def with_action(action_location = nil, &)
self.class.new(id, text, location, multiline_arg, Test::Action::Defined.new(action_location, &))
end
def with_unskippable_action(action_location = nil, &)
self.class.new(id, text, location, multiline_arg, Test::Action::Unskippable.new(action_location, &))
end
def backtrace_line
"#{location}:in `#{text}'"
end
def to_s
text
end
def action_location
@action.location
end
def matching_locations
[location.merge(multiline_arg)]
end
def inspect
"#<#{self.class}: #{location}>"
end
end
end
end
end
|