dgp-schedule_attributes 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,46 +14,46 @@ describe ScheduleAttributes::RuleParser::Day do
14
14
  context 'no arguments', args: {} do
15
15
  let(:every_day) { [t, t+1.day, t+2.days, t+3.days, t+4.days, t+5.days, t+6.days, t+7.days, t+8.days] }
16
16
 
17
- it { should == IceCube::Rule.daily }
18
- its_occurrences_until(8.days.from_now) { should == every_day }
17
+ it { is_expected.to eq(IceCube::Rule.daily) }
18
+ its_occurrences_until(8.days.from_now) { is_expected.to eq(every_day) }
19
19
  end
20
20
 
21
21
  context 'interval argument', args: {interval: 2} do
22
22
  let(:every_other_day) { [t, t+2.days, t+4.days, t+6.days, t+8.days] }
23
23
 
24
- it { should == IceCube::Rule.daily(2) }
25
- its_occurrences_until(8.days.from_now) { should == every_other_day }
24
+ it { is_expected.to eq(IceCube::Rule.daily(2)) }
25
+ its_occurrences_until(8.days.from_now) { is_expected.to eq(every_other_day) }
26
26
  end
27
27
 
28
28
  context 'end_date argument', args: {end_date: '2014-01-30'} do
29
29
  let(:t) { Time.new(2014,01,30) }
30
30
  let(:last_5_days) { [t-4.days, t-3.days, t-2.days, t-1.day, t] }
31
31
 
32
- it { should == IceCube::Rule.daily.until(t) }
33
- its_occurrences_until(Time.new(2014,02,01)) { subject[-5..-1].should == last_5_days }
32
+ it { is_expected.to eq(IceCube::Rule.daily.until(t)) }
33
+ its_occurrences_until(Time.new(2014,02,01)) { expect(subject[-5..-1]).to eq last_5_days }
34
34
  end
35
35
 
36
36
  context 'yearly_start_month and yearly_end_month arguments, whole year', args: {yearly_start_month: 1, yearly_end_month: 12} do
37
- it { should == IceCube::Rule.daily }
37
+ it { is_expected.to eq(IceCube::Rule.daily) }
38
38
  end
39
39
 
40
40
  context 'yearly_start_month and yearly_end_month arguments, less than a year', args: {yearly_start_month: 6, yearly_end_month: 8} do
41
- it { should == IceCube::Rule.daily.month_of_year(6,7,8) }
41
+ it { is_expected.to eq(IceCube::Rule.daily.month_of_year(6,7,8)) }
42
42
  end
43
43
 
44
44
  context 'yearly_start_month and yearly_end_month arguments, jump year', args: {yearly_start_month: 11, yearly_end_month: 1} do
45
- it { should == IceCube::Rule.daily.month_of_year(11,12,1) }
45
+ it { is_expected.to eq(IceCube::Rule.daily.month_of_year(11,12,1)) }
46
46
  end
47
47
 
48
48
  context 'yearly_start_month and yearly_end_month arguments, jump year alt', args: {yearly_start_month: 12, yearly_end_month: 2} do
49
- it { should == IceCube::Rule.daily.month_of_year(12,1,2) }
49
+ it { is_expected.to eq(IceCube::Rule.daily.month_of_year(12,1,2)) }
50
50
  end
51
51
 
52
52
  context 'yearly_start_month, yearly_start_month_day, yearly_end_month and yearly_end_month_day arguments', args: {
53
53
  yearly_start_month: 3, yearly_start_month_day: 14,
54
54
  yearly_end_month: 3, yearly_end_month_day: 17
55
55
  } do
56
- it { should == IceCube::Rule.daily.month_of_year(3) }
56
+ it { is_expected.to eq(IceCube::Rule.daily.month_of_year(3)) }
57
57
  end
58
58
  end
59
59
 
@@ -65,48 +65,48 @@ describe ScheduleAttributes::RuleParser::Day do
65
65
  yearly_end_month: 3, yearly_end_month_day: 26
66
66
  } do
67
67
  it "returns exceptions for the leading & trailing days" do
68
- should == [
68
+ is_expected.to eq([
69
69
  IceCube::Rule.daily.month_of_year(3).day_of_month(*1..3),
70
70
  IceCube::Rule.daily.month_of_year(3).day_of_month(*27..31)
71
- ]
71
+ ])
72
72
  end
73
73
  end
74
74
 
75
75
  context 'yearly_start_month and yearly_end_month arguments', args: {yearly_start_month: 3, yearly_end_month: 3} do
76
76
  it "has no trailing exceptions" do
77
- should == []
77
+ is_expected.to eq([])
78
78
  end
79
79
  end
80
80
 
81
81
  context 'yearly_start_month, yearly_end_month and yearly_end_month_day arguments', args: {yearly_start_month: 3, yearly_end_month: 4, yearly_end_month_day: 25} do
82
82
  it "returns exceptions for the trailing days of the last month only" do
83
- should == [IceCube::Rule.daily.month_of_year(4).day_of_month(*26..31)]
83
+ is_expected.to eq([IceCube::Rule.daily.month_of_year(4).day_of_month(*26..31)])
84
84
  end
85
85
  end
86
86
 
87
87
  context 'yearly_start_month, yearly_start_month_day and yearly_end_month arguments', args: {yearly_start_month: 3, yearly_start_month_day: 3, yearly_end_month: 4} do
88
88
  it "returns exceptions for the leading days of the first month" do
89
- should == [
89
+ is_expected.to eq([
90
90
  IceCube::Rule.daily.month_of_year(3).day_of_month(*1..2)
91
- ]
91
+ ])
92
92
  end
93
93
  end
94
94
 
95
95
  context 'yearly_start_month, yearly_end_month, yearly_start_month_day and yearly_end_month_day arguments', args: {yearly_start_month: 3, yearly_end_month: 4, yearly_start_month_day: 31, yearly_end_month_day: 1} do
96
96
  it "excepts the first 30 days of first month and last 30 days of last month" do
97
- should == [
97
+ is_expected.to eq([
98
98
  IceCube::Rule.daily.month_of_year(3).day_of_month(*1..30),
99
99
  IceCube::Rule.daily.month_of_year(4).day_of_month(*2..31)
100
- ]
100
+ ])
101
101
  end
102
102
  end
103
103
 
104
104
  context 'yearly_start_month, yearly_end_month, yearly_start_month_day and yearly_end_month_day arguments', args: {yearly_start_month: 12, yearly_end_month: 1, yearly_start_month_day: 31, yearly_end_month_day: 1} do
105
105
  it "excepts the first 30 days of first month and last 30 days of last month" do
106
- should == [
106
+ is_expected.to eq([
107
107
  IceCube::Rule.daily.month_of_year(12).day_of_month(*1..30),
108
108
  IceCube::Rule.daily.month_of_year(1).day_of_month(*2..31)
109
- ]
109
+ ])
110
110
  end
111
111
  end
112
112
  end
@@ -18,30 +18,30 @@ describe ScheduleAttributes::RuleParser::Month do
18
18
  let(:every_14th) { [n, n >> 1, n >> 2, n >> 3].map(&:to_time) }
19
19
 
20
20
  context 'no arguments', args: {} do
21
- it { should == IceCube::Rule.monthly }
22
- its_occurrences_until(3.months.from_now) { should == monthly }
21
+ it { is_expected.to eq(IceCube::Rule.monthly) }
22
+ its_occurrences_until(3.months.from_now) { is_expected.to eq(monthly) }
23
23
  end
24
24
 
25
25
  context 'start_date and interval arguments', args: {"start_date" => "2000-03-14", "interval" => "2"} do
26
- it { should == IceCube::Rule.monthly(2) }
27
- its_occurrences_until(6.months.from_now) { should == bimonthly }
26
+ it { is_expected.to eq(IceCube::Rule.monthly(2)) }
27
+ its_occurrences_until(6.months.from_now) { is_expected.to eq(bimonthly) }
28
28
  end
29
29
 
30
30
  context 'ordinal_unit and ordinal_day arguments', args: {"ordinal_unit" => "day", "ordinal_day" => "14"} do
31
- it { should == IceCube::Rule.monthly.day_of_month(14) }
32
- its_occurrences_until(4.months.from_now) { should == every_14th }
31
+ it { is_expected.to eq(IceCube::Rule.monthly.day_of_month(14)) }
32
+ its_occurrences_until(4.months.from_now) { is_expected.to eq(every_14th) }
33
33
  end
34
34
 
35
35
  context 'ordinal_unit, ordinal_week and tuesday arguments', args: {"ordinal_unit" => "week", "ordinal_week" => "2", "tuesday" => "1"} do
36
- it { should == IceCube::Rule.monthly.day_of_week(:tuesday => [2]) }
36
+ it { is_expected.to eq(IceCube::Rule.monthly.day_of_week(:tuesday => [2])) }
37
37
  end
38
38
 
39
39
  context 'ordinal_unit and ordinal_week arguments', args: {"ordinal_unit" => "week", "ordinal_week" => "2"} do
40
- it { should == IceCube::Rule.monthly.day_of_week(0=>(w=[2]), 1=>w, 2=>w, 3=>w, 4=>w, 5=>w, 6=>w) }
40
+ it { is_expected.to eq(IceCube::Rule.monthly.day_of_week(0=>(w=[2]), 1=>w, 2=>w, 3=>w, 4=>w, 5=>w, 6=>w)) }
41
41
  end
42
42
 
43
43
  context 'start_date and end_date arguments', args: {"start_date" => "2000-03-14", "end_date" => "2000-06-14"} do
44
- it { should == IceCube::Rule.monthly.until(Time.new(2000,6,14)) }
44
+ it { is_expected.to eq(IceCube::Rule.monthly.until(Time.new(2000,6,14))) }
45
45
  end
46
46
  end
47
47
  end
@@ -19,18 +19,18 @@ describe ScheduleAttributes::RuleParser::Week do
19
19
  subject { parser.rule }
20
20
 
21
21
  context 'no arguments', args: {} do
22
- it { should == IceCube::Rule.weekly }
23
- its_occurrences_until(5.weeks.from_now) { should == weekly }
22
+ it { is_expected.to eq(IceCube::Rule.weekly) }
23
+ its_occurrences_until(5.weeks.from_now) { is_expected.to eq(weekly) }
24
24
  end
25
25
 
26
26
  context 'interval argument', args: {"interval" => "2"} do
27
- it { should == IceCube::Rule.weekly(2) }
28
- its_occurrences_until(5.weeks.from_now) { should == every_2_weeks }
27
+ it { is_expected.to eq(IceCube::Rule.weekly(2)) }
28
+ its_occurrences_until(5.weeks.from_now) { is_expected.to eq(every_2_weeks) }
29
29
  end
30
30
 
31
31
  context 'several day name arguments', args: {"monday" => "0", "saturday" => "1", "sunday" => "1"} do
32
- it { should == IceCube::Rule.weekly.day(0,6) }
33
- its_occurrences_until(Date.today.beginning_of_week+3.weeks) { subject[-4..-1].should == weekends[-4..-1] }
32
+ it { is_expected.to eq(IceCube::Rule.weekly.day(0,6)) }
33
+ its_occurrences_until(Date.today.beginning_of_week+3.weeks) { expect(subject[-4..-1]).to eq weekends[-4..-1] }
34
34
  end
35
35
  end
36
36
  end
@@ -17,26 +17,26 @@ describe ScheduleAttributes::RuleParser::Year do
17
17
  subject { parser.rule }
18
18
 
19
19
  context 'no arguments', args: {} do
20
- it { should == IceCube::Rule.yearly }
21
- its_occurrences_until(4.years.from_now) { should == every_year }
20
+ it { is_expected.to eq(IceCube::Rule.yearly) }
21
+ its_occurrences_until(4.years.from_now) { is_expected.to eq(every_year) }
22
22
  end
23
23
 
24
24
  context 'interval argument', args: {"interval" => "2"} do
25
- it { should == IceCube::Rule.yearly(2) }
26
- its_occurrences_until(4.years.from_now) { should == every_2nd_year }
25
+ it { is_expected.to eq(IceCube::Rule.yearly(2)) }
26
+ its_occurrences_until(4.years.from_now) { is_expected.to eq(every_2nd_year) }
27
27
  end
28
28
 
29
29
  context 'start_date argument', args: {"start_date" => "2000-03-14"} do
30
- it { should == IceCube::Rule.yearly.month_of_year(3).day_of_month(14) }
30
+ it { is_expected.to eq(IceCube::Rule.yearly.month_of_year(3).day_of_month(14)) }
31
31
  end
32
32
 
33
33
  context 'start_date argument alt', args: {"start_date" => "2000-01-30"} do
34
- it { should == IceCube::Rule.yearly.month_of_year(1).day_of_month(30) }
34
+ it { is_expected.to eq(IceCube::Rule.yearly.month_of_year(1).day_of_month(30)) }
35
35
  end
36
36
 
37
37
  context 'start_date and end_date arguments', args: {"start_date" => "2000-03-14", "end_date" => "#{Date.current.year+4}-03-14"} do
38
- it { should == IceCube::Rule.yearly.month_of_year(3).day_of_month(14).until(Date.new(Date.current.year+4,3,14).to_time) }
39
- its_occurrences_until(10.years.from_now) { should == every_pi_day }
38
+ it { is_expected.to eq(IceCube::Rule.yearly.month_of_year(3).day_of_month(14).until(Date.new(Date.current.year+4,3,14).to_time)) }
39
+ its_occurrences_until(10.years.from_now) { is_expected.to eq(every_pi_day) }
40
40
  end
41
41
 
42
42
  context "ignoring yearly_start and end limits", args: {
@@ -46,8 +46,8 @@ describe ScheduleAttributes::RuleParser::Year do
46
46
  "yearly_end_month" => "5",
47
47
  "yearly_end_month_day" => "20"
48
48
  } do
49
- it { should == IceCube::Rule.yearly.month_of_year(3).day_of_month(14) }
50
- its_occurrences_until(Date.new(Date.current.year+4,12,31)) { should == every_pi_day }
49
+ it { is_expected.to eq(IceCube::Rule.yearly.month_of_year(3).day_of_month(14)) }
50
+ its_occurrences_until(Date.new(Date.current.year+4,12,31)) { is_expected.to eq(every_pi_day) }
51
51
  end
52
52
  end
53
53
  end
@@ -11,7 +11,7 @@ describe ScheduleAttributes::RuleParser do
11
11
  }. each do |key,parser_class|
12
12
 
13
13
  it "returns parser for #{key} interval units" do
14
- ScheduleAttributes::RuleParser[key].should == parser_class
14
+ expect(ScheduleAttributes::RuleParser[key]).to eq(parser_class)
15
15
  end
16
16
  end
17
17
  end
@@ -9,17 +9,17 @@ describe ScheduleAttributes::TimeHelpers do
9
9
  before { Time.zone = 'UTC' }
10
10
 
11
11
  it "returns a time from a date string" do
12
- subject.parse_in_zone("2000-12-31").should == Time.zone.parse("2000-12-31")
12
+ expect(subject.parse_in_zone("2000-12-31")).to eq(Time.zone.parse("2000-12-31"))
13
13
  end
14
14
 
15
15
  it "returns a time from a time" do
16
16
  local_offset = "-08:00"
17
17
  local_time = Time.new(2000,12,31,0,0,0,local_offset)
18
- subject.parse_in_zone(local_time).should == Time.zone.parse("2000-12-31 08:00:00")
18
+ expect(subject.parse_in_zone(local_time)).to eq(Time.zone.parse("2000-12-31 08:00:00"))
19
19
  end
20
20
 
21
21
  it "returns a time from a date" do
22
- subject.parse_in_zone(Date.new(2000,12,31)).should == Time.zone.parse("2000-12-31")
22
+ expect(subject.parse_in_zone(Date.new(2000,12,31))).to eq(Time.zone.parse("2000-12-31"))
23
23
  end
24
24
  end
25
25
 
@@ -27,11 +27,11 @@ describe ScheduleAttributes::TimeHelpers do
27
27
  before { Time.zone = nil }
28
28
 
29
29
  it "returns a time from a date string" do
30
- subject.parse_in_zone("2000-12-31").should == Time.parse("2000-12-31")
30
+ expect(subject.parse_in_zone("2000-12-31")).to eq(Time.parse("2000-12-31"))
31
31
  end
32
32
 
33
33
  it "returns a time from a time" do
34
- subject.parse_in_zone(Time.new(2000,12,31)).should == Time.parse("2000-12-31")
34
+ expect(subject.parse_in_zone(Time.new(2000,12,31))).to eq(Time.parse("2000-12-31"))
35
35
  end
36
36
  end
37
37
 
@@ -7,11 +7,11 @@ describe ScheduledModel do
7
7
  subject(:schedule) { ScheduledModel.new.schedule }
8
8
 
9
9
  it "should default to a daily schedule" do
10
- schedule.should be_a(IceCube::Schedule)
11
- schedule.rtimes.should == []
12
- schedule.start_time.should == Date.today.to_time
13
- schedule.end_time.should be nil
14
- schedule.rrules.should == [IceCube::Rule.daily]
10
+ expect(schedule).to be_a(IceCube::Schedule)
11
+ expect(schedule.rtimes).to eq([])
12
+ expect(schedule.start_time).to eq(Date.today.to_time)
13
+ expect(schedule.end_time).to be nil
14
+ expect(schedule.rrules).to eq([IceCube::Rule.daily])
15
15
  end
16
16
  end
17
17
 
@@ -21,80 +21,80 @@ describe ScheduledModel do
21
21
  subject(:schedule) { scheduled_model.schedule }
22
22
 
23
23
  context args: {repeat: '0', date: '1-1-1985', interval: '5 (ignore this)'} do
24
- it { subject.start_time.should == Time.new(1985,1,1) }
25
- it { subject.all_occurrences.should == [Time.new(1985,1,1)] }
26
- it { subject.rrules.should be_blank }
24
+ it { expect(subject.start_time).to eq(Time.new(1985,1,1)) }
25
+ it { expect(subject.all_occurrences).to eq([Time.new(1985,1,1)]) }
26
+ it { expect(subject.rrules).to be_blank }
27
27
  end
28
28
 
29
29
  context args: {repeat: '0', dates: ['1-1-1985', '31-12-1985'], interval: '5 (ignore this)'} do
30
- it { subject.start_time.should == Time.new(1985,1,1) }
31
- it { subject.all_occurrences.should == [Time.new(1985,1,1), Time.new(1985,12,31)] }
32
- it { subject.rrules.should be_blank }
30
+ it { expect(subject.start_time).to eq(Time.new(1985,1,1)) }
31
+ it { expect(subject.all_occurrences).to eq([Time.new(1985,1,1), Time.new(1985,12,31)]) }
32
+ it { expect(subject.rrules).to be_blank }
33
33
  end
34
34
 
35
35
  context args: {repeat: '0', dates: ['1-1-1985', '31-12-1985'], start_time: '12:00', end_time: '14:00', interval: '5 (ignore this)'} do
36
- it { subject.start_time.should == Time.new(1985,1,1,12,0) }
37
- it { subject.duration.should == 7200 }
38
- it { subject.all_occurrences.should == [Time.new(1985,1,1,12,0), Time.new(1985,12,31,12,0)] }
39
- it { subject.rrules.should be_blank }
40
- specify { schedule.occurring_between?(helpers.parse_in_zone('1985-1-1 12:00'), helpers.parse_in_zone('1985-6-25 14:00')).should be_truthy }
41
- specify { schedule.occurs_at?(helpers.parse_in_zone('1985-1-1 12:00')).should be_truthy }
42
- specify { schedule.occurs_at?(helpers.parse_in_zone('1985-6-6 15:00')).should be_falsey }
36
+ it { expect(subject.start_time).to eq(Time.new(1985,1,1,12,0)) }
37
+ it { expect(subject.duration).to eq(7200) }
38
+ it { expect(subject.all_occurrences).to eq([Time.new(1985,1,1,12,0), Time.new(1985,12,31,12,0)]) }
39
+ it { expect(subject.rrules).to be_blank }
40
+ specify { expect(schedule.occurring_between?(helpers.parse_in_zone('1985-1-1 12:00'), helpers.parse_in_zone('1985-6-25 14:00'))).to be_truthy }
41
+ specify { expect(schedule.occurs_at?(helpers.parse_in_zone('1985-1-1 12:00'))).to be_truthy }
42
+ specify { expect(schedule.occurs_at?(helpers.parse_in_zone('1985-6-6 15:00'))).to be_falsey }
43
43
  end
44
44
 
45
45
  context args: {repeat: '1'} do
46
- it { subject.start_time.should == Date.today.to_time }
47
- it { subject.rrules.should == [IceCube::Rule.daily] }
46
+ it { expect(subject.start_time).to eq(Date.today.to_time) }
47
+ it { expect(subject.rrules).to eq([IceCube::Rule.daily]) }
48
48
  end
49
49
 
50
50
  context args: {repeat: '1', start_date: '1-1-1985', interval_unit: 'day', interval: '3'} do
51
- it { subject.start_time.should == Date.new(1985,1,1).to_time }
52
- it { subject.rrules.should == [IceCube::Rule.daily(3)] }
53
- specify { schedule.first(3).should == [Date.civil(1985,1,1), Date.civil(1985,1,4), Date.civil(1985,1,7)].map(&:to_time) }
51
+ it { expect(subject.start_time).to eq(Date.new(1985,1,1).to_time) }
52
+ it { expect(subject.rrules).to eq([IceCube::Rule.daily(3)]) }
53
+ specify { expect(schedule.first(3)).to eq([Date.civil(1985,1,1), Date.civil(1985,1,4), Date.civil(1985,1,7)].map(&:to_time)) }
54
54
  end
55
55
 
56
56
  context args: {repeat: "1", start_date: "1-1-1985", interval_unit: "day", interval: "3", end_date: "29-12-1985", ends: "eventually"} do
57
- it { subject.start_time.should == Date.new(1985,1,1).to_time }
57
+ it { expect(subject.start_time).to eq(Date.new(1985,1,1).to_time) }
58
58
  # Rails 4.1 removes Date.current.to_time_in_current_zone in favour of Date.in_time_zone
59
59
  it do
60
60
  if Date.current.respond_to?(:in_time_zone)
61
- subject.rrules.should == [ IceCube::Rule.daily(3).until(Date.new(1985,12,29).in_time_zone) ]
61
+ expect(subject.rrules).to eq([ IceCube::Rule.daily(3).until(Date.new(1985,12,29).in_time_zone) ])
62
62
  else
63
- subject.rrules.should == [ IceCube::Rule.daily(3).until(Date.new(1985,12,29).to_time_in_current_zone) ]
63
+ expect(subject.rrules).to eq([ IceCube::Rule.daily(3).until(Date.new(1985,12,29).to_time_in_current_zone) ])
64
64
  end
65
65
  end
66
- specify { schedule.first(3).should == [Date.civil(1985,1,1), Date.civil(1985,1,4), Date.civil(1985,1,7)].map(&:to_time) }
66
+ specify { expect(schedule.first(3)).to eq([Date.civil(1985,1,1), Date.civil(1985,1,4), Date.civil(1985,1,7)].map(&:to_time)) }
67
67
  end
68
68
 
69
69
  context args: {repeat: '1', start_date: '1-1-1985', interval_unit: 'day', interval: '3', until_date: '29-12-1985', ends: 'never'} do
70
- it { subject.start_time.should == Date.new(1985,1,1).to_time }
71
- it { subject.rrules.should == [IceCube::Rule.daily(3)] }
72
- specify { schedule.first(3).should == [Date.civil(1985,1,1), Date.civil(1985,1,4), Date.civil(1985,1,7)].map(&:to_time) }
70
+ it { expect(subject.start_time).to eq(Date.new(1985,1,1).to_time) }
71
+ it { expect(subject.rrules).to eq([IceCube::Rule.daily(3)]) }
72
+ specify { expect(schedule.first(3)).to eq([Date.civil(1985,1,1), Date.civil(1985,1,4), Date.civil(1985,1,7)].map(&:to_time)) }
73
73
  end
74
74
 
75
75
  context args: {repeat: '1', start_date: '1-1-1985', interval_unit: 'week', interval: '3', monday: '1', wednesday: '1', friday: '1'} do
76
- it { subject.start_time.should == Date.new(1985,1,1).to_time }
77
- it { subject.rrules.should == [IceCube::Rule.weekly(3).day(:monday, :wednesday, :friday)] }
78
- specify { schedule.occurs_at?(helpers.parse_in_zone('1985-1-2')).should be_truthy }
79
- specify { schedule.occurs_at?(helpers.parse_in_zone('1985-1-4')).should be_truthy }
80
- specify { schedule.occurs_at?(helpers.parse_in_zone('1985-1-7')).should be_falsey }
81
- specify { schedule.occurs_at?(helpers.parse_in_zone('1985-1-21')).should be_truthy }
76
+ it { expect(subject.start_time).to eq(Date.new(1985,1,1).to_time) }
77
+ it { expect(subject.rrules).to eq([IceCube::Rule.weekly(3).day(:monday, :wednesday, :friday)]) }
78
+ specify { expect(schedule.occurs_at?(helpers.parse_in_zone('1985-1-2'))).to be_truthy }
79
+ specify { expect(schedule.occurs_at?(helpers.parse_in_zone('1985-1-4'))).to be_truthy }
80
+ specify { expect(schedule.occurs_at?(helpers.parse_in_zone('1985-1-7'))).to be_falsey }
81
+ specify { expect(schedule.occurs_at?(helpers.parse_in_zone('1985-1-21'))).to be_truthy }
82
82
  end
83
83
 
84
84
  context args: {repeat: '1', start_date: '1-1-1985', interval_unit: 'day'} do
85
- it { subject.rrules.should == [IceCube::Rule.daily(1)] }
85
+ it { expect(subject.rrules).to eq([IceCube::Rule.daily(1)]) }
86
86
  end
