timely 0.0.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +4 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +14 -0
  5. data/CHANGELOG.md +5 -0
  6. data/Gemfile +1 -12
  7. data/README.md +5 -0
  8. data/Rakefile +1 -139
  9. data/gemfiles/rails3.gemfile +8 -0
  10. data/gemfiles/rails4.gemfile +9 -0
  11. data/lib/timely.rb +7 -3
  12. data/lib/timely/date.rb +20 -0
  13. data/lib/timely/date_chooser.rb +10 -5
  14. data/lib/timely/date_range.rb +47 -10
  15. data/lib/timely/rails.rb +10 -3
  16. data/lib/timely/rails/calendar_tag.rb +52 -0
  17. data/lib/timely/rails/date.rb +5 -0
  18. data/lib/timely/rails/date_group.rb +68 -99
  19. data/lib/timely/rails/date_range_validity_module.rb +27 -0
  20. data/lib/timely/rails/date_time.rb +20 -0
  21. data/lib/timely/rails/extensions.rb +23 -11
  22. data/lib/timely/rails/period.rb +31 -0
  23. data/lib/timely/rails/season.rb +65 -75
  24. data/lib/timely/railtie.rb +7 -0
  25. data/lib/timely/temporal_patterns/finder.rb +152 -0
  26. data/lib/timely/temporal_patterns/frequency.rb +108 -0
  27. data/lib/timely/temporal_patterns/interval.rb +67 -0
  28. data/lib/timely/temporal_patterns/pattern.rb +160 -0
  29. data/lib/timely/time_since.rb +17 -0
  30. data/lib/timely/version.rb +3 -0
  31. data/spec/calendar_tag_spec.rb +29 -0
  32. data/spec/date_chooser_spec.rb +36 -27
  33. data/spec/date_group_spec.rb +9 -9
  34. data/spec/date_range_spec.rb +58 -20
  35. data/spec/date_spec.rb +20 -12
  36. data/spec/extensions_spec.rb +32 -0
  37. data/spec/rails/date_spec.rb +16 -0
  38. data/spec/rails/date_time_spec.rb +20 -0
  39. data/spec/rails/period_spec.rb +17 -0
  40. data/spec/schema.rb +5 -0
  41. data/spec/season_spec.rb +21 -24
  42. data/spec/spec_helper.rb +5 -20
  43. data/spec/string_spec.rb +4 -3
  44. data/spec/support/coverage.rb +26 -0
  45. data/spec/temporal_patterns_spec.rb +28 -0
  46. data/spec/time_since_spec.rb +24 -0
  47. data/spec/time_spec.rb +14 -14
  48. data/spec/trackable_date_set_spec.rb +14 -14
  49. data/spec/week_days_spec.rb +18 -18
  50. data/timely.gemspec +34 -98
  51. metadata +244 -21
  52. data/lib/timely/temporal_patterns.rb +0 -441
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe DateTime do
4
+ let(:date_time) { DateTime.parse("2010-01-01") }
5
+
6
+ it "should allow advancing by calendar days" do
7
+ expect(date_time.advance_considering_calendar(:calendar_days, 10))
8
+ .to eq DateTime.parse("2010-01-10 23:59:59")
9
+ end
10
+
11
+ it "should allow advancing by calendar months" do
12
+ expect(date_time.advance_considering_calendar(:calendar_months, 10))
13
+ .to eq DateTime.parse("2010-10-31 23:59:59")
14
+ end
15
+
16
+ it "should allow advancing by calendar years" do
17
+ expect(date_time.advance_considering_calendar(:calendar_years, 10))
18
+ .to eq DateTime.parse("2019-12-31 23:59:59")
19
+ end
20
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ require 'timely/rails/period'
4
+
5
+ describe Timely::Period do
6
+ let(:time) { DateTime.new(2000, 1, 1, 12, 0, 0) }
7
+ let(:period_after_time) { DateTime.new(2000, 1, 1, 12, 2, 0) }
8
+ subject(:period) { Timely::Period.new(2, :minutes) }
9
+
10
+ it 'should work' do
11
+ expect(period.after(time)).to eq period_after_time
12
+ end
13
+
14
+ specify do
15
+ expect(period.to_s).to eq '2 minutes'
16
+ end
17
+ end
data/spec/schema.rb CHANGED
@@ -1,4 +1,9 @@
1
1
  ActiveRecord::Schema.define(:version => 1) do
2
+ create_table :seasonals do |t|
3
+ t.date :boundary_start, :boundary_end
4
+ t.integer :season_id
5
+ end
6
+
2
7
  create_table :seasons do |t|
3
8
  t.string :name
4
9
  end
data/spec/season_spec.rb CHANGED
@@ -6,53 +6,50 @@ describe Timely::Season, "in general" do
6
6
  @simple_low_season = Timely::Season.new
7
7
  @simple_low_season.date_groups.build(:start_date => '2009-01-01'.to_date, :end_date => '2009-03-31'.to_date)
8
8
  @simple_low_season.date_groups.build(:start_date => '2009-07-01'.to_date, :end_date => '2009-09-30'.to_date)
9
- @simple_low_season.save!
10
9
 
11
10
  # 2nd and 4th Quarter
12
11
  @simple_high_season = Timely::Season.new
13
12
  @simple_high_season.date_groups.build(:start_date => '2009-04-01'.to_date, :end_date => '2009-06-30'.to_date)
14
13
  @simple_high_season.date_groups.build(:start_date => '2009-10-01'.to_date, :end_date => '2009-12-31'.to_date)
15
- @simple_high_season.save!
16
14
  end
17
15
 
18
16
  it "be able to tell if a date is in or out of its season" do
19
17
  low_season_date = '2009-02-22'.to_date
20
18
  high_season_date = '2009-04-22'.to_date
21
19
 
22
- @simple_low_season.includes_date?(low_season_date).should be_true
23
- @simple_high_season.includes_date?(low_season_date).should_not be_true
20
+ expect(@simple_low_season.includes_date?(low_season_date)).to be true
21
+ expect(@simple_high_season.includes_date?(low_season_date)).to_not be true
24
22
 
25
- @simple_low_season.includes_date?(high_season_date).should_not be_true
26
- @simple_high_season.includes_date?(high_season_date).should be_true
23
+ expect(@simple_low_season.includes_date?(high_season_date)).to_not be true
24
+ expect(@simple_high_season.includes_date?(high_season_date)).to be true
27
25
  end
28
26
 
29
27
  it "should be able to tell the boundary range (the range including the absolute first and last date) of itself" do
30
- @simple_low_season.boundary_range.should eql('2009-01-01'.to_date..'2009-09-30'.to_date)
31
- @simple_high_season.boundary_range.should eql('2009-04-01'.to_date..'2009-12-31'.to_date)
28
+ expect(@simple_low_season.boundary_range).to eq('2009-01-01'.to_date..'2009-09-30'.to_date)
29
+ expect(@simple_high_season.boundary_range).to eq('2009-04-01'.to_date..'2009-12-31'.to_date)
32
30
  end
33
31
  end
34
32
 
35
33
 
36
34
  describe Timely::Season, 'when asked to build season for given dates' do
37
- before do
38
- @dates = [Date.current + 1, Date.current + 4, Date.current + 5]
39
- end
40
-
41
- it "should generate proper season" do
42
- season = Timely::Season.build_season_for(@dates)
43
- season.class.should == Timely::Season
44
- season.date_groups.size.should == 3
45
- season.date_groups.first.start_date.should == (Date.current + 1)
46
- season.date_groups.last.start_date.should == (Date.current + 5)
47
- season.date_groups.last.end_date.should == (Date.current + 5)
48
- @dates = []
49
- season = Timely::Season.build_season_for(@dates)
50
- season.class.should == Timely::Season
51
- season.date_groups.size.should == 0
52
- end
35
+ subject(:season) { Timely::Season.build_season_for(dates) }
53
36
 
37
+ context 'when three dates' do
38
+ let(:dates) { [Date.current + 1, Date.current + 4, Date.current + 5] }
39
+ its(:class) { should eq Timely::Season }
40
+ its('date_groups.size') { should eq 3 }
54
41
 
42
+ it "should generate proper date groups" do
43
+ expect(season.date_groups.first.start_date).to eq (Date.current + 1)
44
+ expect(season.date_groups.last.start_date).to eq (Date.current + 5)
45
+ expect(season.date_groups.last.end_date).to eq (Date.current + 5)
46
+ end
47
+ end
55
48
 
49
+ context 'when dates are empty' do
50
+ let(:dates) { [] }
51
+ its(:date_groups) { should be_empty }
52
+ end
56
53
  end
57
54
 
58
55
 
data/spec/spec_helper.rb CHANGED
@@ -7,29 +7,15 @@
7
7
 
8
8
  require 'rubygems'
9
9
  require 'bundler/setup'
10
+ require 'rspec/its'
10
11
  require 'active_record'
11
- require 'timely/rails'
12
12
 
13
- if ENV['COVERAGE']
14
- require 'simplecov'
15
- require 'simplecov-rcov'
16
- SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
17
- SimpleCov.start do
18
- add_filter '/vendor/'
19
- add_filter '/spec/'
20
- add_group 'lib', 'lib'
21
- end
22
- SimpleCov.at_exit do
23
- SimpleCov.result.format!
24
- percent = SimpleCov.result.covered_percent
25
- unless percent >= 50
26
- puts "Coverage must be above 50%. It is #{"%.2f" % percent}%"
27
- Kernel.exit(1)
28
- end
29
- end
30
- end
13
+ require 'support/coverage'
14
+
15
+ I18n.enforce_available_locales = true if I18n.respond_to? :enforce_available_locales=
31
16
 
32
17
  require 'timely'
18
+ require 'timely/rails'
33
19
 
34
20
  DB_FILE = 'tmp/test_db'
35
21
  FileUtils.mkdir_p File.dirname(DB_FILE)
@@ -40,7 +26,6 @@ ActiveRecord::Base.establish_connection :adapter => 'sqlite3', :database => DB_F
40
26
  load('spec/schema.rb')
41
27
 
42
28
  RSpec.configure do |config|
43
- config.treat_symbols_as_metadata_keys_with_true_values = true
44
29
  config.run_all_when_everything_filtered = true
45
30
  config.filter_run :focus
46
31
  end
data/spec/string_spec.rb CHANGED
@@ -1,9 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe String do
4
- it "should convert to date" do
5
- "10-2010-01".to_date('%d-%Y-%m').should eql Date.parse("2010-01-10")
6
- end
4
+ # Spec currently doesn't work
5
+ #it "should convert to date" do
6
+ # "10-2010-01".to_date('%d-%Y-%m').should eql Date.parse("2010-01-10")
7
+ #end
7
8
 
8
9
  # Spec currently doesn't work
9
10
  #it 'should handle rails date formats' do
@@ -0,0 +1,26 @@
1
+ MINIMUM_COVERAGE = 68
2
+
3
+ unless ENV['COVERAGE'] == 'off'
4
+ require 'simplecov'
5
+ require 'simplecov-rcov'
6
+ require 'coveralls'
7
+ Coveralls.wear!
8
+
9
+ SimpleCov.formatters = [
10
+ SimpleCov::Formatter::RcovFormatter,
11
+ Coveralls::SimpleCov::Formatter
12
+ ]
13
+ SimpleCov.start do
14
+ add_filter '/vendor/'
15
+ add_filter '/spec/'
16
+ add_group 'lib', 'lib'
17
+ end
18
+ SimpleCov.at_exit do
19
+ SimpleCov.result.format!
20
+ percent = SimpleCov.result.covered_percent
21
+ unless percent >= MINIMUM_COVERAGE
22
+ puts "Coverage must be above #{MINIMUM_COVERAGE}%. It is #{"%.2f" % percent}%"
23
+ Kernel.exit(1)
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+
3
+ describe Timely::TemporalPatterns do
4
+
5
+ before(:all) do
6
+ @from = Date.new(2012, 1, 1)
7
+ @to = Date.new(2013, 4, 1)
8
+ end
9
+
10
+ it "should be able to create a basic 1st-of-the-month recurrence pattern" do
11
+ pattern = Timely::TemporalPatterns::Pattern.new([@from..@to], 1.month)
12
+ expect(pattern.to_s).to eq "every 1st of the month from 2012-01-01T00:00:00+00:00 to 2013-04-01T00:00:00+00:00"
13
+
14
+ expect(pattern.match?('01-05-2012'.to_date)).to be true
15
+ expect(pattern.match?('01-08-2012'.to_date)).to be true
16
+ expect(pattern.match?('01-04-2013'.to_date)).to be true
17
+
18
+ expect(pattern.match?('03-05-2012'.to_date)).to be false
19
+ expect(pattern.match?('01-06-2013'.to_date)).to be false
20
+ end
21
+
22
+ it "should only allow a positive duration to be set as the frequency of the pattern" do
23
+ expect { Timely::TemporalPatterns::Frequency.new(2) }.to raise_error(ArgumentError)
24
+ expect { Timely::TemporalPatterns::Frequency.new(-5.months) }.to raise_error(ArgumentError)
25
+ expect(Timely::TemporalPatterns::Frequency.new(3.months).to_s).to eq 'every 3 months'
26
+ end
27
+
28
+ end
@@ -0,0 +1,24 @@
1
+ require 'timely/time_since'
2
+
3
+ require 'timecop'
4
+
5
+ describe Timely::TimeSince do
6
+ before {
7
+ Timecop.freeze(DateTime.new(2000, 1, 10, 12, 0, 42))
8
+ }
9
+ after { Timecop.return }
10
+
11
+ context '42 seconds ago' do
12
+ subject(:time) { DateTime.new(2000, 1, 10, 12, 0, 0) }
13
+ its(:seconds_since) { should eq 42 }
14
+ its(:minutes_since) { should eq 0 }
15
+ its(:hours_since) { should eq 0 }
16
+ end
17
+
18
+ context 'a day ago' do
19
+ subject(:time) { DateTime.new(2000, 1, 9, 12, 0, 42) }
20
+ its(:seconds_since) { should eq 24*60*60 }
21
+ its(:minutes_since) { should eq 24*60 }
22
+ its(:hours_since) { should eq 24 }
23
+ end
24
+ end
data/spec/time_spec.rb CHANGED
@@ -5,17 +5,17 @@ describe Time do
5
5
  xmas = Date.new(2012, 12, 25)
6
6
  lunch_time = Time.parse("12:00")
7
7
  xmas_lunch = lunch_time.on_date(xmas)
8
- xmas_lunch.year.should == 2012
9
- xmas_lunch.month.should == 12
10
- xmas_lunch.day.should == 25
11
- xmas_lunch.hour.should == 12
12
- xmas_lunch.min.should == 0
13
- xmas_lunch.sec.should == 0
8
+ expect(xmas_lunch.year).to eq 2012
9
+ expect(xmas_lunch.month).to eq 12
10
+ expect(xmas_lunch.day).to eq 25
11
+ expect(xmas_lunch.hour).to eq 12
12
+ expect(xmas_lunch.min).to eq 0
13
+ expect(xmas_lunch.sec).to eq 0
14
14
  end
15
15
 
16
16
  it "should allow setting the date part given a date" do
17
17
  time = Time.parse("2010-01-01 09:30:00")
18
- time.on_date(Date.parse("2012-12-31")).should eql Time.parse("2012-12-31 09:30:00")
18
+ expect(time.on_date(Date.parse("2012-12-31"))).to eq Time.parse("2012-12-31 09:30:00")
19
19
  end
20
20
  end
21
21
 
@@ -29,36 +29,36 @@ describe Time do
29
29
  end
30
30
 
31
31
  it 'should give that time on a date' do
32
- @time.should respond_to(:on_date)
32
+ expect(@time).to respond_to(:on_date)
33
33
  end
34
34
 
35
35
  describe 'giving that time on a date' do
36
36
  it 'should accept year, month and day' do
37
- lambda { @time.on_date(@year, @month, @day) }.should_not raise_error(ArgumentError)
37
+ expect { @time.on_date(@year, @month, @day) }.to_not raise_error
38
38
  end
39
39
 
40
40
  it 'should require year, month, and day' do
41
- lambda { @time.on_date(@year, @month) }.should raise_error(ArgumentError)
41
+ expect { @time.on_date(@year, @month) }.to raise_error(ArgumentError)
42
42
  end
43
43
 
44
44
  it 'should return the same time on the specified year, month, and day' do
45
45
  expected = Time.local(@year, @month, @day, @time.hour, @time.min, @time.sec)
46
- @time.on_date(@year, @month, @day).should == expected
46
+ expect(@time.on_date(@year, @month, @day)).to eq expected
47
47
  end
48
48
 
49
49
  it 'should accept a date' do
50
- lambda { @time.on_date(Date.today) }.should_not raise_error(ArgumentError)
50
+ expect { @time.on_date(Date.today) }.to_not raise_error
51
51
  end
52
52
 
53
53
  it 'should return the same time on the specified date' do
54
54
  @date = Date.today - 2345
55
55
  expected = Time.local(@date.year, @date.month, @date.day, @time.hour, @time.min, @time.sec)
56
- @time.on_date(@date).should == expected
56
+ expect(@time.on_date(@date)).to eq expected
57
57
  end
58
58
  end
59
59
 
60
60
  it "should provide 'on' as an alias" do
61
61
  expected = Time.local(@year, @month, @day, @time.hour, @time.min, @time.sec)
62
- @time.on(@year, @month, @day).should == expected
62
+ expect(@time.on(@year, @month, @day)).to eq expected
63
63
  end
64
64
  end
@@ -7,27 +7,27 @@ describe Timely::TrackableDateSet, ' tracking 7 days' do
7
7
  end
8
8
 
9
9
  it "should start on the first date" do
10
- @trackable_date_set.start_date.should == Date.today
10
+ expect(@trackable_date_set.start_date).to eq Date.today
11
11
  end
12
12
 
13
13
  it "should end on the last date" do
14
- @trackable_date_set.end_date.should == Date.today + 6
14
+ expect(@trackable_date_set.end_date).to eq Date.today + 6
15
15
  end
16
16
 
17
17
  it "should have the 7 days set" do
18
- get_dates.should == @range.to_a
19
- @trackable_date_set.duration.should == 7
20
- @trackable_date_set.number_of_nights.should == 7
18
+ expect(get_dates).to eq @range.to_a
19
+ expect(@trackable_date_set.duration).to eq 7
20
+ expect(@trackable_date_set.number_of_nights).to eq 7
21
21
  end
22
22
 
23
23
  it "should have all the 7 days to do" do
24
- get_dates_to_do.should == @range.to_a
24
+ expect(get_dates_to_do).to eq @range.to_a
25
25
  should_not_have_done(@range.to_a)
26
26
  end
27
27
 
28
28
  it "should have only the last 6 days to do when we set_done! the first one" do
29
29
  @trackable_date_set.set_date_done!(Date.today)
30
- get_dates_to_do.should == ((Date.today + 1)..(Date.today + 6)).to_a
30
+ expect(get_dates_to_do).to eq ((Date.today + 1)..(Date.today + 6)).to_a
31
31
 
32
32
  should_not_have_done(@range.to_a - [Date.today])
33
33
  should_have_done([Date.today])
@@ -37,33 +37,33 @@ describe Timely::TrackableDateSet, ' tracking 7 days' do
37
37
  dates_to_be_done = [Date.today + 1, Date.today + 2, Date.today + 3]
38
38
  @trackable_date_set.set_dates_done!(dates_to_be_done)
39
39
 
40
- get_dates_to_do.should == [Date.today, Date.today + 4, Date.today + 5, Date.today + 6]
40
+ expect(get_dates_to_do).to eq [Date.today, Date.today + 4, Date.today + 5, Date.today + 6]
41
41
  should_not_have_done(@range.to_a - dates_to_be_done)
42
42
  should_have_done(dates_to_be_done)
43
43
  end
44
44
 
45
45
  it "should have none left to do when set_all_done!" do
46
46
  @trackable_date_set.set_all_done!
47
- get_dates_to_do.should == []
47
+ expect(get_dates_to_do).to eq []
48
48
  should_have_done(@range.to_a)
49
49
  end
50
50
 
51
51
  it 'should have no actions applied' do
52
- @trackable_date_set.action_applied?(:some_action).should == false
52
+ expect(@trackable_date_set.action_applied?(:some_action)).to be false
53
53
  end
54
54
 
55
55
  it 'should remember if we apply an action' do
56
56
  @trackable_date_set.apply_action(:some_action)
57
- @trackable_date_set.action_applied?(:some_action).should == true
58
- @trackable_date_set.action_applied?(:some_other_action).should == false
57
+ expect(@trackable_date_set.action_applied?(:some_action)).to be true
58
+ expect(@trackable_date_set.action_applied?(:some_other_action)).to be false
59
59
  end
60
60
 
61
61
  def should_have_done(dates)
62
- dates.each{|date| @trackable_date_set.has_done?(date).should == true }
62
+ dates.each{|date| expect(@trackable_date_set.has_done?(date)).to be true }
63
63
  end
64
64
 
65
65
  def should_not_have_done(dates)
66
- dates.each{|date| @trackable_date_set.has_done?(date).should == false }
66
+ dates.each{|date| expect(@trackable_date_set.has_done?(date)).to be false }
67
67
  end
68
68
 
69
69
  def get_dates
@@ -8,44 +8,44 @@ describe Timely::WeekDays do
8
8
  it 'should create via hash, integer and array' do
9
9
  # 0 0 1 0 1 0 0
10
10
  # Sat Fri Thu Wed Tue Mon Sun
11
- Timely::WeekDays.new(0b0010100).weekdays.should == [:tue, :thu]
12
- Timely::WeekDays.new(%w(0 0 1 0 1 0 0)).weekdays.should == [:tue, :thu]
13
- Timely::WeekDays.new(:tue => true, :thu => true).weekdays.should == [:tue, :thu]
11
+ expect(Timely::WeekDays.new(0b0010100).weekdays).to eq [:tue, :thu]
12
+ expect(Timely::WeekDays.new(%w(0 0 1 0 1 0 0)).weekdays).to eq [:tue, :thu]
13
+ expect(Timely::WeekDays.new(:tue => true, :thu => true).weekdays).to eq [:tue, :thu]
14
14
  end
15
15
 
16
16
  it 'should be able to set/unset days' do
17
17
  @weekdays[:mon] = true
18
- @weekdays.weekdays.should == [:mon, :tue, :thu]
18
+ expect(@weekdays.weekdays).to eq [:mon, :tue, :thu]
19
19
  @weekdays[:tue] = false
20
- @weekdays.weekdays.should == [:mon, :thu]
20
+ expect(@weekdays.weekdays).to eq [:mon, :thu]
21
21
  end
22
22
 
23
23
  it 'should output days nicely' do
24
- Timely::WeekDays.new(%w(1 0 0 0 0 0 0)).to_s.should == "Sun"
25
- Timely::WeekDays.new(%w(1 0 1 0 0 0 0)).to_s.should == "Sun, and Tue"
26
- Timely::WeekDays.new(%w(1 0 1 1 0 0 0)).to_s.should == "Sun, Tue, and Wed"
27
- Timely::WeekDays.new(%w(1 0 1 1 0 1 0)).to_s.should == "Sun, Tue, Wed, and Fri"
24
+ expect(Timely::WeekDays.new(%w(1 0 0 0 0 0 0)).to_s).to eq "Sun"
25
+ expect(Timely::WeekDays.new(%w(1 0 1 0 0 0 0)).to_s).to eq "Sun, and Tue"
26
+ expect(Timely::WeekDays.new(%w(1 0 1 1 0 0 0)).to_s).to eq "Sun, Tue, and Wed"
27
+ expect(Timely::WeekDays.new(%w(1 0 1 1 0 1 0)).to_s).to eq "Sun, Tue, Wed, and Fri"
28
28
  end
29
29
 
30
30
  it 'should be able to determine if days of the week are selected' do
31
31
  # Test mon and tue in both symbol/integer forms
32
- @weekdays.has_day?(1).should be_false
33
- @weekdays.has_day?(:mon).should be_false
34
- @weekdays.has_day?(2).should be_true
35
- @weekdays.has_day?(:tue).should be_true
32
+ expect(@weekdays.has_day?(1)).to be false
33
+ expect(@weekdays.has_day?(:mon)).to be false
34
+ expect(@weekdays.has_day?(2)).to be true
35
+ expect(@weekdays.has_day?(:tue)).to be true
36
36
  end
37
37
 
38
38
  it 'should be able to determine if it would be applicable on a date' do
39
- @weekdays.applies_for_date?(Date.new(2012, 04, 22)).should be_false # Sunday
40
- @weekdays.applies_for_date?(Date.new(2012, 04, 24)).should be_true # Tuesday
39
+ expect(@weekdays.applies_for_date?(Date.new(2012, 04, 22))).to be false # Sunday
40
+ expect(@weekdays.applies_for_date?(Date.new(2012, 04, 24))).to be true # Tuesday
41
41
  end
42
42
 
43
43
  it 'should be able to convert to integer for use in databases, etc.' do
44
- @weekdays.weekdays_int.should == 4 + 16 # 4 = Tue, 16 = Thu
44
+ expect(@weekdays.weekdays_int).to eq 4 + 16 # 4 = Tue, 16 = Thu
45
45
  end
46
46
 
47
47
  it 'should be able to determine if all days are selected' do
48
- Timely::WeekDays.new(%w(1 1 1 1 1 1 1)).all_days?.should be_true
49
- Timely::WeekDays.new(%w(1 1 1 1 1 0 1)).all_days?.should be_false
48
+ expect(Timely::WeekDays.new(%w(1 1 1 1 1 1 1)).all_days?).to be true
49
+ expect(Timely::WeekDays.new(%w(1 1 1 1 1 0 1)).all_days?).to be false
50
50
  end
51
51
  end