Skip to content

Commit b6a2d96

Browse files
authored
Merge pull request ice-cube-ruby#374 from seejohnrun/upgrade_rspec
Upgrade rspec via transpec
2 parents 021497e + 9a983ac commit b6a2d96

31 files changed

+906
-906
lines changed

ice_cube.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ Gem::Specification.new do |s|
1818
s.rubyforge_project = "ice-cube"
1919

2020
s.add_development_dependency('rake')
21-
s.add_development_dependency('rspec', '~> 2.12.0')
21+
s.add_development_dependency('rspec')
2222
end

spec/examples/_no_active_support_spec.rb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@
44
# ActiveSupport gets loaded by other specs.
55

66
module IceCube
7-
describe TimeUtil, :if_active_support_time => false do
7+
describe TimeUtil do
88

99
before do
10-
Time.any_instance.should_receive(:respond_to?).with(:time_zone).
11-
at_least(1).times.and_return(false)
10+
raise 'ActiveSupport should not be loaded' if defined?(ActiveSuppport)
1211
end
1312

1413
WORLD_TIME_ZONES.each do |zone|
@@ -17,14 +16,14 @@ module IceCube
1716
it 'should be able to calculate end of dates without active_support' do
1817
date = Date.new(2011, 1, 1)
1918
end_of_date = Time.local(2011, 1, 1, 23, 59, 59)
20-
TimeUtil.end_of_date(date).to_s.should == end_of_date.to_s
19+
expect(TimeUtil.end_of_date(date).to_s).to eq(end_of_date.to_s)
2120
end
2221

2322
it 'should be able to calculate beginning of dates without active_support' do
2423
date = Date.new(2011, 1, 1)
2524
res = [ TimeUtil.beginning_of_date(date), Time.local(2011, 1, 1, 0, 0, 0) ]
2625
res.all? { |r| r.class.name == 'Time' }
27-
res.map(&:to_s).uniq.size.should == 1
26+
expect(res.map(&:to_s).uniq.size).to eq(1)
2827
end
2928

3029
it 'should serialize to hash without error' do

spec/examples/active_support_spec.rb

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,64 +19,64 @@ module IceCube
1919
it 'works with a single recurrence time starting from a TimeWithZone' do
2020
schedule = Schedule.new(t0 = Time.zone.parse("2010-02-05 05:00:00"))
2121
schedule.add_recurrence_time t0
22-
schedule.all_occurrences.should == [t0]
22+
expect(schedule.all_occurrences).to eq([t0])
2323
end
2424

2525
it 'works with a monthly recurrence rule starting from a TimeWithZone' do
2626
schedule = Schedule.new(t0 = Time.zone.parse("2010-02-05 05:00:00"))
2727
schedule.add_recurrence_rule Rule.monthly
28-
schedule.first(10).should == [
28+
expect(schedule.first(10)).to eq([
2929
Time.zone.parse("2010-02-05 05:00"), Time.zone.parse("2010-03-05 05:00"),
3030
Time.zone.parse("2010-04-05 05:00"), Time.zone.parse("2010-05-05 05:00"),
3131
Time.zone.parse("2010-06-05 05:00"), Time.zone.parse("2010-07-05 05:00"),
3232
Time.zone.parse("2010-08-05 05:00"), Time.zone.parse("2010-09-05 05:00"),
3333
Time.zone.parse("2010-10-05 05:00"), Time.zone.parse("2010-11-05 05:00")
34-
]
34+
])
3535
end
3636

3737
it 'works with a monthly schedule converting to UTC across DST' do
3838
Time.zone = 'Eastern Time (US & Canada)'
3939
schedule = Schedule.new(t0 = Time.zone.parse("2009-10-28 19:30:00"))
4040
schedule.add_recurrence_rule Rule.monthly
41-
schedule.first(7).map { |d| d.getutc }.should == [
41+
expect(schedule.first(7).map { |d| d.getutc }).to eq([
4242
Time.utc(2009, 10, 28, 23, 30, 0), Time.utc(2009, 11, 29, 0, 30, 0),
4343
Time.utc(2009, 12, 29, 0, 30, 0), Time.utc(2010, 1, 29, 0, 30, 0),
4444
Time.utc(2010, 3, 1, 0, 30, 0), Time.utc(2010, 3, 28, 23, 30, 0),
4545
Time.utc(2010, 4, 28, 23, 30, 0)
46-
]
46+
])
4747
end
4848

4949
it 'can round trip TimeWithZone to YAML' do
5050
schedule = Schedule.new(t0 = Time.zone.parse("2010-02-05 05:00:00"))
5151
schedule.add_recurrence_time t0
5252
schedule2 = Schedule.from_yaml(schedule.to_yaml)
53-
schedule.all_occurrences.should == schedule2.all_occurrences
53+
expect(schedule.all_occurrences).to eq(schedule2.all_occurrences)
5454
end
5555

5656
it 'uses local zone from start time to determine occurs_on? from the beginning of day' do
5757
schedule = Schedule.new(t0 = Time.local(2009, 2, 7, 23, 59, 59))
5858
schedule.add_recurrence_rule Rule.daily
59-
schedule.occurs_on?(Date.new(2009, 2, 7)).should be_true
59+
expect(schedule.occurs_on?(Date.new(2009, 2, 7))).to be_truthy
6060
end
6161

6262
it 'uses local zone from start time to determine occurs_on? to the end of day' do
6363
schedule = Schedule.new(t0 = Time.local(2009, 2, 7, 0, 0, 0))
6464
schedule.add_recurrence_rule Rule.daily
65-
schedule.occurs_on?(Date.new(2009, 2, 7)).should be_true
65+
expect(schedule.occurs_on?(Date.new(2009, 2, 7))).to be_truthy
6666
end
6767

6868
it 'should use the correct zone for next_occurrences before start_time' do
6969
future_time = Time.zone.now.beginning_of_day + IceCube::ONE_DAY
7070
schedule = Schedule.new(future_time)
7171
schedule.add_recurrence_rule Rule.daily
72-
schedule.next_occurrence.time_zone.should == schedule.start_time.time_zone
72+
expect(schedule.next_occurrence.time_zone).to eq(schedule.start_time.time_zone)
7373
end
7474

7575
it 'should use the correct zone for next_occurrences after start_time' do
7676
past_time = Time.zone.now.beginning_of_day
7777
schedule = Schedule.new(past_time)
7878
schedule.add_recurrence_rule Rule.daily
79-
schedule.next_occurrence.time_zone.should == schedule.start_time.time_zone
79+
expect(schedule.next_occurrence.time_zone).to eq(schedule.start_time.time_zone)
8080
end
8181

8282
describe 'querying with time arguments for a different zone' do
@@ -92,69 +92,69 @@ module IceCube
9292

9393
it 'uses schedule zone for next_occurrence' do
9494
next_occurrence = schedule.next_occurrence(reference_time)
95-
next_occurrence.should == Time.utc(2013, 1, 2)
96-
next_occurrence.time_zone.should == schedule.start_time.time_zone
95+
expect(next_occurrence).to eq(Time.utc(2013, 1, 2))
96+
expect(next_occurrence.time_zone).to eq(schedule.start_time.time_zone)
9797
end
9898

9999
it 'uses schedule zone for next_occurrences' do
100100
next_occurrences = schedule.next_occurrences(2, reference_time)
101-
next_occurrences.should == [Time.utc(2013, 1, 2), Time.utc(2013, 1, 3)]
101+
expect(next_occurrences).to eq([Time.utc(2013, 1, 2), Time.utc(2013, 1, 3)])
102102
next_occurrences.each do |t|
103-
t.time_zone.should == schedule.start_time.time_zone
103+
expect(t.time_zone).to eq(schedule.start_time.time_zone)
104104
end
105105
end
106106

107107
it 'uses schedule zone for remaining_occurrences' do
108108
remaining_occurrences = schedule.remaining_occurrences(reference_time + IceCube::ONE_DAY)
109-
remaining_occurrences.should == [Time.utc(2013, 1, 2), Time.utc(2013, 1, 3)]
109+
expect(remaining_occurrences).to eq([Time.utc(2013, 1, 2), Time.utc(2013, 1, 3)])
110110
remaining_occurrences.each do |t|
111-
t.time_zone.should == schedule.start_time.time_zone
111+
expect(t.time_zone).to eq(schedule.start_time.time_zone)
112112
end
113113
end
114114

115115
it 'uses schedule zone for occurrences' do
116116
occurrences = schedule.occurrences(reference_time + IceCube::ONE_DAY)
117-
occurrences.should == [Time.utc(2013, 1, 1), Time.utc(2013, 1, 2)]
117+
expect(occurrences).to eq([Time.utc(2013, 1, 1), Time.utc(2013, 1, 2)])
118118
occurrences.each do |t|
119-
t.time_zone.should == schedule.start_time.time_zone
119+
expect(t.time_zone).to eq(schedule.start_time.time_zone)
120120
end
121121
end
122122

123123
it 'uses schedule zone for occurrences_between' do
124124
occurrences_between = schedule.occurrences_between(reference_time, reference_time + IceCube::ONE_DAY)
125-
occurrences_between.should == [Time.utc(2013, 1, 1), Time.utc(2013, 1, 2)]
125+
expect(occurrences_between).to eq([Time.utc(2013, 1, 1), Time.utc(2013, 1, 2)])
126126
occurrences_between.each do |t|
127-
t.time_zone.should == schedule.start_time.time_zone
127+
expect(t.time_zone).to eq(schedule.start_time.time_zone)
128128
end
129129
end
130130

131131
it "uses schedule zone for occurrences_between with a rule terminated by #count" do
132132
utc = Time.utc(2013, 1, 1).in_time_zone('UTC')
133133
s = Schedule.new(utc) { |s| s.add_recurrence_rule Rule.daily.count(3) }
134134
occurrences_between = s.occurrences_between(reference_time, reference_time + IceCube::ONE_DAY)
135-
occurrences_between.should == [Time.utc(2013, 1, 1), Time.utc(2013, 1, 2)]
135+
expect(occurrences_between).to eq([Time.utc(2013, 1, 1), Time.utc(2013, 1, 2)])
136136
occurrences_between.each do |t|
137-
t.time_zone.should == schedule.start_time.time_zone
137+
expect(t.time_zone).to eq(schedule.start_time.time_zone)
138138
end
139139
end
140140

141141
it "uses schedule zone for occurrences_between with a rule terminated by #until" do
142142
utc = Time.utc(2013, 1, 1).in_time_zone('UTC')
143143
s = Schedule.new(utc) { |s| s.add_recurrence_rule Rule.daily.until(utc.advance(:days => 3)) }
144144
occurrences_between = s.occurrences_between(reference_time, reference_time + IceCube::ONE_DAY)
145-
occurrences_between.should == [Time.utc(2013, 1, 1), Time.utc(2013, 1, 2)]
145+
expect(occurrences_between).to eq([Time.utc(2013, 1, 1), Time.utc(2013, 1, 2)])
146146
occurrences_between.each do |t|
147-
t.time_zone.should == schedule.start_time.time_zone
147+
expect(t.time_zone).to eq(schedule.start_time.time_zone)
148148
end
149149
end
150150

151151
it "uses schedule zone for occurrences_between with an unterminated rule" do
152152
utc = Time.utc(2013, 1, 1).in_time_zone('UTC')
153153
s = Schedule.new(utc) { |s| s.add_recurrence_rule Rule.daily }
154154
occurrences_between = s.occurrences_between(reference_time, reference_time + IceCube::ONE_DAY)
155-
occurrences_between.should == [Time.utc(2013, 1, 1), Time.utc(2013, 1, 2)]
155+
expect(occurrences_between).to eq([Time.utc(2013, 1, 1), Time.utc(2013, 1, 2)])
156156
occurrences_between.each do |t|
157-
t.time_zone.should == schedule.start_time.time_zone
157+
expect(t.time_zone).to eq(schedule.start_time.time_zone)
158158
end
159159
end
160160

@@ -169,7 +169,7 @@ module IceCube
169169
occurrence = Occurrence.new(start_time)
170170

171171
difference = (start_time + 60) - occurrence
172-
difference.should == 60
172+
expect(difference).to eq(60)
173173
end
174174

175175
end

spec/examples/daily_rule_spec.rb

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ module IceCube
44
describe DailyRule, 'interval validation' do
55
it 'converts a string integer to an actual int when using the interval method' do
66
rule = Rule.daily.interval("2")
7-
rule.validations_for(:interval).first.interval.should == 2
7+
expect(rule.validations_for(:interval).first.interval).to eq(2)
88
end
99

1010
it 'converts a string integer to an actual int when using the initializer' do
1111
rule = Rule.daily("3")
12-
rule.validations_for(:interval).first.interval.should == 3
12+
expect(rule.validations_for(:interval).first.interval).to eq(3)
1313
end
1414

1515
it 'raises an argument error when a bad value is passed using the interval method' do
@@ -27,36 +27,36 @@ module IceCube
2727

2828
describe DailyRule do
2929

30-
context :system_time_zone => 'America/Vancouver' do
30+
describe 'in Vancouver time', :system_time_zone => 'America/Vancouver' do
3131

3232
it 'should include nearest time in DST start hour' do
3333
schedule = Schedule.new(t0 = Time.local(2013, 3, 9, 2, 30, 0))
3434
schedule.add_recurrence_rule Rule.daily
35-
schedule.first(3).should == [
35+
expect(schedule.first(3)).to eq([
3636
Time.local(2013, 3, 9, 2, 30, 0), # -0800
3737
Time.local(2013, 3, 10, 3, 30, 0), # -0700
3838
Time.local(2013, 3, 11, 2, 30, 0) # -0700
39-
]
39+
])
4040
end
4141

4242
it 'should not skip times in DST end hour' do
4343
schedule = Schedule.new(t0 = Time.local(2013, 11, 2, 2, 30, 0))
4444
schedule.add_recurrence_rule Rule.daily
45-
schedule.first(3).should == [
45+
expect(schedule.first(3)).to eq([
4646
Time.local(2013, 11, 2, 2, 30, 0), # -0700
4747
Time.local(2013, 11, 3, 2, 30, 0), # -0800
4848
Time.local(2013, 11, 4, 2, 30, 0) # -0800
49-
]
49+
])
5050
end
5151

5252
it 'should include nearest time to DST start when locking hour_of_day' do
5353
schedule = Schedule.new(t0 = Time.local(2013, 3, 9, 2, 0, 0))
5454
schedule.add_recurrence_rule Rule.daily.hour_of_day(2)
55-
schedule.first(3).should == [
55+
expect(schedule.first(3)).to eq([
5656
Time.local(2013, 3, 9, 2, 0, 0), # -0800
5757
Time.local(2013, 3, 10, 3, 0, 0), # -0700
5858
Time.local(2013, 3, 11, 2, 0, 0) # -0700
59-
]
59+
])
6060
end
6161

6262
end
@@ -65,45 +65,45 @@ module IceCube
6565
schedule = double(start_time: t0 = Time.now)
6666
rule = Rule.daily(7)
6767
rule.interval(5)
68-
rule.next_time(t0 + 1, schedule, nil).should == t0 + 5 * ONE_DAY
68+
expect(rule.next_time(t0 + 1, schedule, nil)).to eq(t0 + 5 * ONE_DAY)
6969
end
7070

7171
it 'should produce the correct days for @interval = 1' do
7272
schedule = Schedule.new(t0 = Time.now)
7373
schedule.add_recurrence_rule Rule.daily
7474
#check assumption
7575
times = schedule.occurrences(t0 + 2 * ONE_DAY)
76-
times.size.should == 3
77-
times.should == [t0, t0 + ONE_DAY, t0 + 2 * ONE_DAY]
76+
expect(times.size).to eq(3)
77+
expect(times).to eq([t0, t0 + ONE_DAY, t0 + 2 * ONE_DAY])
7878
end
7979

8080
it 'should produce the correct days for @interval = 2' do
8181
schedule = Schedule.new(t0 = Time.now)
8282
schedule.add_recurrence_rule Rule.daily(2)
8383
#check assumption (3) -- (1) 2 (3) 4 (5) 6
8484
times = schedule.occurrences(t0 + 5 * ONE_DAY)
85-
times.size.should == 3
86-
times.should == [t0, t0 + 2 * ONE_DAY, t0 + 4 * ONE_DAY]
85+
expect(times.size).to eq(3)
86+
expect(times).to eq([t0, t0 + 2 * ONE_DAY, t0 + 4 * ONE_DAY])
8787
end
8888

8989
it 'should produce the correct days for @interval = 2 when crossing into a new year' do
9090
schedule = Schedule.new(t0 = Time.utc(2011, 12, 29))
9191
schedule.add_recurrence_rule Rule.daily(2)
9292
#check assumption (3) -- (1) 2 (3) 4 (5) 6
9393
times = schedule.occurrences(t0 + 5 * ONE_DAY)
94-
times.size.should == 3
95-
times.should == [t0, t0 + 2 * ONE_DAY, t0 + 4 * ONE_DAY]
94+
expect(times.size).to eq(3)
95+
expect(times).to eq([t0, t0 + 2 * ONE_DAY, t0 + 4 * ONE_DAY])
9696
end
9797

9898
it 'should produce the correct days for interval of 4 day with hour and minute of day set' do
9999
schedule = Schedule.new(t0 = Time.local(2010, 3, 1))
100100
schedule.add_recurrence_rule Rule.daily(4).hour_of_day(5).minute_of_hour(45)
101101
#check assumption 2 -- 1 (2) (3) (4) 5 (6)
102102
times = schedule.occurrences(t0 + 5 * ONE_DAY)
103-
times.should == [
103+
expect(times).to eq([
104104
t0 + 5 * ONE_HOUR + 45 * ONE_MINUTE,
105105
t0 + 4 * ONE_DAY + 5 * ONE_HOUR + 45 * ONE_MINUTE
106-
]
106+
])
107107
end
108108

109109
end

0 commit comments

Comments
 (0)