Sha256: 1035ba6546adc20a84befa2d15a600a33f12c1d65384059335fe7226b56b4fea
Contents?: true
Size: 1.46 KB
Versions: 3
Compression:
Stored size: 1.46 KB
Contents
require 'spec_helper' describe VRBO::Availability do let(:dates) { %w[2015-12-13 2015-12-14 2015-12-15 2015-12-16 2015-12-17 2015-12-20] } subject { described_class.new(dates) } describe '#initialize' do context 'when given an array of dates strings' do it 'assigns @start_at to the date parsed first item' do expect(subject.start_at).to eq Date.parse('2015-12-13') end it 'removes the first item from the array (mutation)' do expect { subject.start_at }.to change(dates, :length).from(6).to(5) end it 'assigns the all but the first items in -dates- to @dates' do expect(subject.dates).to eq %w[2015-12-14 2015-12-15 2015-12-16 2015-12-17 2015-12-20] end end context 'when given nil' do let(:dates) { nil } it 'assigns @start_at to today' do expect(subject.start_at).to eq Date.today end end end describe '#duration' do context 'when given a list of dates in ascending order' do it 'returns the length of the first sequence' do expect(subject.duration).to eq 5 end context 'when dates are sequential' do let(:dates) { %w[2015-12-05 2015-12-07 2015-12-10] } it 'returns one' do expect(subject.duration).to eq 1 end end end context 'when no dates are given' do let(:dates) { [] } it 'returns one' do expect(subject.duration).to eq 1 end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
vrbo-2.1.1 | spec/vrbo/availability_spec.rb |
vrbo-2.1.0 | spec/vrbo/availability_spec.rb |
vrbo-2.0.1 | spec/vrbo/availability_spec.rb |