Sha256: ef9372c579dd6a1c9f79ffa1d863a8c304931417cce836d8e09494b71f8579bb
Contents?: true
Size: 1.55 KB
Versions: 1
Compression:
Stored size: 1.55 KB
Contents
require 'spec_helper' shared_examples_for 'scope parameter' do describe 'scope' do it 'should memoize the scope variable' do Event.instance_variable_get(:@by_star_scope).should be_nil Post.instance_variable_get(:@by_star_scope).should be_nil Appointment.instance_variable_get(:@by_star_scope).should be_a Proc end context 'between_times with default scope' do subject { Appointment.between_times(Date.parse('2013-12-01'), Date.parse('2014-02-01')) } its(:count) { should eq 3 } end context 'between_times with scope override as a query criteria' do subject { Appointment.between_times(Date.parse('2013-12-01'), Date.parse('2014-02-01'), scope: Appointment.unscoped) } its(:count) { should eq 14 } end context 'between_times with scope override as a Proc' do subject { Appointment.between_times(Date.parse('2013-12-01'), Date.parse('2014-02-01'), scope: ->{ unscoped }) } its(:count) { should eq 14 } end context 'by_month with default scope' do subject { Appointment.by_month(Date.parse('2014-01-01')) } its(:count) { should eq 2 } end context 'by_month with scope override as a query criteria' do subject { Appointment.by_month(Date.parse('2014-01-01'), scope: Appointment.unscoped) } its(:count) { should eq 6 } end context 'by_month with scope override as a Proc' do subject { Appointment.by_month(Date.parse('2014-01-01'), scope: ->{ unscoped }) } its(:count) { should eq 6 } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
by_star-2.2.0 | spec/integration/shared/scope_parameter.rb |