Created
January 1, 2020 18:28
-
-
Save joegaudet/51f9c89c7601d6d42abc7ddbe65ed936 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
describe FooCommand do | |
it 'sets the name of and saves bar' do | |
# setup | |
foo_command = FooCommand.as_subject | |
# store is wired onto every test, and shared by the DAO class Save / Find etc. | |
store.put(Bar.new(id: 123, name: 'old_name')) | |
#exercise | |
foo_command.(123, "Bar") | |
#assert | |
saved_bar = store.get(Bar, 123) | |
assert saved_bar.name == "Bar" | |
end | |
end |
This file contains hidden or 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
class FooCommand < Commands::Command | |
dependency :find, Queries::Id.klass(Baz) | |
dependency :save, Commands::SaveRecord | |
def call(bar_id, bar_name) | |
bar = find.(bar) | |
bar.name = bar_name | |
save.(bar) | |
bar | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment