Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #111 from forrest/spec_refactoring

Minor Cleanup
  • Loading branch information...
commit 96265765728d3d3aa1a7a785580293e26ca17c4e 2 parents b2f0db1 + 5674c69
@seejohnrun authored
View
4 Rakefile
@@ -1,6 +1,6 @@
require 'rspec/core/rake_task'
require File.dirname(__FILE__) + '/lib/ice_cube/version'
-
+
task :build => :test do
system "gem build ice_cube.gemspec"
end
@@ -12,7 +12,7 @@ task :release => :build do
# push the gem
system "gem push ice_cube-#{IceCube::VERSION}.gem"
end
-
+
RSpec::Core::RakeTask.new(:test) do |t|
t.pattern = 'spec/**/*_spec.rb'
fail_on_error = true # be explicit
View
4 ice_cube.gemspec
@@ -1,8 +1,8 @@
require File.dirname(__FILE__) + '/lib/ice_cube/version'
spec = Gem::Specification.new do |s|
-
- s.name = 'ice_cube'
+
+ s.name = 'ice_cube'
s.author = 'John Crepezzi'
s.add_development_dependency('rspec')
s.add_development_dependency('active_support', '>= 3.0.0')
View
2  lib/ice_cube/builders/hash_builder.rb
@@ -1,7 +1,7 @@
module IceCube
class HashBuilder
-
+
def initialize(rule = nil)
@hash = { :validations => {}, :rule_type => rule.class.name }
end
View
8 lib/ice_cube/builders/string_builder.rb
@@ -41,8 +41,8 @@ def register_formatter(type, &formatter)
class << self
NUMBER_SUFFIX = ['th', 'st', 'nd', 'rd', 'th', 'th', 'th', 'th', 'th', 'th']
- SPECIAL_SUFFIX = { 11 => 'th', 12 => 'th', 13 => 'th', 14 => 'th' }
-
+ SPECIAL_SUFFIX = { 11 => 'th', 12 => 'th', 13 => 'th', 14 => 'th' }
+
# influenced by ActiveSupport's to_sentence
def sentence(array)
case array.length
@@ -63,12 +63,12 @@ def nice_number(number)
else
suffix = SPECIAL_SUFFIX.include?(number) ?
SPECIAL_SUFFIX[number] : NUMBER_SUFFIX[number.abs % 10]
- number.to_s << suffix
+ number.to_s << suffix
end
end
end
-
+
end
end
View
2  lib/ice_cube/rules/secondly_rule.rb
@@ -1,7 +1,7 @@
module IceCube
class SecondlyRule < ValidatedRule
-
+
include Validations::SecondlyInterval
def initialize(interval = 1)
View
2  lib/ice_cube/schedule.rb
@@ -314,7 +314,7 @@ def self.from_hash(original_hash, options = {})
schedule = IceCube::Schedule.new TimeUtil.deserialize_time(data[:start_date])
schedule.duration = data[:duration] if data[:duration]
schedule.end_time = TimeUtil.deserialize_time(data[:end_time]) if data[:end_time]
- data[:rrules] && data[:rrules].each { |h| schedule.rrule(IceCube::Rule.from_hash(h)) }
+ data[:rrules] && data[:rrules].each { |h| schedule.rrule(IceCube::Rule.from_hash(h)) }
data[:exrules] && data[:exrules].each { |h| schedule.exrule(IceCube::Rule.from_hash(h)) }
data[:rtimes] && data[:rtimes].each do |t|
schedule.add_recurrence_time TimeUtil.deserialize_time(t)
View
2  lib/ice_cube/validations/count.rb
@@ -45,7 +45,7 @@ def build_ical(builder)
end
StringBuilder.register_formatter(:count) do |segments|
- count = segments.first
+ count = segments.first
"#{count} #{count == 1 ? 'time' : 'times'}"
end
View
2  lib/ice_cube/validations/day.rb
@@ -3,7 +3,7 @@
module IceCube
module Validations::Day
-
+
def day(*days)
days.each do |day|
day = TimeUtil.symbol_to_day(day) if day.is_a?(Symbol)
View
2  lib/ice_cube/validations/hourly_interval.rb
@@ -42,7 +42,7 @@ def dst_adjust?
def validate(time, schedule)
start_time = schedule.start_time
- sec = (time.to_i - time.to_i % ONE_HOUR) -
+ sec = (time.to_i - time.to_i % ONE_HOUR) -
(start_time.to_i - start_time.to_i % ONE_HOUR)
hours = sec / ONE_HOUR
unless hours % interval == 0
View
4 lib/ice_cube/validations/lock.rb
@@ -23,11 +23,11 @@ def validate_day_lock(time, schedule)
# If this number is positive, then follow our normal procedure
if start > 0
return start >= time.day ? start - time.day : days_in_this_month - time.day + start
- end
+ end
# If the number is negative, and it resolved against the current month
# puts it in the future, just return the difference
days_in_this_month = TimeUtil.days_in_month(time)
- start_one = days_in_this_month + start + 1
+ start_one = days_in_this_month + start + 1
if start_one >= time.day
return start_one - time.day
end
View
2  lib/ice_cube/validations/weekly_interval.rb
@@ -45,7 +45,7 @@ def validate(time, schedule)
st = schedule.start_time
start_date = Date.new(st.year, st.month, st.day)
weeks = (
- (date - TimeUtil.normalize_weekday(date.wday, week_start)) -
+ (date - TimeUtil.normalize_weekday(date.wday, week_start)) -
(start_date - TimeUtil.normalize_weekday(start_date.wday, week_start))
) / 7
unless weeks % interval == 0
View
6 spec/data/issue40.yml
@@ -3,8 +3,8 @@
:rrules:
- :rule_type: IceCube::MinutelyRule
:interval: 60
- :until: !!null
- :count: !!null
+ :until: !!null
+ :count: !!null
:validations:
:day:
- 4
@@ -18,4 +18,4 @@
:rdates: []
:exdates: []
:duration: 3600
-:end_time: !!null
+:end_time: !!null
View
6 spec/examples/active_support_spec.rb
@@ -54,19 +54,19 @@
it 'should work with occurs_on? and a boundary of a day in a different time_zone' do
schedule = IceCube::Schedule.new(Time.local(2009, 2, 7, 10, 30, 0))
schedule.add_recurrence_rule IceCube::Rule.daily
- schedule.occurs_on?(Date.new(2009, 2, 7)).should be(true)
+ schedule.occurs_on?(Date.new(2009, 2, 7)).should be_true
end
it 'should work in the occurs_on? boundary condition to the beginning of the day' do
schedule = IceCube::Schedule.new(Time.local(2009, 2, 7, 23, 59, 59))
schedule.add_recurrence_rule IceCube::Rule.daily
- schedule.occurs_on?(Date.new(2009, 2, 7)).should be(true)
+ schedule.occurs_on?(Date.new(2009, 2, 7)).should be_true
end
it 'should work in the occurs_on? boundary condition to the end of the day' do
schedule = IceCube::Schedule.new(Time.local(2009, 2, 7, 0, 0, 0))
schedule.add_recurrence_rule IceCube::Rule.daily
- schedule.occurs_on?(Date.new(2009, 2, 7)).should be(true)
+ schedule.occurs_on?(Date.new(2009, 2, 7)).should be_true
end
end
View
22 spec/examples/dst_spec.rb
@@ -13,7 +13,7 @@
dates.each do |date|
date.utc?.should_not == true
date.hour.should == 5
- end
+ end
end
# DST in 2010 is November 7th at 2am
@@ -27,9 +27,9 @@
dates.each do |date|
date.utc?.should_not == true
date.hour.should == 5
- end
+ end
end
-
+
it 'cross a daylight savings time boundary with a recurrence rule in local time' do
start_date = Time.local(2010, 3, 14, 5, 0, 0)
schedule = IceCube::Schedule.new(start_date)
@@ -55,7 +55,7 @@
distance_in_hours += 2
end
end
-
+
it 'every 30 minutes over a daylight savings time boundary, checking interval' do
start_date = Time.local(2010, 11, 6, 23, 0, 0)
schedule = IceCube::Schedule.new(start_date)
@@ -68,7 +68,7 @@
distance_in_minutes += 30
end
end
-
+
it 'every 120 seconds over a daylight savings time boundary, checking interval' do
start_date = Time.local(2010, 11, 6, 23, 50, 0)
schedule = IceCube::Schedule.new(start_date)
@@ -81,7 +81,7 @@
distance_in_seconds += 120
end
end
-
+
it 'every other day over a daylight savings time boundary, checking hour/min/sec' do
start_date = Time.local(2010, 11, 6, 20, 0, 0)
schedule = IceCube::Schedule.new(start_date)
@@ -94,7 +94,7 @@
d.sec.should == start_date.sec
end
end
-
+
it 'every other month over a daylight savings time boundary, checking day/hour/min/sec' do
start_date = Time.local(2010, 11, 6, 20, 0, 0)
schedule = IceCube::Schedule.new(start_date)
@@ -108,7 +108,7 @@
d.sec.should == start_date.sec
end
end
-
+
it 'every other year over a daylight savings time boundary, checking day/hour/min/sec' do
start_date = Time.local(2010, 11, 6, 20, 0, 0)
schedule = IceCube::Schedule.new(start_date)
@@ -123,7 +123,7 @@
d.sec.should == start_date.sec
end
end
-
+
it 'LOCAL - has an until date on a rule that is over a DST from the start date' do
start_date = Time.local(2010, 3, 13, 5, 0, 0)
end_date = Time.local(2010, 3, 15, 5, 0, 0)
@@ -159,7 +159,7 @@
#make sure we end on the proper time
schedule.all_occurrences.last.should == end_date
end
-
+
it 'LOCAL - has an end date on a rule that is over a DST from the start date' do
start_date = Time.local(2010, 3, 13, 5, 0, 0)
end_date = Time.local(2010, 3, 15, 5, 0, 0)
@@ -262,5 +262,5 @@
schedule.add_recurrence_rule IceCube::Rule.yearly.month_of_year(:april).day_of_month(10)
schedule.first(3).should == [Time.local(2010, 4, 10, 12, 0, 0), Time.local(2011, 4, 10, 12, 0, 0), Time.local(2012, 4, 10, 12, 0, 0)]
end
-
+
end
View
144 spec/examples/ice_cube_spec.rb
@@ -11,7 +11,7 @@
schedule.first(3)
end.should_not raise_error
end
-
+
it 'should respond to complex combinations (1)' do
start_date = Time.utc(2010, 1, 1)
schedule = IceCube::Schedule.new(start_date)
@@ -25,7 +25,7 @@
date.year.should == start_date.year #since we're doing every other
end
end
-
+
it 'should respond to a single date event' do
start_date = Time.now
schedule = IceCube::Schedule.new(start_date)
@@ -105,7 +105,7 @@
schedule.add_recurrence_rule IceCube::Rule.daily.hour_of_day(1, 2).count(6)
dates = schedule.all_occurrences
dates.should == [Time.utc(2007, 9, 3, 1, 15, 25), Time.utc(2007, 9, 3, 2, 15, 25),
- Time.utc(2007, 9, 4, 1, 15, 25), Time.utc(2007, 9, 4, 2, 15, 25),
+ Time.utc(2007, 9, 4, 1, 15, 25), Time.utc(2007, 9, 4, 2, 15, 25),
Time.utc(2007, 9, 5, 1, 15, 25), Time.utc(2007, 9, 5, 2, 15, 25)]
end
@@ -115,7 +115,7 @@
schedule.add_recurrence_rule IceCube::Rule.daily.hour_of_day(1, 2).minute_of_hour(0).count(6)
dates = schedule.all_occurrences
dates.should == [Time.utc(2007, 9, 3, 1, 0, 25), Time.utc(2007, 9, 3, 2, 0, 25),
- Time.utc(2007, 9, 4, 1, 0, 25), Time.utc(2007, 9, 4, 2, 0, 25),
+ Time.utc(2007, 9, 4, 1, 0, 25), Time.utc(2007, 9, 4, 2, 0, 25),
Time.utc(2007, 9, 5, 1, 0, 25), Time.utc(2007, 9, 5, 2, 0, 25)]
end
@@ -153,7 +153,7 @@
date.sec.should == start_date.sec
end
end
-
+
it 'occurs daily' do
start_date = Time.now
schedule = IceCube::Schedule.new(start_date)
@@ -165,7 +165,7 @@
date.sec.should == start_date.sec
end
end
-
+
it 'occurs hourly' do
start_date = Time.now
schedule = IceCube::Schedule.new(start_date)
@@ -176,7 +176,7 @@
date.sec.should == start_date.sec
end
end
-
+
it 'occurs minutely' do
start_date = Time.now
schedule = IceCube::Schedule.new(start_date)
@@ -205,10 +205,10 @@
start_date = Time.zone.local(2010, 9, 2, 5, 0, 0)
schedule = IceCube::Schedule.new(start_date)
schedule.add_recurrence_rule IceCube::Rule.daily
- schedule.first(10).each do |d|
+ schedule.first(10).each do |d|
d.utc?.should == false
d.hour.should == 5
- (d.utc_offset == -5 * IceCube::ONE_HOUR || d.utc_offset == -4 * IceCube::ONE_HOUR).should be(true)
+ (d.utc_offset == -5 * IceCube::ONE_HOUR || d.utc_offset == -4 * IceCube::ONE_HOUR).should be_true
end
end
@@ -216,13 +216,13 @@
start_date = Time.utc(2010, 9, 2, 5, 0, 0)
schedule = IceCube::Schedule.new(start_date)
schedule.add_recurrence_rule IceCube::Rule.daily
- schedule.first(10).each do |d|
+ schedule.first(10).each do |d|
d.utc?.should == true
d.utc_offset.should == 0
d.hour.should == 5
- end
+ end
end
-
+
# here we purposely put a UTC time that is before the range ends, to
# verify ice_cube is properly checking until bounds
it 'works with a until date that is UTC, but the start date is local' do
@@ -233,8 +233,8 @@
#check assumptions
dates = schedule.all_occurrences
dates.each { |d| d.utc?.should == false }
- dates.should == [Time.zone.local(2010, 11, 6, 5, 0, 0),
- Time.zone.local(2010, 11, 7, 5, 0, 0), Time.zone.local(2010, 11, 8, 5, 0, 0),
+ dates.should == [Time.zone.local(2010, 11, 6, 5, 0, 0),
+ Time.zone.local(2010, 11, 7, 5, 0, 0), Time.zone.local(2010, 11, 8, 5, 0, 0),
Time.zone.local(2010, 11, 9, 5, 0, 0)]
end
@@ -248,8 +248,8 @@
#check assumptions
dates = schedule.all_occurrences
dates.each { |d| d.utc?.should == true }
- dates.should == [Time.utc(2010, 11, 6, 5, 0, 0),
- Time.utc(2010, 11, 7, 5, 0, 0), Time.utc(2010, 11, 8, 5, 0, 0),
+ dates.should == [Time.utc(2010, 11, 6, 5, 0, 0),
+ Time.utc(2010, 11, 7, 5, 0, 0), Time.utc(2010, 11, 8, 5, 0, 0),
Time.utc(2010, 11, 9, 5, 0, 0)]
end
@@ -263,7 +263,7 @@
d.hour.should == 15
d.min.should == 45
d.sec.should == 0
- d.utc?.should be(true)
+ d.utc?.should be_true
end
end
@@ -290,7 +290,7 @@
# pull the dates back out of the schedule and compare
schedule.rdates.should == dates
end
-
+
it 'can retrieve exdates from a schedule' do
schedule = IceCube::Schedule.new(Time.now)
dates = [Time.now, Time.now + 5, Time.now + 10]
@@ -312,20 +312,20 @@
it 'ensures that month of year (3) is march' do
schedule = IceCube::Schedule.new(DAY)
schedule.add_recurrence_rule IceCube::Rule.daily.month_of_year(:march)
-
+
schedule2 = IceCube::Schedule.new(DAY)
schedule2.add_recurrence_rule IceCube::Rule.daily.month_of_year(3)
-
+
schedule.first(10).should == schedule2.first(10)
end
it 'ensures that day of week (1) is monday' do
schedule = IceCube::Schedule.new(DAY)
schedule.add_recurrence_rule IceCube::Rule.daily.day(:monday)
-
+
schedule2 = IceCube::Schedule.new(DAY)
schedule2.add_recurrence_rule IceCube::Rule.daily.day(1)
-
+
schedule.first(10).should == schedule2.first(10)
end
@@ -365,14 +365,14 @@
start_time = Time.local(2010, 7, 2, 10, 0, 0)
schedule = IceCube::Schedule.new(start_time)
schedule.add_recurrence_rule IceCube::Rule.daily.count(10)
- schedule.occurs_on?(Date.new(2010, 7, 4)).should be(true)
+ schedule.occurs_on?(Date.new(2010, 7, 4)).should be_true
end
-
+
it 'should be able to determine whether a given rule falls on a Date (rather than a time)' do
start_time = Time.local(2010, 7, 2, 10, 0, 0)
schedule = IceCube::Schedule.new(start_time)
schedule.add_recurrence_rule IceCube::Rule.daily.count(10)
- schedule.occurs_on?(Date.new(2010, 7, 1)).should_not be(true)
+ schedule.occurs_on?(Date.new(2010, 7, 1)).should_not be_true
end
it 'should be able to get back rdates from an ice_cube schedule' do
@@ -392,18 +392,18 @@
it 'occurs_on? works for a single date recurrence' do
schedule = IceCube::Schedule.new Time.utc(2009, 9, 2, 13, 0, 0)
schedule.add_recurrence_date Time.utc(2009, 9, 2, 13, 0, 0)
- schedule.occurs_on?(Date.new(2009, 9, 2)).should be(true)
- schedule.occurs_on?(Date.new(2009, 9, 1)).should_not be(true)
- schedule.occurs_on?(Date.new(2009, 9, 3)).should_not be(true)
+ schedule.occurs_on?(Date.new(2009, 9, 2)).should be_true
+ schedule.occurs_on?(Date.new(2009, 9, 1)).should_not be_true
+ schedule.occurs_on?(Date.new(2009, 9, 3)).should_not be_true
end
- it 'occurs_on? should only be(true) for the single day of a certain event' do
+ it 'occurs_on? should only be_true for the single day of a certain event' do
Time.zone = "Pacific Time (US & Canada)"
schedule = IceCube::Schedule.new Time.zone.parse("2010/5/13 02:00:00")
schedule.add_recurrence_date Time.zone.parse("2010/5/13 02:00:00")
- schedule.occurs_on?(Date.new(2010, 5, 13)).should be(true)
- schedule.occurs_on?(Date.new(2010, 5, 14)).should be(false)
- schedule.occurs_on?(Date.new(2010, 5, 15)).should be(false)
+ schedule.occurs_on?(Date.new(2010, 5, 13)).should be_true
+ schedule.occurs_on?(Date.new(2010, 5, 14)).should be_false
+ schedule.occurs_on?(Date.new(2010, 5, 15)).should be_false
end
it 'should allow calling of .first on a schedule with no arguments' do
@@ -442,7 +442,7 @@
start_time = Time.local 2010, 5, 6, 10, 0, 0
schedule = IceCube::Schedule.new(start_time, :duration => 3600)
schedule.add_recurrence_rule IceCube::Rule.daily
- schedule.occurring_at?(Time.local(2010, 5, 6, 10, 30, 0)).should be(true) #true
+ schedule.occurring_at?(Time.local(2010, 5, 6, 10, 30, 0)).should be_true #true
end
it 'should be able to specify a duration on a schedule and use occurring_at? on that schedule
@@ -450,8 +450,8 @@
start_time = Time.local 2010, 5, 6, 10, 0, 0
schedule = IceCube::Schedule.new(start_time, :duration => 3600)
schedule.add_recurrence_rule IceCube::Rule.daily
- schedule.occurring_at?(Time.local(2010, 5, 6, 9, 59, 0)).should be(false)
- schedule.occurring_at?(Time.local(2010, 5, 6, 11, 0, 0)).should be(false)
+ schedule.occurring_at?(Time.local(2010, 5, 6, 9, 59, 0)).should be_false
+ schedule.occurring_at?(Time.local(2010, 5, 6, 11, 0, 0)).should be_false
end
it 'should be able to specify a duration on a schedule and use occurring_at? on that schedule
@@ -459,8 +459,8 @@
start_time = Time.local 2010, 5, 6, 10, 0, 0
schedule = IceCube::Schedule.new(start_time, :duration => 3600)
schedule.add_recurrence_rule IceCube::Rule.daily
- schedule.occurring_at?(Time.local(2010, 5, 6, 10, 0, 0)).should be(true)
- schedule.occurring_at?(Time.local(2010, 5, 6, 10, 59, 59)).should be(true)
+ schedule.occurring_at?(Time.local(2010, 5, 6, 10, 0, 0)).should be_true
+ schedule.occurring_at?(Time.local(2010, 5, 6, 10, 59, 59)).should be_true
end
it 'should be able to explicity remove a certain minute from a duration' do
@@ -468,9 +468,9 @@
schedule = IceCube::Schedule.new(start_time, :duration => 3600)
schedule.add_recurrence_rule IceCube::Rule.daily
schedule.add_exception_date Time.local(2010, 5, 6, 10, 21, 30)
- schedule.occurring_at?(Time.local(2010, 5, 6, 10, 21, 29)).should be(true)
- schedule.occurring_at?(Time.local(2010, 5, 6, 10, 21, 30)).should be(false)
- schedule.occurring_at?(Time.local(2010, 5, 6, 10, 21, 31)).should be(true)
+ schedule.occurring_at?(Time.local(2010, 5, 6, 10, 21, 29)).should be_true
+ schedule.occurring_at?(Time.local(2010, 5, 6, 10, 21, 30)).should be_false
+ schedule.occurring_at?(Time.local(2010, 5, 6, 10, 21, 31)).should be_true
end
it 'should be able to specify an end time for the schedule' do
@@ -525,7 +525,7 @@
end_time = DAY + IceCube::ONE_DAY * 2
schedule = IceCube::Schedule.new(start_time)
schedule.add_recurrence_rule IceCube::Rule.daily.until(end_time)
- schedule.occurs_at?(DAY + 4*IceCube::ONE_DAY).should be(false) # out of range
+ schedule.occurs_at?(DAY + 4*IceCube::ONE_DAY).should be_false # out of range
end
it 'should be able to work with an end date and .occurs_at' do
@@ -533,7 +533,7 @@
end_time = DAY + IceCube::ONE_DAY * 2
schedule = IceCube::Schedule.new(start_time)
schedule.add_recurrence_rule IceCube::Rule.daily.until(end_time)
- schedule.occurs_on?((DAY + 4*IceCube::ONE_DAY)).should be(false) # out of range
+ schedule.occurs_on?((DAY + 4*IceCube::ONE_DAY)).should be_false # out of range
end
it 'should be able to work with an end date and .occurring_at' do
@@ -541,8 +541,8 @@
end_time = DAY + IceCube::ONE_DAY * 2
schedule = IceCube::Schedule.new(start_time, :duration => 20)
schedule.add_recurrence_rule IceCube::Rule.daily.until(end_time)
- schedule.occurring_at?((DAY + 2*IceCube::ONE_DAY + 10)).should be(true) # in range
- schedule.occurring_at?((DAY + 4*IceCube::ONE_DAY + 10)).should be(false) # out of range
+ schedule.occurring_at?((DAY + 2*IceCube::ONE_DAY + 10)).should be_true # in range
+ schedule.occurring_at?((DAY + 4*IceCube::ONE_DAY + 10)).should be_false # out of range
end
it 'should not create an infinite loop crossing over february - github issue 6' do
@@ -604,7 +604,7 @@
schedule.add_recurrence_rule IceCube::Rule.yearly.until(Time.local(2010, 10, 30))
schedule.first(10).should == [Time.local(2010, 2, 29)]
end
-
+
it 'should be able to know when to stop with an end date and a rule that misses a few times' do
schedule = IceCube::Schedule.new(Time.local(2010, 2, 29))
schedule.add_recurrence_rule IceCube::Rule.yearly.count(1)
@@ -636,38 +636,38 @@
Time.zone = 'Eastern Time (US & Canada)'
schedule = IceCube::Schedule.new(Time.zone.local(2010, 8, 10, 0, 0, 0))
schedule.add_recurrence_rule IceCube::Rule.weekly
- schedule.occurs_on?(Date.new(2010, 8, 10)).should be(true)
- schedule.occurs_on?(Date.new(2010, 8, 11)).should be(false)
- schedule.occurs_on?(Date.new(2010, 8, 9)).should be(false)
- schedule.occurs_on?(Date.new(2010, 8, 17)).should be(true)
+ schedule.occurs_on?(Date.new(2010, 8, 10)).should be_true
+ schedule.occurs_on?(Date.new(2010, 8, 11)).should be_false
+ schedule.occurs_on?(Date.new(2010, 8, 9)).should be_false
+ schedule.occurs_on?(Date.new(2010, 8, 17)).should be_true
end
it 'should be able to work with occurs_on? at an odd time - end of day' do
schedule = IceCube::Schedule.new(Time.local(2010, 8, 10, 23, 59, 59))
schedule.add_recurrence_rule IceCube::Rule.weekly
- schedule.occurs_on?(Date.new(2010, 8, 10)).should be(true)
- schedule.occurs_on?(Date.new(2010, 8, 11)).should be(false)
- schedule.occurs_on?(Date.new(2010, 8, 9)).should be(false)
- schedule.occurs_on?(Date.new(2010, 8, 17)).should be(true)
+ schedule.occurs_on?(Date.new(2010, 8, 10)).should be_true
+ schedule.occurs_on?(Date.new(2010, 8, 11)).should be_false
+ schedule.occurs_on?(Date.new(2010, 8, 9)).should be_false
+ schedule.occurs_on?(Date.new(2010, 8, 17)).should be_true
end
it 'should be able to work with occurs_on? at an odd time - start of day' do
schedule = IceCube::Schedule.new(Time.zone.local(2010, 8, 10, 0, 0, 0))
schedule.add_recurrence_date Time.zone.local(2010, 8, 20, 0, 0, 0)
schedule.add_recurrence_rule IceCube::Rule.weekly
- schedule.occurs_on?(Date.new(2010, 8, 20)).should be(true)
- schedule.occurs_on?(Date.new(2010, 8, 10)).should be(true)
- schedule.occurs_on?(Date.new(2010, 8, 11)).should be(false)
- schedule.occurs_on?(Date.new(2010, 8, 17)).should be(true)
- schedule.occurs_on?(Date.new(2010, 8, 18)).should be(false)
+ schedule.occurs_on?(Date.new(2010, 8, 20)).should be_true
+ schedule.occurs_on?(Date.new(2010, 8, 10)).should be_true
+ schedule.occurs_on?(Date.new(2010, 8, 11)).should be_false
+ schedule.occurs_on?(Date.new(2010, 8, 17)).should be_true
+ schedule.occurs_on?(Date.new(2010, 8, 18)).should be_false
end
it 'should be able to work with occurs_on? at an odd time - end of day' do
schedule = IceCube::Schedule.new(Time.local(2010, 8, 10, 23, 59, 59).in_time_zone('Pacific Time (US & Canada)'))
schedule.add_recurrence_date Time.local(2010, 8, 20, 23, 59, 59)
- schedule.occurs_on?(Date.new(2010, 8, 20)).should be(true)
- schedule.occurs_on?(Date.new(2010, 8, 21)).should be(false)
- schedule.occurs_on?(Date.new(2010, 8, 19)).should be(false)
+ schedule.occurs_on?(Date.new(2010, 8, 20)).should be_true
+ schedule.occurs_on?(Date.new(2010, 8, 21)).should be_false
+ schedule.occurs_on?(Date.new(2010, 8, 19)).should be_false
end
it 'should work with occurs on for a single day schedule' do
@@ -678,9 +678,9 @@
schedule.add_recurrence_date time
schedule.all_occurrences.should == [time]
# test occurs_on? for surrounding dates
- schedule.occurs_on?(date).should be(true)
- schedule.occurs_on?(date + 1).should be(false)
- schedule.occurs_on?(date - 1).should be(false)
+ schedule.occurs_on?(date).should be_true
+ schedule.occurs_on?(date + 1).should be_false
+ schedule.occurs_on?(date - 1).should be_false
end
it 'should work with occurs_on? with multiple rdates' do
@@ -689,9 +689,9 @@
schedule.add_recurrence_date(Time.local(2010, 7, 12, 16))
schedule.add_recurrence_date(Time.local(2010, 7, 13, 16))
# test
- schedule.occurs_on?(Date.new(2010, 7, 11)).should be(true)
- schedule.occurs_on?(Date.new(2010, 7, 12)).should be(true)
- schedule.occurs_on?(Date.new(2010, 7, 13)).should be(true)
+ schedule.occurs_on?(Date.new(2010, 7, 11)).should be_true
+ schedule.occurs_on?(Date.new(2010, 7, 12)).should be_true
+ schedule.occurs_on?(Date.new(2010, 7, 13)).should be_true
end
it 'should have some convenient aliases' do
@@ -709,7 +709,7 @@
schedule.rrule monthly
schedule.rrules.should == [daily, monthly]
end
-
+
it 'should have some convenient alias for exrules' do
schedule = IceCube::Schedule.new(Time.now)
daily = IceCube::Rule.daily; monthly = IceCube::Rule.monthly
@@ -717,14 +717,14 @@
schedule.exrule monthly
schedule.exrules.should == [daily, monthly]
end
-
+
it 'should have some convenient alias for rdates' do
schedule = IceCube::Schedule.new(Time.now)
schedule.add_recurrence_date Time.local(2010, 8, 13)
schedule.rdate Time.local(2010, 8, 14)
schedule.rdates.should == [Time.local(2010, 8, 13), Time.local(2010, 8, 14)]
end
-
+
it 'should have some convenient alias for exdates' do
schedule = IceCube::Schedule.new(Time.now)
schedule.add_exception_date Time.local(2010, 8, 13)
@@ -736,8 +736,8 @@
schedule = IceCube::Schedule.new(Time.local(2010, 8, 27, 10))
schedule.rrule IceCube::Rule.daily
schedule.exrule IceCube::Rule.daily.day(:friday)
- schedule.occurs_on?(Date.new(2010, 8, 27)).should be(false)
- schedule.occurs_on?(Date.new(2010, 8, 28)).should be(true)
+ schedule.occurs_on?(Date.new(2010, 8, 27)).should be_false
+ schedule.occurs_on?(Date.new(2010, 8, 28)).should be_true
end
it 'should always generate the correct number of days for .first' do
View
4 spec/examples/monthly_rule_spec.rb
@@ -1,7 +1,7 @@
require File.dirname(__FILE__) + '/../spec_helper'
describe IceCube::MonthlyRule, 'occurs_on?' do
-
+
it 'should produce the correct number of days for @interval = 1' do
start_date = DAY
schedule = IceCube::Schedule.new(start_date)
@@ -40,7 +40,7 @@
#check assumption (month 1 monday) (month 2 monday)
schedule.occurrences(start_date + 50 * IceCube::ONE_DAY).size.should == 2
end
-
+
it 'should produce the correct number of days for @interval = 1 with only the last mondays' do
start_date = Time.utc(2010, 1, 1)
schedule = IceCube::Schedule.new(start_date)
View
2  spec/examples/regression_spec.rb
@@ -5,7 +5,7 @@
it 'should consider recurrence dates properly in find_occurreces - github issue 43' do
s = IceCube::Schedule.new(Time.local(2011,10,1, 18, 25))
s.add_recurrence_date(Time.local(2011,12,3,15,0,0))
- s.add_recurrence_date(Time.local(2011,12,3,10,0,0))
+ s.add_recurrence_date(Time.local(2011,12,3,10,0,0))
s.add_recurrence_date(Time.local(2011,12,4,10,0,0))
s.occurs_at?(Time.local(2011,12,3,15,0,0)).should be_true
end
View
4 spec/examples/schedule_spec.rb
@@ -179,7 +179,7 @@
it 'should return false if conflict is not present and single recurrence and time originally specified as DateTime' do
date = DateTime.new(2020,9,21,11,30,0)
- start_time = date.to_time
+ start_time = date.to_time
schedule1 = IceCube::Schedule.new(start_time, :duration => IceCube::ONE_HOUR)
schedule1.add_recurrence_time(start_time)
schedule2 = IceCube::Schedule.new(start_time + IceCube::ONE_HOUR, :duration => IceCube::ONE_HOUR)
@@ -274,7 +274,7 @@
describe :start_date= do
it 'should modify start date in rrule_occurrence_heads when changed' do
- schedule = Schedule.new (Time.now - 1000)
+ schedule = Schedule.new(Time.now - 1000)
schedule.rrule Rule.daily
schedule.start_date = (start_date = Time.now)
(Time.now - schedule.first).should be < 100
View
4 spec/examples/to_ical_spec.rb
@@ -80,7 +80,7 @@
it 'should be able to collapse a combination day_of_week and day' do
rule = IceCube::Rule.daily.day(:monday, :tuesday).day_of_week(:monday => [1, -1])
- ['FREQ=DAILY;BYDAY=TU,1MO,-1MO', 'FREQ=DAILY;BYDAY=1MO,-1MO,TU'].include?(rule.to_ical).should be(true)
+ ['FREQ=DAILY;BYDAY=TU,1MO,-1MO', 'FREQ=DAILY;BYDAY=1MO,-1MO,TU'].include?(rule.to_ical).should be_true
end
it 'should be able to serialize of .day_of_week rule to_ical with multiple days' do
@@ -91,7 +91,7 @@
'FREQ=DAILY;BYDAY=2TU,1MO,-1MO,WE',
'FREQ=DAILY;BYDAY=WE,2TU,1MO,-1MO',
'FREQ=DAILY;BYDAY=2TU,WE,1MO,-1MO'
- ].include?(rule.to_ical).should be(true)
+ ].include?(rule.to_ical).should be_true
end
it 'should be able to serialize a base schedule to ical in local time' do
View
20 spec/examples/to_s_spec.rb
@@ -6,37 +6,37 @@
IceCube::Rule.secondly.to_s.should == 'Secondly'
IceCube::Rule.secondly(2).to_s.should == 'Every 2 seconds'
end
-
+
it 'should have a useful base to_s representation for a minutely rule' do
IceCube::Rule.minutely.to_s.should == 'Minutely'
IceCube::Rule.minutely(2).to_s.should == 'Every 2 minutes'
end
-
+
it 'should have a useful base to_s representation for a hourly rule' do
IceCube::Rule.hourly.to_s.should == 'Hourly'
IceCube::Rule.hourly(2).to_s.should == 'Every 2 hours'
end
-
+
it 'should have a useful base to_s representation for a daily rule' do
IceCube::Rule.daily.to_s.should == 'Daily'
IceCube::Rule.daily(2).to_s.should == 'Every 2 days'
end
-
+
it 'should have a useful base to_s representation for a weekly rule' do
IceCube::Rule.weekly.to_s.should == 'Weekly'
IceCube::Rule.weekly(2).to_s.should == 'Every 2 weeks'
end
-
+
it 'should have a useful base to_s representation for a monthly rule' do
IceCube::Rule.monthly.to_s.should == 'Monthly'
IceCube::Rule.monthly(2).to_s.should == 'Every 2 months'
end
-
+
it 'should have a useful base to_s representation for a yearly rule' do
IceCube::Rule.yearly.to_s.should == 'Yearly'
IceCube::Rule.yearly(2).to_s.should == 'Every 2 years'
end
-
+
it 'should work with various sentence types properly' do
IceCube::Rule.weekly.to_s.should == 'Weekly'
IceCube::Rule.weekly.day(:monday).to_s.should == 'Weekly on Mondays'
@@ -77,7 +77,7 @@
schedule.add_recurrence_date Time.local(2010, 3, 20)
schedule.to_s.should == "March 20, 2010"
end
-
+
it 'should work with additional dates' do
schedule = IceCube::Schedule.new Time.local(2010, 3, 20)
schedule.add_recurrence_date Time.local(2010, 3, 20)
@@ -98,7 +98,7 @@
schedule.add_recurrence_date Time.local(2010, 3, 20)
schedule.to_s.should == 'March 20, 2010'
end
-
+
it 'should work with rules and dates' do
schedule = IceCube::Schedule.new Time.local(2010, 3, 20)
schedule.add_recurrence_date Time.local(2010, 3, 20)
@@ -166,7 +166,7 @@
schedule.rrule IceCube::Rule.weekly.until(Time.local(2012, 2, 3))
schedule.to_s.should == 'Weekly until February 3, 2012'
end
-
+
it 'should be able to reflect count' do
schedule = IceCube::Schedule.new(Time.now)
schedule.add_recurrence_rule IceCube::Rule.weekly.count(1)
View
76 spec/examples/to_yaml_spec.rb
@@ -20,125 +20,125 @@
rule = schedule.rrules.first
rule.is_a?(IceCube::MonthlyRule)
end
-
+
it 'should respond to .to_yaml' do
schedule = IceCube::Schedule.new(Time.now)
schedule.add_recurrence_rule IceCube::Rule.daily.until(Time.now)
#check assumption
schedule.should respond_to('to_yaml')
end
-
+
it 'should be able to make a round-trip to YAML' do
schedule = IceCube::Schedule.new(Time.now)
schedule.add_recurrence_rule IceCube::Rule.daily.until(Time.now + 10)
result1 = schedule.all_occurrences
-
+
yaml_string = schedule.to_yaml
-
+
schedule2 = IceCube::Schedule.from_yaml(yaml_string)
result2 = schedule2.all_occurrences
-
+
# compare without usecs
- result1.map { |r| r.to_s }.should == result2.map { |r| r.to_s }
+ result1.map { |r| r.to_s }.should == result2.map { |r| r.to_s }
end
it 'should be able to make a round-trip to YAML with .day' do
schedule = IceCube::Schedule.new(Time.now)
schedule.add_recurrence_rule IceCube::Rule.daily.day(:monday, :wednesday)
-
+
yaml_string = schedule.to_yaml
schedule2 = IceCube::Schedule.from_yaml(yaml_string)
-
+
# compare without usecs
- schedule.first(10).map { |r| r.to_s }.should == schedule2.first(10).map { |r| r.to_s }
+ schedule.first(10).map { |r| r.to_s }.should == schedule2.first(10).map { |r| r.to_s }
end
it 'should be able to make a round-trip to YAML with .day_of_month' do
schedule = IceCube::Schedule.new(Time.now)
schedule.add_recurrence_rule IceCube::Rule.monthly.day_of_month(10, 20)
-
+
yaml_string = schedule.to_yaml
schedule2 = IceCube::Schedule.from_yaml(yaml_string)
# compare without usecs
- schedule.first(10).map { |r| r.to_s }.should == schedule2.first(10).map { |r| r.to_s }
+ schedule.first(10).map { |r| r.to_s }.should == schedule2.first(10).map { |r| r.to_s }
end
it 'should be able to make a round-trip to YAML with .day_of_week' do
schedule = IceCube::Schedule.new(Time.now)
schedule.add_recurrence_rule IceCube::Rule.weekly.day_of_week(:monday => [1, -2])
-
+
yaml_string = schedule.to_yaml
schedule2 = IceCube::Schedule.from_yaml(yaml_string)
# compare without usecs
- schedule.first(10).map { |r| r.to_s }.should == schedule2.first(10).map { |r| r.to_s }
+ schedule.first(10).map { |r| r.to_s }.should == schedule2.first(10).map { |r| r.to_s }
end
it 'should be able to make a round-trip to YAML with .day_of_year' do
schedule = IceCube::Schedule.new(Time.now)
schedule.add_recurrence_rule IceCube::Rule.yearly.day_of_year(100, 200)
-
+
yaml_string = schedule.to_yaml
schedule2 = IceCube::Schedule.from_yaml(yaml_string)
-
+
# compare without usecs
- schedule.first(10).map { |r| r.to_s }.should == schedule2.first(10).map { |r| r.to_s }
+ schedule.first(10).map { |r| r.to_s }.should == schedule2.first(10).map { |r| r.to_s }
end
it 'should be able to make a round-trip to YAML with .hour_of_day' do
schedule = IceCube::Schedule.new(Time.now)
schedule.add_recurrence_rule IceCube::Rule.daily.hour_of_day(1, 2)
-
+
yaml_string = schedule.to_yaml
schedule2 = IceCube::Schedule.from_yaml(yaml_string)
# compare without usecs
- schedule.first(10).map { |r| r.to_s }.should == schedule2.first(10).map { |r| r.to_s }
+ schedule.first(10).map { |r| r.to_s }.should == schedule2.first(10).map { |r| r.to_s }
end
it 'should be able to make a round-trip to YAML with .minute_of_hour' do
schedule = IceCube::Schedule.new(Time.now)
schedule.add_recurrence_rule IceCube::Rule.daily.minute_of_hour(0, 30)
-
+
yaml_string = schedule.to_yaml
schedule2 = IceCube::Schedule.from_yaml(yaml_string)
# compare without usecs
- schedule.first(10).map { |r| r.to_s }.should == schedule2.first(10).map { |r| r.to_s }
+ schedule.first(10).map { |r| r.to_s }.should == schedule2.first(10).map { |r| r.to_s }
end
it 'should be able to make a round-trip to YAML with .month_of_year' do
schedule = IceCube::Schedule.new(Time.now)
schedule.add_recurrence_rule IceCube::Rule.yearly.month_of_year(:april, :may)
-
+
yaml_string = schedule.to_yaml
schedule2 = IceCube::Schedule.from_yaml(yaml_string)
# compare without usecs
- schedule.first(10).map { |r| r.to_s }.should == schedule2.first(10).map { |r| r.to_s }
+ schedule.first(10).map { |r| r.to_s }.should == schedule2.first(10).map { |r| r.to_s }
end
it 'should be able to make a round-trip to YAML with .second_of_minute' do
schedule = IceCube::Schedule.new(Time.now)
schedule.add_recurrence_rule IceCube::Rule.daily.second_of_minute(1, 2)
-
+
yaml_string = schedule.to_yaml
schedule2 = IceCube::Schedule.from_yaml(yaml_string)
# compare without usecs
- schedule.first(10).map { |r| r.to_s }.should == schedule2.first(10).map { |r| r.to_s }
+ schedule.first(10).map { |r| r.to_s }.should == schedule2.first(10).map { |r| r.to_s }
end
it 'should have a to_yaml representation of a rule that does not contain ruby objects' do
rule = IceCube::Rule.daily.day_of_week(:monday => [1, -1]).month_of_year(:april)
- rule.to_yaml.include?('object').should be(false)
+ rule.to_yaml.include?('object').should be_false
end
it 'should have a to_yaml representation of a schedule that does not contain ruby objects' do
schedule = IceCube::Schedule.new(Time.now)
schedule.add_recurrence_rule IceCube::Rule.daily.day_of_week(:monday => [1, -1]).month_of_year(:april)
- schedule.to_yaml.include?('object').should be(false)
+ schedule.to_yaml.include?('object').should be_false
end
# This test will fail when not run in Eastern Time
@@ -152,7 +152,7 @@
ice_cube_start_date.should == start_date
ice_cube_start_date.utc_offset.should == start_date.utc_offset
end
-
+
it 'should be able to roll forward times and get back times in an array - Time' do
start_date = Time.now
schedule = IceCube::Schedule.new(start_date)
@@ -175,7 +175,7 @@
it 'should be able to make a round trip with an exdate' do
schedule = IceCube::Schedule.new
- schedule.add_exception_time (time = Time.now)
+ schedule.add_exception_time(time = Time.now)
schedule = IceCube::Schedule.from_yaml schedule.to_yaml
schedule.exdates.map(&:to_s).should == [time.to_s]
end
@@ -183,7 +183,7 @@
it 'crazy shit' do
start_date = Time.zone.now
schedule = IceCube::Schedule.new(start_date)
-
+
schedule.add_recurrence_rule IceCube::Rule.weekly.day(:wednesday)
schedule.add_recurrence_date start_date
@@ -229,9 +229,9 @@
Time.zone = pacific_time
schedule = IceCube::Schedule.new(Time.zone.now)
schedule.add_recurrence_rule IceCube::Rule.weekly
- schedule.occurs_on?(schedule.start_time.to_date + 6).should be(false)
- schedule.occurs_on?(schedule.start_time.to_date + 7).should be(true)
- schedule.occurs_on?(schedule.start_time.to_date + 8).should be(false)
+ schedule.occurs_on?(schedule.start_time.to_date + 6).should be_false
+ schedule.occurs_on?(schedule.start_time.to_date + 7).should be_true
+ schedule.occurs_on?(schedule.start_time.to_date + 8).should be_false
end
it 'should work with occurs_on and TimeWithZone' do
@@ -240,9 +240,9 @@
Time.zone = pacific_time
schedule = IceCube::Schedule.new(start_time)
schedule.add_recurrence_time start_time + 7 * IceCube::ONE_DAY
- schedule.occurs_on?(schedule.start_time.to_date + 6).should be(false)
- schedule.occurs_on?(schedule.start_time.to_date + 7).should be(true)
- schedule.occurs_on?(schedule.start_time.to_date + 8).should be(false)
+ schedule.occurs_on?(schedule.start_time.to_date + 6).should be_false
+ schedule.occurs_on?(schedule.start_time.to_date + 7).should be_true
+ schedule.occurs_on?(schedule.start_time.to_date + 8).should be_false
end
it 'should crazy patch' do
@@ -250,9 +250,9 @@
day = Time.zone.parse('21 Oct 2010 02:00:00')
schedule = IceCube::Schedule.new(day)
schedule.add_recurrence_date(day)
- schedule.occurs_on?(Date.new(2010, 10, 20)).should be(false)
- schedule.occurs_on?(Date.new(2010, 10, 21)).should be(true)
- schedule.occurs_on?(Date.new(2010, 10, 22)).should be(false)
+ schedule.occurs_on?(Date.new(2010, 10, 20)).should be_false
+ schedule.occurs_on?(Date.new(2010, 10, 21)).should be_true
+ schedule.occurs_on?(Date.new(2010, 10, 22)).should be_false
end
it 'should be able to bring a Rule to_yaml and back with a timezone' do
View
2  spec/examples/weekly_rule_spec.rb
@@ -41,7 +41,7 @@
now = Time.now
schedule = IceCube::Schedule.new(Time.local(now.year, now.month, now.day))
schedule.add_recurrence_rule IceCube::Rule.monthly.hour_of_day(11).day_of_week(:tuesday => [2])
- schedule.first(100).each do |d|
+ schedule.first(100).each do |d|
d.hour.should == 11
d.wday.should == 2
end
View
2  spec/examples/yearly_rule_spec.rb
@@ -9,7 +9,7 @@
#check assumption - over 1 year should be 2
schedule.occurrences(start_date + IceCube::TimeUtil.days_in_year(start_date) * IceCube::ONE_DAY).size.should == 2
end
-
+
it 'should produce the correct number of days for @interval = 1' do
start_date = Time.now
schedule = IceCube::Schedule.new(start_date)
Please sign in to comment.
Something went wrong with that request. Please try again.