87
87
 
88
88
  context args: {repeat: '1', start_date: '1-1-1985', interval_unit: 'year'} do
89
- it { subject.start_time.should == Date.new(1985,1,1).to_time }
90
- it { subject.rrules.should == [IceCube::Rule.yearly.day_of_month(1).month_of_year(1)] }
91
- specify { schedule.first(3).should == [Date.civil(1985,1,1), Date.civil(1986,1,1), Date.civil(1987,1,1)].map(&:to_time) }
89
+ it { expect(subject.start_time).to eq(Date.new(1985,1,1).to_time) }
90
+ it { expect(subject.rrules).to eq([IceCube::Rule.yearly.day_of_month(1).month_of_year(1)]) }
91
+ specify { expect(schedule.first(3)).to eq([Date.civil(1985,1,1), Date.civil(1986,1,1), Date.civil(1987,1,1)].map(&:to_time)) }
92
92
  end
93
93
 
94
94
  context args: {repeat: '1', interval_unit: 'day', start_date: '2012-09-27', yearly_start_month: '12', yearly_start_month_day: '1', yearly_end_month: '4', yearly_end_month_day: '21'} do
95
- it { subject.start_time.should == Time.new(2012,9,27) }
96
- it { subject.rrules.should == [IceCube::Rule.daily.month_of_year(12,1,2,3,4)] }
97
- it { subject.exrules.should == [IceCube::Rule.daily.month_of_year(4).day_of_month(*22..31)] }
95
+ it { expect(subject.start_time).to eq(Time.new(2012,9,27)) }
96
+ it { expect(subject.rrules).to eq([IceCube::Rule.daily.month_of_year(12,1,2,3,4)]) }
97
+ it { expect(subject.exrules).to eq([IceCube::Rule.daily.month_of_year(4).day_of_month(*22..31)]) }
98
98
  end
99
99
 
100
100
  context "all_day", pending: "Work in progress"
@@ -104,7 +104,7 @@ describe ScheduledModel do
104
104
  let(:scheduled_model) { ScheduledModel.new.tap { |m| m.schedule_attributes = RSpec.current_example.metadata[:args] } }
105
105
  subject { scheduled_model }
106
106
 
107
- it { subject.schedule.should == IceCube::Schedule.new(Date.new(1985,1,1).to_time).tap { |s| s.add_recurrence_rule IceCube::Rule.daily(3) } }
107
+ it { expect(subject.schedule).to eq(IceCube::Schedule.new(Date.new(1985,1,1).to_time).tap { |s| s.add_recurrence_rule IceCube::Rule.daily(3) }) }
108
108
  end
109
109
 
110
110
  end
@@ -117,25 +117,25 @@ describe ScheduledModel do
117
117
 
118
118
  context "for a single date" do
119
119
  before { schedule.add_recurrence_time(Date.tomorrow.to_time) }
120
- it { should == OpenStruct.new(repeat: 0, interval: 1, date: Date.tomorrow, dates: [Date.tomorrow], start_date: Date.today, all_day: true) }
121
- it { subject.date.should be_a(Date) }
120
+ it { is_expected.to eq(OpenStruct.new(repeat: 0, interval: 1, date: Date.tomorrow, dates: [Date.tomorrow], start_date: Date.today, all_day: true)) }
121
+ it { expect(subject.date).to be_a(Date) }
122
122
  end
123
123
 
124
124
  context "when it repeats daily" do
125
125
  before do
126
126
  schedule.add_recurrence_rule(IceCube::Rule.daily(4))
127
127
  end
128
- it { should == OpenStruct.new(repeat: 1, start_date: Date.tomorrow, interval_unit: 'day', interval: 4, ends: 'never', date: Date.today, all_day: true) }
129
- it { subject.start_date.should be_a(Date) }
128
+ it { is_expected.to eq(OpenStruct.new(repeat: 1, start_date: Date.tomorrow, interval_unit: 'day', interval: 4, ends: 'never', date: Date.today, all_day: true)) }
129
+ it { expect(subject.start_date).to be_a(Date) }
130
130
  end
131
131
 
132
132
  context "when it repeats with an end date" do
133
133
  before do
134
134
  schedule.add_recurrence_rule(IceCube::Rule.daily(4).until((Date.today+10).to_time))
135
135
  end
