Skip to content

Instantly share code, notes, and snippets.

View emilybache's full-sized avatar

Emily Bache emilybache

View GitHub Profile
@emilybache
emilybache / EmailChangedMessage.java
Last active January 18, 2022 10:51
Peel with a domain event instead of a boolean
record EmailChangedMessage(int userId, String newEmail) implements DomainEvent {}
@emilybache
emilybache / User.java
Created January 18, 2022 10:37
after peeling the call to MessageBus
public void changeEmail(String newEmail)
{
if (changeEmailInDatabase(newEmail)) return;
MessageBus.sendEmailChangedMessage(this.userId, newEmail);
}
boolean changeEmailInDatabase(String newEmail) {
Object[] data = Database.getUserById(userId);
email = (String)data[1];
userType = (UserType)data[2];
public void changeEmail(String newEmail)
{
Object[] data = Database.getUserById(userId);
email = (String)data[1];
userType = (UserType)data[2];
if (Objects.equals(email, newEmail))
return;
Object[] companyData = Database.getCompany(userId);
@emilybache
emilybache / GildedRoseTest.test_foo.approved.txt
Created August 23, 2018 07:56
issue #386 in cosmic ray - the files needed to reproduce the problem
args: ('foo', -1, 0) => 'foo, -2, 0'
args: ('foo', -1, 1) => 'foo, -2, 0'
args: ('foo', -1, 49) => 'foo, -2, 47'
args: ('foo', -1, 50) => 'foo, -2, 48'
args: ('foo', 0, 0) => 'foo, -1, 0'
args: ('foo', 0, 1) => 'foo, -1, 0'
args: ('foo', 0, 49) => 'foo, -1, 47'
args: ('foo', 0, 50) => 'foo, -1, 48'
args: ('foo', 11, 0) => 'foo, 10, 0'
args: ('foo', 11, 1) => 'foo, 10, 0'
@emilybache
emilybache / spec_helper.rb
Last active December 17, 2015 19:38
I'm having trouble getting started with approval testing in ruby, I can't find any documentation, and I can't seem to make sense of the source code. I'd really appreciate some help getting this code to run.
require 'approvals'
require 'approvals/rspec'
Approvals.configuration.approvals_path = './'