Skip to content

Instantly share code, notes, and snippets.

@stevo
Created May 8, 2018 09:28
Show Gist options
  • Save stevo/9b2f09c831e93c30a2bf149b888bb477 to your computer and use it in GitHub Desktop.
Save stevo/9b2f09c831e93c30a2bf149b888bb477 to your computer and use it in GitHub Desktop.
An opinionated guide to readable RSpec (part 2 of 2)
describe '#nightly_price_for' do
context 'when given night is not booked' do
context 'when given night is weekend night' do
context 'when weekend nightly rate is available for period' do
it 'returns weekend nightly rate for period' do
rates_table = <<~RATE_PLAN
Rate period | Nightly | Weekend Night | Weekly | Monthly
---------------------------------------------------------------------
2017/07/20 - 2017/07/31 | 500 | 600 | 2800 | 30000
2017/08/01 - 2017/08/10 | 200 | 400 (Sat,Sun) | 1400 | 20000
2017/08/11 - 2017/08/30 | 150 | 250 | 1050 | 15000
Standard | 600 | 100 (Sat,Sun) | 3000 | 40000
RATE_PLAN
expect(
get_nightly_price_for(
'2017-08-05',
booked: false,
rates_table: rates_table
)
).to eq 400.0
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment