-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from avispatech/silent-story
Adds silent mode
- Loading branch information
Showing
6 changed files
with
93 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# Storyteller | ||
|
||
version 0.4.2.2 | ||
version 0.4.3 | ||
|
||
Run user stories based on a simple DSL | ||
|
||
|
@@ -83,7 +83,10 @@ Every Story **must** have at least on step to be able to execute, if no steps ar | |
|
||
Verification steps can be added to check if the Story has concluded successfully. | ||
|
||
### Closure | ||
|
||
If some activities are nice to have, but not necessary, i.e. Notifying a newly created | ||
user, the `after_run`s may come in handy. | ||
|
||
## Lifecycle | ||
|
||
|
@@ -97,6 +100,8 @@ Verification steps can be added to check if the Story has concluded successfully | |
- `step` | ||
- verification | ||
- `done_criteria` | ||
- closure | ||
- `after_run` | ||
|
||
|
||
## Helper methods | ||
|
@@ -134,6 +139,41 @@ Require the gem, if needed | |
|
||
`require storyteller` | ||
|
||
Create your Stories extending from `Storyteller::Story` | ||
|
||
``` | ||
class CreateUser < Storyteller::Story | ||
initialize_with :email, :name | ||
step -> { @user = User.create(email:, name:) } | ||
step -> { @user.add_role :member } | ||
after_run :send_emails | ||
def send_emails | ||
Mailer.send_email(email:, template: :welcome) | ||
end | ||
end | ||
``` | ||
|
||
Invoke your story | ||
|
||
``` | ||
CreateUser.execute(email: '[email protected]', name: 'Example User') | ||
# Or the new, and execute way | ||
use_case = CreateUser.new(email: '[email protected]', name: 'Example User') | ||
use_case.execute | ||
``` | ||
|
||
### Silent mode | ||
|
||
To disable the `after_run` method add the `silent_story: true` parameter. | ||
|
||
`CreateUser.execute(email:, name:, silent_story: true)` | ||
|
||
|
||
|
||
## Development | ||
|
||
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
module Storyteller | ||
VERSION = '0.4.2.2' | ||
VERSION = '0.4.3' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters