by_star 3.0.0 → 4.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/mysql.yml +92 -0
  3. data/.github/workflows/postgresql.yml +99 -0
  4. data/.gitignore +6 -5
  5. data/.travis.yml +92 -61
  6. data/CHANGELOG.md +63 -44
  7. data/Gemfile +18 -18
  8. data/MIT-LICENSE +20 -20
  9. data/README.md +616 -577
  10. data/Rakefile +18 -18
  11. data/UPGRADING +4 -6
  12. data/by_star.gemspec +34 -34
  13. data/cleaner.rb +24 -24
  14. data/lib/by_star/base.rb +69 -68
  15. data/lib/by_star/between.rb +185 -156
  16. data/lib/by_star/directional.rb +35 -37
  17. data/lib/by_star/kernel/date.rb +41 -50
  18. data/lib/by_star/kernel/in_time_zone.rb +20 -0
  19. data/lib/by_star/kernel/time.rb +41 -41
  20. data/lib/by_star/normalization.rb +156 -127
  21. data/lib/by_star/orm/active_record/by_star.rb +75 -61
  22. data/lib/by_star/orm/mongoid/by_star.rb +90 -76
  23. data/lib/by_star/orm/mongoid/reorder.rb +23 -23
  24. data/lib/by_star/version.rb +3 -3
  25. data/lib/by_star.rb +18 -17
  26. data/spec/database.yml +15 -15
  27. data/spec/fixtures/active_record/models.rb +12 -12
  28. data/spec/fixtures/active_record/schema.rb +19 -19
  29. data/spec/fixtures/mongoid/models.rb +31 -31
  30. data/spec/fixtures/shared/seeds.rb +36 -26
  31. data/spec/gemfiles/Gemfile.rails +5 -0
  32. data/spec/gemfiles/Gemfile.rails32 +7 -0
  33. data/spec/gemfiles/Gemfile.rails40 +7 -7
  34. data/spec/gemfiles/Gemfile.rails41 +7 -7
  35. data/spec/gemfiles/Gemfile.rails42 +7 -7
  36. data/spec/gemfiles/Gemfile.rails50 +7 -10
  37. data/spec/gemfiles/Gemfile.rails51 +7 -10
  38. data/spec/gemfiles/Gemfile.rails52 +7 -0
  39. data/spec/gemfiles/Gemfile.rails60 +7 -0
  40. data/spec/gemfiles/Gemfile.rails61 +7 -0
  41. data/spec/integration/active_record/active_record_spec.rb +41 -38
  42. data/spec/integration/mongoid/mongoid_spec.rb +39 -37
  43. data/spec/integration/shared/at_time.rb +53 -0
  44. data/spec/integration/shared/between_dates.rb +99 -0
  45. data/spec/integration/shared/between_times.rb +99 -82
  46. data/spec/integration/shared/by_calendar_month.rb +55 -55
  47. data/spec/integration/shared/by_cweek.rb +54 -54
  48. data/spec/integration/shared/by_day.rb +120 -96
  49. data/spec/integration/shared/by_direction.rb +126 -172
  50. data/spec/integration/shared/by_fortnight.rb +48 -48
  51. data/spec/integration/shared/by_month.rb +50 -50
  52. data/spec/integration/shared/by_quarter.rb +49 -49
  53. data/spec/integration/shared/by_week.rb +54 -54
  54. data/spec/integration/shared/by_weekend.rb +49 -49
  55. data/spec/integration/shared/by_year.rb +48 -48
  56. data/spec/integration/shared/index_scope_parameter.rb +111 -0
  57. data/spec/integration/shared/offset_parameter.rb +32 -32
  58. data/spec/integration/shared/order_parameter.rb +36 -36
  59. data/spec/integration/shared/relative.rb +174 -174
  60. data/spec/spec_helper.rb +33 -29
  61. data/spec/unit/kernel_date_spec.rb +113 -113
  62. data/spec/unit/kernel_time_spec.rb +57 -57
  63. data/spec/unit/normalization_spec.rb +384 -305
  64. data/tmp/.gitignore +1 -1
  65. metadata +33 -21
  66. data/spec/gemfiles/Gemfile.master +0 -6
  67. data/spec/integration/shared/scope_parameter.rb +0 -73
@@ -1,174 +1,174 @@
1
- require 'spec_helper'
2
-
3
- shared_examples_for 'relative' do
4
-
5
- describe '#past_day' do
6
- context 'point-in-time' do
7
- subject { Post.past_day }
8
- it { expect(subject.count).to eql(1) }
9
- end
10
-
11
- context 'timespan' do
12
- subject { Event.past_day }
13
- it { expect(subject.count).to eql(5) }
14
- end
15
-
16
- context 'timespan strict' do
17
- subject { Event.past_day(strict: true) }
18
- it { expect(subject.count).to eql(0) }
19
- end
20
- end
21
-
22
- describe '#past_week' do
23
- context 'point-in-time' do
24
- subject { Post.past_week }
25
- it { expect(subject.count).to eql(3) }
26
- end
27
-
28
- context 'timespan' do
29
- subject { Event.past_week }
30
- it { expect(subject.count).to eql(7) }
31
- end
32
-
33
- context 'timespan strict' do
34
- subject { Event.past_week(strict: true) }
35
- it { expect(subject.count).to eql(0) }
36
- end
37
- end
38
-
39
- describe '#past_fortnight' do
40
- context 'point-in-time' do
41
- subject { Post.past_fortnight }
42
- it { expect(subject.count).to eql(4) }
43
- end
44
-
45
- context 'timespan' do
46
- subject { Event.past_fortnight }
47
- it { expect(subject.count).to eql(8) }
48
- end
49
-
50
- context 'timespan strict' do
51
- subject { Event.past_fortnight(strict: true) }
52
- it { expect(subject.count).to eql(1) }
53
- end
54
- end
55
-
56
- describe '#past_month' do
57
- context 'point-in-time' do
58
- subject { Post.past_month }
59
- it { expect(subject.count).to eql(8) }
60
- end
61
-
62
- context 'timespan' do
63
- subject { Event.past_month }
64
- it { expect(subject.count).to eql(12) }
65
- end
66
-
67
- context 'timespan strict' do
68
- subject { Event.past_month(strict: true) }
69
- it { expect(subject.count).to eql(4) }
70
- end
71
- end
72
-
73
- describe '#past_year' do
74
- context 'point-in-time' do
75
- subject { Post.past_year }
76
- it { expect(subject.count).to eql(10) }
77
- end
78
-
79
- context 'timespan' do
80
- subject { Event.past_year }
81
- it { expect(subject.count).to eql(13) }
82
- end
83
-
84
- context 'timespan strict' do
85
- subject { Event.past_year(strict: true) }
86
- it { expect(subject.count).to eql(8) }
87
- end
88
- end
89
-
90
- describe '#next_day' do
91
- context 'point-in-time' do
92
- subject { Post.next_day }
93
- it { expect(subject.count).to eql(2) }
94
- end
95
-
96
- context 'timespan' do
97
- subject { Event.next_day }
98
- it { expect(subject.count).to eql(5) }
99
- end
100
-
101
- context 'timespan strict' do
102
- subject { Event.next_day(strict: true) }
103
- it { expect(subject.count).to eql(0) }
104
- end
105
- end
106
-
107
- describe '#next_week' do
108
- context 'point-in-time' do
109
- subject { Post.next_week }
110
- it { expect(subject.count).to eql(3) }
111
- end
112
-
113
- context 'timespan' do
114
- subject { Event.next_week }
115
- it { expect(subject.count).to eql(7) }
116
- end
117
-
118
- context 'timespan strict' do
119
- subject { Event.next_week(strict: true) }
120
- it { expect(subject.count).to eql(0) }
121
- end
122
- end
123
-
124
- describe '#next_fortnight' do
125
- context 'point-in-time' do
126
- subject { Post.next_fortnight }
127
- it { expect(subject.count).to eql(5) }
128
- end
129
-
130
- context 'timespan' do
131
- subject { Event.next_fortnight }
132
- it { expect(subject.count).to eql(7) }
133
- end
134
-
135
- context 'timespan strict' do
136
- subject { Event.next_fortnight(strict: true) }
137
- it { expect(subject.count).to eql(0) }
138
- end
139
- end
140
-
141
- describe '#next_month' do
142
- context 'point-in-time' do
143
- subject { Post.next_month }
144
- it { expect(subject.count).to eql(6) }
145
- end
146
-
147
- context 'timespan' do
148
- subject { Event.next_month }
149
- it { expect(subject.count).to eql(9) }
150
- end
151
-
152
- context 'timespan strict' do
153
- subject { Event.next_month(strict: true) }
154
- it { expect(subject.count).to eql(3) }
155
- end
156
- end
157
-
158
- describe '#next_year' do
159
- context 'point-in-time' do
160
- subject { Post.next_year }
161
- it { expect(subject.count).to eql(12) }
162
- end
163
-
164
- context 'timespan' do
165
- subject { Event.next_year }
166
- it { expect(subject.count).to eql(14) }
167
- end
168
-
169
- context 'timespan strict' do
170
- subject { Event.next_year(strict: true) }
171
- it { expect(subject.count).to eql(9) }
172
- end
173
- end
174
- end
1
+ require 'spec_helper'
2
+
3
+ shared_examples_for 'relative' do
4
+
5
+ describe '#past_day' do
6
+ context 'point-in-time' do
7
+ subject { Post.past_day }
8
+ it { expect(subject.count).to eql(1) }
9
+ end
10
+
11
+ context 'timespan' do
12
+ subject { Event.past_day }
13
+ it { expect(subject.count).to eql(5) }
14
+ end
15
+
16
+ context 'timespan strict' do
17
+ subject { Event.past_day(strict: true) }
18
+ it { expect(subject.count).to eql(0) }
19
+ end
20
+ end
21
+
22
+ describe '#past_week' do
23
+ context 'point-in-time' do
24
+ subject { Post.past_week }
25
+ it { expect(subject.count).to eql(3) }
26
+ end
27
+
28
+ context 'timespan' do
29
+ subject { Event.past_week }
30
+ it { expect(subject.count).to eql(7) }
31
+ end
32
+
33
+ context 'timespan strict' do
34
+ subject { Event.past_week(strict: true) }
35
+ it { expect(subject.count).to eql(0) }
36
+ end
37
+ end
38
+
39
+ describe '#past_fortnight' do
40
+ context 'point-in-time' do
41
+ subject { Post.past_fortnight }
42
+ it { expect(subject.count).to eql(4) }
43
+ end
44
+
45
+ context 'timespan' do
46
+ subject { Event.past_fortnight }
47
+ it { expect(subject.count).to eql(8) }
48
+ end
49
+
50
+ context 'timespan strict' do
51
+ subject { Event.past_fortnight(strict: true) }
52
+ it { expect(subject.count).to eql(1) }
53
+ end
54
+ end
55
+
56
+ describe '#past_month' do
57
+ context 'point-in-time' do
58
+ subject { Post.past_month }
59
+ it { expect(subject.count).to eql(8) }
60
+ end
61
+
62
+ context 'timespan' do
63
+ subject { Event.past_month }
64
+ it { expect(subject.count).to eql(12) }
65
+ end
66
+
67
+ context 'timespan strict' do
68
+ subject { Event.past_month(strict: true) }
69
+ it { expect(subject.count).to eql(4) }
70
+ end
71
+ end
72
+
73
+ describe '#past_year' do
74
+ context 'point-in-time' do
75
+ subject { Post.past_year }
76
+ it { expect(subject.count).to eql(10) }
77
+ end
78
+
79
+ context 'timespan' do
80
+ subject { Event.past_year }
81
+ it { expect(subject.count).to eql(13) }
82
+ end
83
+
84
+ context 'timespan strict' do
85
+ subject { Event.past_year(strict: true) }
86
+ it { expect(subject.count).to eql(8) }
87
+ end
88
+ end
89
+
90
+ describe '#next_day' do
91
+ context 'point-in-time' do
92
+ subject { Post.next_day }
93
+ it { expect(subject.count).to eql(2) }
94
+ end
95
+
96
+ context 'timespan' do
97
+ subject { Event.next_day }
98
+ it { expect(subject.count).to eql(5) }
99
+ end
100
+
101
+ context 'timespan strict' do
102
+ subject { Event.next_day(strict: true) }
103
+ it { expect(subject.count).to eql(0) }
104
+ end
105
+ end
106
+
107
+ describe '#next_week' do
108
+ context 'point-in-time' do
109
+ subject { Post.next_week }
110
+ it { expect(subject.count).to eql(3) }
111
+ end
112
+
113
+ context 'timespan' do
114
+ subject { Event.next_week }
115
+ it { expect(subject.count).to eql(7) }
116
+ end
117
+
118
+ context 'timespan strict' do
119
+ subject { Event.next_week(strict: true) }
120
+ it { expect(subject.count).to eql(0) }
121
+ end
122
+ end
123
+
124
+ describe '#next_fortnight' do
125
+ context 'point-in-time' do
126
+ subject { Post.next_fortnight }
127
+ it { expect(subject.count).to eql(5) }
128
+ end
129
+
130
+ context 'timespan' do
131
+ subject { Event.next_fortnight }
132
+ it { expect(subject.count).to eql(7) }
133
+ end
134
+
135
+ context 'timespan strict' do
136
+ subject { Event.next_fortnight(strict: true) }
137
+ it { expect(subject.count).to eql(0) }
138
+ end
139
+ end
140
+
141
+ describe '#next_month' do
142
+ context 'point-in-time' do
143
+ subject { Post.next_month }
144
+ it { expect(subject.count).to eql(6) }
145
+ end
146
+
147
+ context 'timespan' do
148
+ subject { Event.next_month }
149
+ it { expect(subject.count).to eql(9) }
150
+ end
151
+
152
+ context 'timespan strict' do
153
+ subject { Event.next_month(strict: true) }
154
+ it { expect(subject.count).to eql(3) }
155
+ end
156
+ end
157
+
158
+ describe '#next_year' do
159
+ context 'point-in-time' do
160
+ subject { Post.next_year }
161
+ it { expect(subject.count).to eql(12) }
162
+ end
163
+
164
+ context 'timespan' do
165
+ subject { Event.next_year }
166
+ it { expect(subject.count).to eql(14) }
167
+ end
168
+
169
+ context 'timespan strict' do
170
+ subject { Event.next_year(strict: true) }
171
+ it { expect(subject.count).to eql(9) }
172
+ end
173
+ end
174
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,29 +1,33 @@
1
- require 'rubygems'
2
- require 'bundler'
3
- Bundler.setup
4
- require 'fileutils'
5
- require 'logger'
6
-
7
- FileUtils.mkdir_p(File.dirname(__FILE__) + "/tmp")
8
- $:.unshift(File.join(File.dirname(__FILE__), "../lib"))
9
-
10
- require 'active_record'
11
- require 'mongoid'
12
- require 'chronic'
13
- require 'timecop'
14
- require 'by_star'
15
-
16
- # Specs should pass regardless of timezone
17
- Time.zone = %w(Asia/Tokyo America/New_York Australia/Sydney UTC).sample
18
- puts "Running specs in #{Time.zone} timezone..."
19
-
20
- # Set Rails time to 2014-01-01 00:00:00
21
- Timecop.travel(Time.zone.local(2014))
22
-
23
- def testing_mongoid?
24
- ENV['DB'] == 'mongodb'
25
- end
26
-
27
- def testing_active_record?
28
- !testing_mongoid?
29
- end
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ Bundler.setup
4
+ require 'fileutils'
5
+ require 'logger'
6
+
7
+ FileUtils.mkdir_p(File.dirname(__FILE__) + "/tmp")
8
+ $:.unshift(File.join(File.dirname(__FILE__), "../lib"))
9
+
10
+ require 'active_record'
11
+ require 'mongoid'
12
+ require 'chronic'
13
+ require 'timecop'
14
+ require 'by_star'
15
+
16
+ # Specs should pass regardless of timezone
17
+ Time.zone = %w(Asia/Tokyo America/New_York Australia/Sydney UTC).sample
18
+ puts "Running specs in #{Time.zone} timezone..."
19
+
20
+ # Set Rails time to 2014-01-01 00:00:00
21
+ Timecop.travel(Time.zone.local(2014))
22
+
23
+ RSpec.configure do |c|
24
+ c.filter_run_excluding sydney: true unless Time.zone.name == 'Australia/Sydney'
25
+ end
26
+
27
+ def testing_mongoid?
28
+ ENV['DB'] == 'mongodb'
29
+ end
30
+
31
+ def testing_active_record?
32
+ !testing_mongoid?
33
+ end
@@ -1,113 +1,113 @@
1
- require 'spec_helper'
2
-
3
- describe Date do
4
-
5
- describe '#in_time_zone' do
6
-
7
- subject { Date.new }
8
-
9
- before do
10
- stub_const('Date', Class.new)
11
- allow_any_instance_of(Date).to receive(:to_time_in_current_zone)
12
- end
13
-
14
- context 'when #in_time_zone is already defined' do
15
- before do
16
- expect_any_instance_of(Date).to receive(:in_time_zone)
17
- end
18
-
19
- context 'when ByStar::Kernel::Date included' do
20
- before do
21
- ::Date.__send__(:include, ByStar::Kernel::Date)
22
- end
23
-
24
- it 'should not be aliased to #to_time_in_current_zone' do
25
- expect(subject).not_to receive(:to_time_in_current_zone)
26
- subject.in_time_zone
27
- end
28
- end
29
-
30
- context 'when ByStar::Kernel::Date not included' do
31
-
32
- it 'should not be aliased to #to_time_in_current_zone' do
33
- expect(subject).not_to receive(:to_time_in_current_zone)
34
- subject.in_time_zone
35
- end
36
- end
37
- end
38
-
39
- context 'when #in_time_zone is not defined' do
40
-
41
- context 'when ByStar::Kernel::Date included' do
42
- before do
43
- ::Date.__send__(:include, ByStar::Kernel::Date)
44
- end
45
-
46
- it 'should be aliased to #to_time_in_current_zone' do
47
- expect(subject).to receive(:to_time_in_current_zone)
48
- subject.in_time_zone
49
- end
50
- end
51
-
52
- context 'when ByStar::Kernel::Date not included' do
53
-
54
- it 'should raise NoMethodError' do
55
- expect{ subject.in_time_zone }.to raise_error(NoMethodError)
56
- end
57
- end
58
- end
59
- end
60
-
61
- describe 'weekend' do
62
-
63
- (0..6).each do |n|
64
- context "Monday plus #{n} days" do
65
- subject { Date.parse('2014-01-06') + n.days }
66
- it { expect(subject.beginning_of_weekend).to eq Date.parse('2014-01-11') }
67
- it { expect(subject.end_of_weekend).to eq Date.parse('2014-01-12') }
68
- end
69
- end
70
- end
71
-
72
- describe 'fortnight' do
73
-
74
- context 'first day of year' do
75
- subject { Date.parse '2014-01-01' }
76
- it { expect(subject.beginning_of_fortnight).to eq Date.parse('2014-01-01') }
77
- it { expect(subject.end_of_fortnight).to eq Date.parse('2014-01-14') }
78
- end
79
-
80
- context 'second fortnight of year' do
81
- subject { Date.parse '2014-01-16' }
82
- it { expect(subject.beginning_of_fortnight).to eq Date.parse('2014-01-15') }
83
- it { expect(subject.end_of_fortnight).to eq Date.parse('2014-01-28') }
84
- end
85
-
86
- context 'middle of year' do
87
- subject { Date.parse '2014-06-13' }
88
- it { expect(subject.beginning_of_fortnight).to eq Date.parse('2014-06-04') }
89
- it { expect(subject.end_of_fortnight).to eq Date.parse('2014-06-17') }
90
- end
91
-
92
- context 'last day of year' do
93
- subject { Date.parse '2014-12-31' }
94
- it { expect(subject.beginning_of_fortnight).to eq Date.parse('2014-12-31') }
95
- it { expect(subject.end_of_fortnight).to eq Date.parse('2015-01-13') }
96
- end
97
- end
98
-
99
- describe 'calendar_month' do
100
-
101
- subject { Date.parse '2014-01-01' }
102
-
103
- context 'week begins Monday' do
104
- it { expect(subject.beginning_of_calendar_month).to eq Date.parse('2013-12-30') }
105
- it { expect(subject.end_of_calendar_month).to eq Date.parse('2014-02-02') }
106
- end
107
-
108
- context 'week begins Sunday' do
109
- it { expect(subject.beginning_of_calendar_month(:sunday)).to eq Date.parse('2013-12-29') }
110
- it { expect(subject.end_of_calendar_month(:sunday)).to eq Date.parse('2014-02-01') }
111
- end
112
- end
113
- end
1
+ require 'spec_helper'
2
+
3
+ describe Date do
4
+
5
+ describe '#in_time_zone' do
6
+
7
+ subject { Date.new }
8
+
9
+ before do
10
+ stub_const('Date', Class.new)
11
+ allow_any_instance_of(Date).to receive(:to_time_in_current_zone)
12
+ end
13
+
14
+ context 'when #in_time_zone is already defined' do
15
+ before do
16
+ expect_any_instance_of(Date).to receive(:in_time_zone)
17
+ end
18
+
19
+ context 'when ByStar::Kernel::InTimeZone included' do
20
+ before do
21
+ ::Date.__send__(:include, ByStar::Kernel::InTimeZone)
22
+ end
23
+
24
+ it 'should not be aliased to #to_time_in_current_zone' do
25
+ expect(subject).not_to receive(:to_time_in_current_zone)
26
+ subject.in_time_zone
27
+ end
28
+ end
29
+
30
+ context 'when ByStar::Kernel::InTimeZone not included' do
31
+
32
+ it 'should not be aliased to #to_time_in_current_zone' do
33
+ expect(subject).not_to receive(:to_time_in_current_zone)
34
+ subject.in_time_zone
35
+ end
36
+ end
37
+ end
38
+
39
+ context 'when #in_time_zone is not defined' do
40
+
41
+ context 'when ByStar::Kernel::InTimeZone included' do
42
+ before do
43
+ ::Date.__send__(:include, ByStar::Kernel::InTimeZone)
44
+ end
45
+
46
+ it 'should be aliased to #to_time_in_current_zone' do
47
+ expect(subject).to receive(:to_time_in_current_zone)
48
+ subject.in_time_zone
49
+ end
50
+ end
51
+
52
+ context 'when ByStar::Kernel::InTimeZone not included' do
53
+
54
+ it 'should raise NoMethodError' do
55
+ expect{ subject.in_time_zone }.to raise_error(NoMethodError)
56
+ end
57
+ end
58
+ end
59
+ end
60
+
61
+ describe 'weekend' do
62
+
63
+ (0..6).each do |n|
64
+ context "Monday plus #{n} days" do
65
+ subject { Date.parse('2014-01-06') + n.days }
66
+ it { expect(subject.beginning_of_weekend).to eq Date.parse('2014-01-11') }
67
+ it { expect(subject.end_of_weekend).to eq Date.parse('2014-01-12') }
68
+ end
69
+ end
70
+ end
71
+
72
+ describe 'fortnight' do
73
+
74
+ context 'first day of year' do
75
+ subject { Date.parse '2014-01-01' }
76
+ it { expect(subject.beginning_of_fortnight).to eq Date.parse('2014-01-01') }
77
+ it { expect(subject.end_of_fortnight).to eq Date.parse('2014-01-14') }
78
+ end
79
+
80
+ context 'second fortnight of year' do
81
+ subject { Date.parse '2014-01-16' }
82
+ it { expect(subject.beginning_of_fortnight).to eq Date.parse('2014-01-15') }
83
+ it { expect(subject.end_of_fortnight).to eq Date.parse('2014-01-28') }
84
+ end
85
+
86
+ context 'middle of year' do
87
+ subject { Date.parse '2014-06-13' }
88
+ it { expect(subject.beginning_of_fortnight).to eq Date.parse('2014-06-04') }
89
+ it { expect(subject.end_of_fortnight).to eq Date.parse('2014-06-17') }
90
+ end
91
+
92
+ context 'last day of year' do
93
+ subject { Date.parse '2014-12-31' }
94
+ it { expect(subject.beginning_of_fortnight).to eq Date.parse('2014-12-31') }
95
+ it { expect(subject.end_of_fortnight).to eq Date.parse('2015-01-13') }
96
+ end
97
+ end
98
+
99
+ describe 'calendar_month' do
100
+
101
+ subject { Date.parse '2014-01-01' }
102
+
103
+ context 'week begins Monday' do
104
+ it { expect(subject.beginning_of_calendar_month).to eq Date.parse('2013-12-30') }
105
+ it { expect(subject.end_of_calendar_month).to eq Date.parse('2014-02-02') }
106
+ end
107
+
108
+ context 'week begins Sunday' do
109
+ it { expect(subject.beginning_of_calendar_month(:sunday)).to eq Date.parse('2013-12-29') }
110
+ it { expect(subject.end_of_calendar_month(:sunday)).to eq Date.parse('2014-02-01') }
111
+ end
112
+ end
113
+ end