Skip to content

Instantly share code, notes, and snippets.

@laser
Last active January 4, 2016 09:39
Show Gist options
  • Save laser/8603665 to your computer and use it in GitHub Desktop.
Save laser/8603665 to your computer and use it in GitHub Desktop.
array combiner
# Account = Struct.new(:id, :last_active)
describe 'pruning expired accounts' do
let(:acc1) { Account.new(1, Date.today) }
let(:acc2) { Account.new(2, Date.today) }
let(:acc3) { Account.new(3, Date.today) }
describe 'when the first account is expired' do
let(:acc1) { Account.new(1, Date.today - 45) }
describe 'when the second account is expired' do
let(:acc2) { Account.new(1, Date.today - 45) }
describe 'when the third account is not expired' do
it 'returns the third account' do
expect(AccountPruner.prune(acc1, acc2, acc3)).to eq([acc3])
end
end
describe 'when the third account is expired' do
let(:acc3) { Account.new(1, Date.today - 45) }
it 'returns no accounts' do
expect(AccountPruner.prune(acc1, acc2, acc3)).to eq([])
end
end
end
# ...continue for all combinations we want to test
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment