diff options
Diffstat (limited to 'spec/support/shared_examples/policies/within_timeframe_shared_examples.rb')
-rw-r--r-- | spec/support/shared_examples/policies/within_timeframe_shared_examples.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/support/shared_examples/policies/within_timeframe_shared_examples.rb b/spec/support/shared_examples/policies/within_timeframe_shared_examples.rb new file mode 100644 index 00000000000..918db6886d3 --- /dev/null +++ b/spec/support/shared_examples/policies/within_timeframe_shared_examples.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +RSpec.shared_examples 'within_timeframe scope' do + describe '.within_timeframe' do + it 'returns resources with start_date and/or end_date between timeframe' do + resources = described_class.within_timeframe(now + 2.days, now + 3.days) + + expect(resources).to match_array([resource_2, resource_4]) + end + + it 'returns resources which starts before the timeframe' do + resources = described_class.within_timeframe(now, now + 1.day) + + expect(resources).to match_array([resource_1, resource_3, resource_4]) + end + + it 'returns resources which ends after the timeframe' do + resources = described_class.within_timeframe(now + 3.days, now + 5.days) + + expect(resources).to match_array([resource_2, resource_4]) + end + end +end |