Sha256: d8231cd5ed0f0b1b69273f0542d0d4c09bd613de52d871b228072404a3ba4995
Contents?: true
Size: 1.54 KB
Versions: 1
Compression:
Stored size: 1.54 KB
Contents
require 'spec_helper' shared_examples_for 'by direction' do describe '#before' do context 'point-in-time' do subject { Post.before(Date.parse '2014-01-05') } its(:count){ should eq 3 } end context 'timespan' do subject { Event.before(Time.parse '2014-01-05') } its(:count){ should eq 4 } end context 'timespan strict' do subject { Event.before('2014-01-05', strict: true) } its(:count){ should eq 4 } end end describe '#after' do context 'point-in-time' do subject { Post.after('2014-01-05') } its(:count){ should eq 10 } end context 'timespan' do subject { Event.after(Date.parse '2014-01-05') } its(:count){ should eq 9 } end context 'timespan strict' do subject { Event.after('2014-01-05', strict: true) } its(:count){ should eq 9 } end end describe '#previous and #next' do context 'point-in-time' do subject { Post.where(created_at: Time.zone.parse('2014-01-10 17:00:00')).first } it{ subject.previous.created_at.should eq Time.zone.parse('2014-01-05 17:00:00') } it{ subject.next.created_at.should eq Time.zone.parse('2014-01-12 17:00:00') } end context 'timespan' do subject { Event.where(start_time: Time.zone.parse('2014-01-05 17:00:00')).first } it{ subject.previous.start_time.should eq Time.zone.parse('2013-12-31 17:00:00') } it{ subject.next.start_time.should eq Time.zone.parse('2014-01-07 17:00:00') } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
by_star-2.2.0.rc1 | spec/integration/shared/by_direction.rb |