Skip to content

Commit

Permalink
Fix Given/when I repeat "{step}"
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandreDecan committed Mar 15, 2018
1 parent 590547b commit d5484c8
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Changelog
=========

0.26.0 (2018-03-15)
0.26.1 (2018-03-15)
-------------------

Sismic support for BDD was completely rewritten. The CLI is now ``sismic-bdd``, pointing to the ``cli`` submodule of
Expand Down
4 changes: 3 additions & 1 deletion docs/behavior.rst
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@ Given/when I reproduce "{scenario}"

Given/when I repeat "{step}" {repeat:d} times

This step repeats given step (including its step keyword) several times.
This step repeats given step several times.
The text of the step must be provided without its keyword, and will be executed using the
current keyword (*given* or *when*).


Given/when I send event {name}
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/microwave/heating_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
action_alias('I open the door', 'I send event door_opened')
action_alias('I close the door', 'I send event door_closed')
action_alias('I place an item in the oven', 'I send event item_placed')
action_alias('I press increase timer button {time} times', 'I repeat "given I send event timer_inc" {time} times')
action_alias('I press increase timer button {time} times', 'I repeat "I send event timer_inc" {time} times')
action_alias('I press increase power button', 'I send event power_inc')
action_alias('I press start button', 'I send event cooking_start')
action_alias('{tick} seconds elapsed', 'I repeat "given I send event timer_tick" {tick} times')
action_alias('{tick} seconds elapsed', 'I repeat "I send event timer_tick" {tick} times')

assertion_alias('Heating turns on', 'Event heating_on is fired')
assertion_alias('Heating does not turn on', 'Event heating_on is not fired')
Expand Down
2 changes: 1 addition & 1 deletion sismic/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
__description__ = 'Sismic Interactive Statechart Model Interpreter and Checker'
__version__ = '0.26.0'
__version__ = '0.26.1'
__url__ = 'https://github.com/AlexandreDecan/sismic/'
__author__ = 'Alexandre Decan'
__email__ = 'alexandre.decan@lexpage.net'
Expand Down
16 changes: 8 additions & 8 deletions sismic/bdd/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,19 @@ def reproduce_scenario(context, scenario, *, keyword='Given'):


@when('I reproduce "{scenario}"')
def __reproduce_scenario(context, scenario):
def _reproduce_scenario(context, scenario):
return reproduce_scenario(context, scenario, keyword='When')


@given('I repeat "{step}" {repeat:d} times')
@when('I repeat "{step}" {repeat:d} times')
def repeat_step(context, step, repeat):
keyword = step.split(' ', 1)[0].lower()
assert keyword in ['given', 'when', 'and', 'but', 'then'], \
'Step {} should start with a supported keyword'.format(step)

def repeat_step(context, step, repeat, *, keyword='Given'):
for _ in range(repeat):
context.execute_steps(step)
context.execute_steps('{} {}'.format(keyword, step))


@when('I repeat "{step}" {repeat:d} times')
def _repeat_step(context, step, repeat):
return repeat_step(context, step, repeat, keyword='When')


@given('I send event {name}')
Expand Down

0 comments on commit d5484c8

Please sign in to comment.