Skip to content

Instantly share code, notes, and snippets.

@joegaudet
Created January 1, 2020 18:28
Show Gist options
  • Save joegaudet/51f9c89c7601d6d42abc7ddbe65ed936 to your computer and use it in GitHub Desktop.
Save joegaudet/51f9c89c7601d6d42abc7ddbe65ed936 to your computer and use it in GitHub Desktop.
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
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