136
- it { should == OpenStruct.new(repeat: 1, start_date: Date.tomorrow, interval_unit: 'day', interval: 4, ends: 'eventually', end_date: Date.today+10, date: Date.today, all_day: true) }
137
- it { subject.start_date.should be_a(Date) }
138
- it { subject.end_date.should be_a(Date) }
136
+ it { is_expected.to eq(OpenStruct.new(repeat: 1, start_date: Date.tomorrow, interval_unit: 'day', interval: 4, ends: 'eventually', end_date: Date.today+10, date: Date.today, all_day: true)) }
137
+ it { expect(subject.start_date).to be_a(Date) }
138
+ it { expect(subject.end_date).to be_a(Date) }
139
139
  end
140
140
 
141
141
  context "when it repeats weekly" do
@@ -144,7 +144,7 @@ describe ScheduledModel do
144
144
  schedule.add_recurrence_rule(IceCube::Rule.weekly(4).day(:monday, :wednesday, :friday))
145
145
  end
146
146
  it do
147
- should == OpenStruct.new(
147
+ is_expected.to eq(OpenStruct.new(
148
148
  :repeat => 1,
149
149
  :start_date => Date.tomorrow,
150
150
  :interval_unit => 'week',
@@ -156,7 +156,7 @@ describe ScheduledModel do
156
156
  :all_day => true,
157
157
 
158
158
  :date => Date.today #for the form
159
- )
159
+ ))
160
160
  end
161
161
  end
162
162
 
@@ -166,7 +166,7 @@ describe ScheduledModel do
166
166
  schedule.add_recurrence_rule(IceCube::Rule.yearly)
167
167
  end
168
168
  it do
169
- should == OpenStruct.new(
169
+ is_expected.to eq(OpenStruct.new(
170
170
  :repeat => 1,
171
171
  :start_date => Date.tomorrow,
172
172
  :interval_unit => 'year',
@@ -175,7 +175,7 @@ describe ScheduledModel do
175
175
  :all_day => true,
176
176
 
177
177
  :date => Date.today #for the form
178
- )
178
+ ))
179
179
  end
180
180
  end
181
181
 
@@ -183,37 +183,37 @@ describe ScheduledModel do
183
183
  it "should have yearly start and end months" do
184
184
  schedule.add_recurrence_rule(IceCube::Rule.daily.month_of_year(12,1,2))
185
185
 
186
- subject.yearly_start_month.should == 12
187
- subject.yearly_end_month.should == 2
186
+ expect(subject.yearly_start_month).to eq(12)
187
+ expect(subject.yearly_end_month).to eq(2)
188
188
  end
189
189
 
190
190
  it "should have a yearly start date" do
191
191
  schedule.add_recurrence_rule(IceCube::Rule.daily.month_of_year(11,12,1,2))
192
192
  schedule.add_exception_rule(IceCube::Rule.daily.month_of_year(11).day_of_month(*1..6))
193
193
 
194
- subject.yearly_start_month.should == 11
195
- subject.yearly_start_month_day.should == 7
194
+ expect(subject.yearly_start_month).to eq(11)
195
+ expect(subject.yearly_start_month_day).to eq(7)
196
196
  end
197
197
 
198
198
  it "should have a yearly end date" do
199
199
  schedule.add_recurrence_rule(IceCube::Rule.daily.month_of_year(1,2,3))
200
200
  schedule.add_exception_rule(IceCube::Rule.daily.month_of_year(3).day_of_month(*26..31))
201
201
 
202
- subject.yearly_end_month.should == 3
203
- subject.yearly_end_month_day.should == 25
202
+ expect(subject.yearly_end_month).to eq(3)
203
+ expect(subject.yearly_end_month_day).to eq(25)
204
204
  end
205
205
 
206
206
  it "should have no yearly start day for months only" do
207
207
  schedule.add_recurrence_rule(IceCube::Rule.daily.month_of_year(1,2,3))
208
208
 
209
- subject.yearly_start_month_day.should be_nil
209
+ expect(subject.yearly_start_month_day).to be_nil
210
210
  end
211
211
 
212
212
  it "should have a yearly start day on the first when end day is set" do
213
213
  schedule.add_recurrence_rule(IceCube::Rule.daily.month_of_year(1,2,3))
214
214
  schedule.add_exception_rule(IceCube::Rule.daily.month_of_year(3).day_of_month(*26..31))
215
215
 
216
- subject.yearly_start_month_day.should == 1
216
+ expect(subject.yearly_start_month_day).to eq(1)
217
217
  end
218
218
  end
219
219