spec/integration/shared/scope_parameter.rb in by_star-2.2.0 vs spec/integration/shared/scope_parameter.rb in by_star-2.2.1

- old
+ new

@@ -17,26 +17,56 @@ 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 + context 'between_times with scope override as a Lambda' do subject { Appointment.between_times(Date.parse('2013-12-01'), Date.parse('2014-02-01'), scope: ->{ unscoped }) } its(:count) { should eq 14 } end + context 'between_times with scope override as a Lambda' do + subject { Appointment.between_times(Date.parse('2013-12-01'), Date.parse('2014-02-01'), scope: ->(x){ unscoped }) } + it{ ->{subject}.should raise_error } + end + + context 'between_times with scope override as a Proc with arguments' do + subject { Appointment.between_times(Date.parse('2013-12-01'), Date.parse('2014-02-01'), scope: Proc.new{ unscoped }) } + its(:count) { should eq 14 } + end + + context 'between_times with scope override as a Proc with arguments' do + subject { Appointment.between_times(Date.parse('2013-12-01'), Date.parse('2014-02-01'), scope: Proc.new{|x,y| unscoped }) } + it{ ->{subject}.should raise_error } + 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 + context 'by_month with scope override as a Lambda' do subject { Appointment.by_month(Date.parse('2014-01-01'), scope: ->{ unscoped }) } its(:count) { should eq 6 } + end + + context 'by_month with scope override as a Lambda with arguments' do + subject { Appointment.by_month(Date.parse('2014-01-01'), scope: ->(x){ unscoped }) } + it{ ->{subject}.should raise_error } + end + + context 'by_month with scope override as a Proc' do + subject { Appointment.by_month(Date.parse('2014-01-01'), scope: Proc.new{ unscoped }) } + its(:count) { should eq 6 } + end + + context 'by_month with scope override as a Proc with arguments' do + subject { Appointment.by_month(Date.parse('2014-01-01'), scope: Proc.new{|x| unscoped }) } + it{ ->{subject}.should raise_error } end end end