You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

errors.rb 1.5 kB

2 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. # frozen_string_literal: true
  2. require 'cucumber/core/test/result'
  3. module Cucumber
  4. # Raised when there is no matching StepDefinition for a step.
  5. class Undefined < Core::Test::Result::Undefined
  6. def self.from(result, step_name)
  7. return result.with_message(with_prefix(result.message)) if result.is_a?(self)
  8. begin
  9. raise self, with_prefix(step_name)
  10. rescue StandardError => e
  11. e
  12. end
  13. end
  14. def self.with_prefix(step_name)
  15. %(Undefined step: "#{step_name}")
  16. end
  17. end
  18. # Raised when there is no matching StepDefinition for a step called
  19. # from within another step definition.
  20. class UndefinedDynamicStep < StandardError
  21. def initialize(step_name)
  22. super %(Undefined dynamic step: "#{step_name}")
  23. end
  24. end
  25. # Raised when a StepDefinition's block invokes World#pending
  26. class Pending < Core::Test::Result::Pending
  27. end
  28. # Raised when a step matches 2 or more StepDefinitions
  29. class Ambiguous < StandardError
  30. def initialize(step_name, step_definitions, used_guess)
  31. message = String.new # rubocop:disable Style/EmptyLiteral
  32. message << "Ambiguous match of \"#{step_name}\":\n\n"
  33. message << step_definitions.map(&:backtrace_line).join("\n")
  34. message << "\n\n"
  35. message << "You can run again with --guess to make Cucumber be more smart about it\n" unless used_guess
  36. super(message)
  37. end
  38. end
  39. class TagExcess < StandardError
  40. def initialize(messages)
  41. super(messages.join("\n"))
  42. end
  43. end
  44. end

No Description

Contributors (1)