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.

one_line_step_definitions.feature 1.6 kB

2 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. Feature: One line step definitions
  2. Everybody knows you can do step definitions in Cucumber
  3. but did you know you can do this?
  4. Scenario: Call a method in World directly from a step def
  5. Given a file named "features/step_definitions/steps.rb" with:
  6. """
  7. module Driver
  8. def do_action
  9. @done = true
  10. end
  11. def assert_done
  12. expect(@done).to be true
  13. end
  14. end
  15. World(Driver)
  16. When /I do the action/, :do_action
  17. Then /The action should be done/, :assert_done
  18. """
  19. And a file named "features/action.feature" with:
  20. """
  21. Feature:
  22. Scenario:
  23. When I do the action
  24. Then the action should be done
  25. """
  26. When I run `cucumber`
  27. Then it should pass
  28. Scenario: Call a method on an actor in the World directly from a step def
  29. Given a file named "features/step_definitions/steps.rb" with:
  30. """
  31. class Thing
  32. def do_action
  33. @done = true
  34. end
  35. def assert_done
  36. expect(@done).to be true
  37. end
  38. end
  39. module Driver
  40. def thing
  41. @thing ||= Thing.new
  42. end
  43. end
  44. World(Driver)
  45. When /I do the action to the thing/, :do_action, :on => lambda { thing }
  46. Then /The thing should be done/, :assert_done, :on => lambda { thing }
  47. """
  48. And a file named "features/action.feature" with:
  49. """
  50. Feature:
  51. Scenario:
  52. When I do the action to the thing
  53. Then the thing should be done
  54. """
  55. When I run `cucumber`
  56. Then it should pass

No Description

Contributors (1)