Sha256: a67a7bc0411a494c729e8707fc6d36f795ce2f425f314a974f95f35b190b7cdd

Contents?: true

Size: 1 KB

Versions: 1

Compression:

Stored size: 1 KB

Contents

require 'spec_helper'

shared_examples_for 'offset parameter' do

  describe 'offset' do
    it 'should memoize the offset variable' do
      Event.instance_variable_get(:@by_star_offset).should eq 3.hours
      Post.instance_variable_get(:@by_star_offset).should be_nil
    end

    context 'between_times with model offset' do
      subject { Event.between_times(Time.parse('2014-01-01'), Time.parse('2014-01-10')) }
      its(:count) { should eq 6 }
    end

    context 'between_times with offset override' do
      subject { Event.between_times(Time.parse('2014-01-01'), Time.parse('2014-01-10'), offset: 16.hours) }
      its(:count) { should eq 6 }
    end

    context 'by_day with model offset' do
      subject { Event.by_day(Time.parse('2014-01-01')) }
      its(:count) { should eq 4 }
    end

    context 'by_day with offset override' do
      subject { Event.by_day(Time.parse('2014-12-26'), field: :start_time, offset: 5.hours) }
      its(:count) { should eq 0 }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
by_star-2.2.0.rc1 spec/integration/shared/offset_parameter.rb