Skip to content

Instantly share code, notes, and snippets.

@will-clarke
Created October 5, 2016 20:37
Show Gist options
  • Save will-clarke/0160f18dfd6168533fc14020fe6cd914 to your computer and use it in GitHub Desktop.
Save will-clarke/0160f18dfd6168533fc14020fe6cd914 to your computer and use it in GitHub Desktop.
require 'rspec'
require_relative 'checkout'
require_relative 'item'
describe Checkout do
subject { described_class.new({bogof: ['FR1']}) }
it '#item' do
expect(subject.item('FR1')[:price]).to eq(311)
end
it '#scan' do
expect(subject.basket).to be_empty
subject.scan('FR1')
expect(subject.basket).to include({ code: 'FR1', name: 'Fruit Tea', price: 311 })
end
it '#total' do
subject.scan('FR1')
expect(subject.total).to eq(311)
subject.scan('FR1')
expect(subject.total).to eq(311)
subject.scan('CF1')
expect(subject.total).to eq(311 + 1123)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment