rrule 0.4.1 → 0.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +3 -0
  3. data/.rubocop.yml +28 -0
  4. data/.travis.yml +27 -1
  5. data/Appraisals +27 -0
  6. data/CHANGELOG.md +14 -0
  7. data/Gemfile +9 -0
  8. data/Rakefile +9 -3
  9. data/gemfiles/activesupport_2.3_LTS.gemfile +16 -0
  10. data/gemfiles/activesupport_3.gemfile +16 -0
  11. data/gemfiles/activesupport_4.gemfile +15 -0
  12. data/gemfiles/activesupport_5.gemfile +15 -0
  13. data/gemfiles/activesupport_6.gemfile +15 -0
  14. data/gemfiles/activesupport_7.gemfile +15 -0
  15. data/lib/rrule/context.rb +5 -3
  16. data/lib/rrule/filters/by_month.rb +2 -0
  17. data/lib/rrule/filters/by_month_day.rb +2 -0
  18. data/lib/rrule/filters/by_week_day.rb +5 -3
  19. data/lib/rrule/filters/by_week_number.rb +2 -0
  20. data/lib/rrule/filters/by_year_day.rb +3 -1
  21. data/lib/rrule/frequencies/daily.rb +2 -0
  22. data/lib/rrule/frequencies/frequency.rb +4 -12
  23. data/lib/rrule/frequencies/monthly.rb +2 -0
  24. data/lib/rrule/frequencies/simple_weekly.rb +6 -6
  25. data/lib/rrule/frequencies/weekly.rb +2 -0
  26. data/lib/rrule/frequencies/yearly.rb +2 -0
  27. data/lib/rrule/generators/all_occurrences.rb +2 -0
  28. data/lib/rrule/generators/by_set_position.rb +2 -0
  29. data/lib/rrule/generators/generator.rb +5 -1
  30. data/lib/rrule/rule.rb +29 -37
  31. data/lib/rrule/version.rb +5 -0
  32. data/lib/rrule/weekday.rb +4 -2
  33. data/lib/rrule.rb +4 -0
  34. data/rrule.gemspec +18 -11
  35. data/scripts/benchmark.rb +3 -1
  36. metadata +30 -52
  37. data/spec/context_spec.rb +0 -261
  38. data/spec/filters/by_month_day_spec.rb +0 -35
  39. data/spec/filters/by_month_spec.rb +0 -35
  40. data/spec/filters/by_week_day_spec.rb +0 -35
  41. data/spec/filters/by_week_number_spec.rb +0 -41
  42. data/spec/filters/by_year_day_spec.rb +0 -35
  43. data/spec/frequencies/daily_spec.rb +0 -62
  44. data/spec/frequencies/monthly_spec.rb +0 -63
  45. data/spec/frequencies/simple_weekly_spec.rb +0 -32
  46. data/spec/frequencies/weekly_spec.rb +0 -92
  47. data/spec/frequencies/yearly_spec.rb +0 -54
  48. data/spec/generators/all_occurrences_spec.rb +0 -44
  49. data/spec/generators/by_set_position_spec.rb +0 -39
  50. data/spec/generators/generator_spec.rb +0 -110
  51. data/spec/rule_spec.rb +0 -2338
  52. data/spec/spec_helper.rb +0 -23
  53. data/spec/weekday_spec.rb +0 -34
data/lib/rrule.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'active_support/all'
2
4
 
3
5
  module RRule
@@ -22,6 +24,8 @@ module RRule
22
24
  autoload :AllOccurrences, 'rrule/generators/all_occurrences'
23
25
  autoload :BySetPosition, 'rrule/generators/by_set_position'
24
26
 
27
+ WEEKDAYS = %w[SU MO TU WE TH FR SA].freeze
28
+
25
29
  def self.parse(rrule, **options)
26
30
  Rule.new(rrule, **options)
27
31
  end
data/rrule.gemspec CHANGED
@@ -1,20 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'rrule/version'
6
+
1
7
  Gem::Specification.new do |s|
2
8
  s.name = 'rrule'
3
- s.version = '0.4.1'
4
- s.date = '2018-04-24'
9
+ s.version = RRule::VERSION
5
10
  s.summary = 'RRule expansion'
6
11
  s.description = 'A gem for expanding dates according to the RRule specification'
7
12
  s.authors = ['Ryan Mitchell']
8
13
  s.email = 'rmitchell@squareup.com'
9
- s.files = `git ls-files`.split($/)
10
- s.test_files = s.files.grep(%r{^(test|spec|features)/})
14
+ s.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
11
15
  s.require_paths = ['lib']
12
- s.homepage = 'http://rubygems.org/gems/rrule'
16
+ s.homepage = 'https://rubygems.org/gems/rrule'
17
+ s.metadata = {
18
+ 'homepage' => 'https://rubygems.org/gems/rrule',
19
+ 'source_code_uri' => 'https://github.com/square/ruby-rrule',
20
+ 'bug_tracker_uri' => 'https://github.com/square/ruby-rrule/issues',
21
+ 'changelog_uri' => 'https://github.com/square/ruby-rrule/blob/master/CHANGELOG.md'
22
+ }
13
23
 
14
- # Since Ruby 1.9.2, Time implementation uses a signed 63 bit integer, Bignum
15
- # or Rational. This enables Time to finally work with years after 2038 which
16
- # is critical for this library.
17
- s.required_ruby_version = '>= 1.9.2'
18
- s.add_runtime_dependency 'activesupport', '>= 4.1'
19
- s.add_development_dependency 'rspec', '~> 3.4'
24
+ s.required_ruby_version = '>= 2.6.0'
25
+ s.add_runtime_dependency 'activesupport', '>= 2.3'
26
+ s.add_development_dependency 'appraisal'
20
27
  end
data/scripts/benchmark.rb CHANGED
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '../lib/'))
2
4
  require 'rrule'
3
- include Benchmark
5
+ require 'benchmark'
4
6
 
5
7
  rules_to_benchmark = ['FREQ=WEEKLY', 'FREQ=WEEKLY;BYDAY=WE']
6
8
  rrule_version = '0.3.0'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rrule
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Mitchell
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-24 00:00:00.000000000 Z
11
+ date: 2022-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '4.1'
19
+ version: '2.3'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '4.1'
26
+ version: '2.3'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rspec
28
+ name: appraisal
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '3.4'
33
+ version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '3.4'
40
+ version: '0'
41
41
  description: A gem for expanding dates according to the RRule specification
42
42
  email: rmitchell@squareup.com
43
43
  executables: []
@@ -45,13 +45,21 @@ extensions: []
45
45
  extra_rdoc_files: []
46
46
  files:
47
47
  - ".gitignore"
48
+ - ".rubocop.yml"
48
49
  - ".travis.yml"
50
+ - Appraisals
49
51
  - CHANGELOG.md
50
52
  - CONTRIBUTING.md
51
53
  - Gemfile
52
54
  - LICENSE.txt
53
55
  - README.md
54
56
  - Rakefile
57
+ - gemfiles/activesupport_2.3_LTS.gemfile
58
+ - gemfiles/activesupport_3.gemfile
59
+ - gemfiles/activesupport_4.gemfile
60
+ - gemfiles/activesupport_5.gemfile
61
+ - gemfiles/activesupport_6.gemfile
62
+ - gemfiles/activesupport_7.gemfile
55
63
  - lib/rrule.rb
56
64
  - lib/rrule/context.rb
57
65
  - lib/rrule/filters/by_month.rb
@@ -69,31 +77,19 @@ files:
69
77
  - lib/rrule/generators/by_set_position.rb
70
78
  - lib/rrule/generators/generator.rb
71
79
  - lib/rrule/rule.rb
80
+ - lib/rrule/version.rb
72
81
  - lib/rrule/weekday.rb
73
82
  - rrule.gemspec
74
83
  - scripts/benchmark.rb
75
84
  - scripts/history.txt
76
- - spec/context_spec.rb
77
- - spec/filters/by_month_day_spec.rb
78
- - spec/filters/by_month_spec.rb
79
- - spec/filters/by_week_day_spec.rb
80
- - spec/filters/by_week_number_spec.rb
81
- - spec/filters/by_year_day_spec.rb
82
- - spec/frequencies/daily_spec.rb
83
- - spec/frequencies/monthly_spec.rb
84
- - spec/frequencies/simple_weekly_spec.rb
85
- - spec/frequencies/weekly_spec.rb
86
- - spec/frequencies/yearly_spec.rb
87
- - spec/generators/all_occurrences_spec.rb
88
- - spec/generators/by_set_position_spec.rb
89
- - spec/generators/generator_spec.rb
90
- - spec/rule_spec.rb
91
- - spec/spec_helper.rb
92
- - spec/weekday_spec.rb
93
- homepage: http://rubygems.org/gems/rrule
85
+ homepage: https://rubygems.org/gems/rrule
94
86
  licenses: []
95
- metadata: {}
96
- post_install_message:
87
+ metadata:
88
+ homepage: https://rubygems.org/gems/rrule
89
+ source_code_uri: https://github.com/square/ruby-rrule
90
+ bug_tracker_uri: https://github.com/square/ruby-rrule/issues
91
+ changelog_uri: https://github.com/square/ruby-rrule/blob/master/CHANGELOG.md
92
+ post_install_message:
97
93
  rdoc_options: []
98
94
  require_paths:
99
95
  - lib
@@ -101,33 +97,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
101
97
  requirements:
102
98
  - - ">="
103
99
  - !ruby/object:Gem::Version
104
- version: 1.9.2
100
+ version: 2.6.0
105
101
  required_rubygems_version: !ruby/object:Gem::Requirement
106
102
  requirements:
107
103
  - - ">="
108
104
  - !ruby/object:Gem::Version
109
105
  version: '0'
110
106
  requirements: []
111
- rubyforge_project:
112
- rubygems_version: 2.4.8
113
- signing_key:
107
+ rubygems_version: 3.1.6
108
+ signing_key:
114
109
  specification_version: 4
115
110
  summary: RRule expansion
116
- test_files:
117
- - spec/context_spec.rb
118
- - spec/filters/by_month_day_spec.rb
119
- - spec/filters/by_month_spec.rb
120
- - spec/filters/by_week_day_spec.rb
121
- - spec/filters/by_week_number_spec.rb
122
- - spec/filters/by_year_day_spec.rb
123
- - spec/frequencies/daily_spec.rb
124
- - spec/frequencies/monthly_spec.rb
125
- - spec/frequencies/simple_weekly_spec.rb
126
- - spec/frequencies/weekly_spec.rb
127
- - spec/frequencies/yearly_spec.rb
128
- - spec/generators/all_occurrences_spec.rb
129
- - spec/generators/by_set_position_spec.rb
130
- - spec/generators/generator_spec.rb
131
- - spec/rule_spec.rb
132
- - spec/spec_helper.rb
133
- - spec/weekday_spec.rb
111
+ test_files: []
data/spec/context_spec.rb DELETED
@@ -1,261 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe RRule::Context do
4
- let(:context) do
5
- RRule::Context.new(
6
- { freq: 'DAILY', count: 3 },
7
- Time.parse('Tue Sep 2 06:00:00 PDT 1997'),
8
- 'America/Los_Angeles'
9
- )
10
- end
11
-
12
- before(:each) { context.rebuild(1997, 1) }
13
-
14
- describe '#year_length_in_days' do
15
- subject { context.year_length_in_days }
16
-
17
- context 'in a non leap year' do
18
- before(:each) { context.rebuild(1997, 1) }
19
-
20
- it { is_expected.to eql 365 }
21
- end
22
-
23
- context 'in a leap year' do
24
- before(:each) { context.rebuild(2000, 1) }
25
-
26
- it { is_expected.to eql 366 }
27
- end
28
- end
29
-
30
- describe '#next_year_length_in_days' do
31
- subject { context.next_year_length_in_days }
32
-
33
- context 'in a year not prior to a leap year' do
34
- before(:each) { context.rebuild(1997, 1) }
35
-
36
- it { is_expected.to eql 365 }
37
- end
38
-
39
- context 'in a year prior to a leap year' do
40
- before(:each) { context.rebuild(1999, 1) }
41
-
42
- it { is_expected.to eql 366 }
43
- end
44
- end
45
-
46
- describe '#first_day_of_year' do
47
- subject { context.first_day_of_year }
48
-
49
- it { is_expected.to eq Date.new(1997, 1, 1) }
50
- end
51
-
52
- describe '#month_by_day_of_year' do
53
- subject(:month_by_day_of_year) { context.month_by_day_of_year }
54
-
55
- context 'in a leap year' do
56
- before(:each) { context.rebuild(2000, 1) }
57
-
58
- it 'maps the day of the year to the month number' do
59
- expect(month_by_day_of_year.length).to eql 366 + 7 # 7 padding days
60
- expect(month_by_day_of_year[0]).to eql 1
61
- expect(month_by_day_of_year[59]).to eql 2
62
- expect(month_by_day_of_year[365]).to eql 12
63
- end
64
- end
65
-
66
- context 'in a non leap year' do
67
- before(:each) { context.rebuild(1997, 1) }
68
-
69
- it 'maps the day of the year to the month number' do
70
- expect(month_by_day_of_year.length).to eql 365 + 7 # 7 padding days
71
- expect(month_by_day_of_year[0]).to eql 1
72
- expect(month_by_day_of_year[59]).to eql 3
73
- expect(month_by_day_of_year[364]).to eql 12
74
- end
75
- end
76
- end
77
-
78
- describe '#month_day_by_day_of_year' do
79
- subject(:month_day_by_day_of_year) { context.month_day_by_day_of_year }
80
-
81
- context 'in a leap year' do
82
- before(:each) { context.rebuild(2000, 1) }
83
-
84
- it 'maps the month day of the year to the month number' do
85
- expect(month_day_by_day_of_year.length).to eql 366 + 7 # 7 padding days
86
- expect(month_day_by_day_of_year[0]).to eql 1
87
- expect(month_day_by_day_of_year[1]).to eql 2
88
- expect(month_day_by_day_of_year[59]).to eql 29
89
- expect(month_day_by_day_of_year[365]).to eql 31
90
- end
91
- end
92
-
93
- context 'in a non leap year' do
94
- before(:each) { context.rebuild(1997, 1) }
95
-
96
- it 'maps the month day of the year to the month number' do
97
- expect(month_day_by_day_of_year.length).to eql 365 + 7 # 7 padding days
98
- expect(month_day_by_day_of_year[0]).to eql 1
99
- expect(month_day_by_day_of_year[1]).to eql 2
100
- expect(month_day_by_day_of_year[59]).to eql 1
101
- expect(month_day_by_day_of_year[364]).to eql 31
102
- end
103
- end
104
- end
105
-
106
- describe '#negative_month_day_by_day_of_year' do
107
- subject(:negative_month_day_by_day_of_year) { context.negative_month_day_by_day_of_year }
108
-
109
- context 'in a leap year' do
110
- before(:each) { context.rebuild(2000, 1) }
111
-
112
- it 'maps the month day of the year to the month number' do
113
- expect(negative_month_day_by_day_of_year.length).to eql 366 + 7 # 7 padding days
114
- expect(negative_month_day_by_day_of_year[0]).to eql -31
115
- expect(negative_month_day_by_day_of_year[1]).to eql -30
116
- expect(negative_month_day_by_day_of_year[59]).to eql -1
117
- expect(negative_month_day_by_day_of_year[365]).to eql -1
118
- end
119
- end
120
-
121
- context 'in a non leap year' do
122
- before(:each) { context.rebuild(1997, 1) }
123
-
124
- it 'maps the month day of the year to the month number' do
125
- expect(negative_month_day_by_day_of_year.length).to eql 365 + 7 # 7 padding days
126
- expect(negative_month_day_by_day_of_year[0]).to eql -31
127
- expect(negative_month_day_by_day_of_year[1]).to eql -30
128
- expect(negative_month_day_by_day_of_year[59]).to eql -31
129
- expect(negative_month_day_by_day_of_year[364]).to eql -1
130
- end
131
- end
132
- end
133
-
134
- describe '#week_number_by_day_of_year' do
135
- subject(:week_number_by_day_of_year) { context.week_number_by_day_of_year }
136
-
137
- context 'when the first day of the year is in the first week of that calendar-week-based year' do
138
- before(:each) { context.rebuild(1997, 1) }
139
-
140
- it 'is part of the current calendar-week-based year' do
141
- expect(week_number_by_day_of_year[0]).to eql 1
142
- end
143
- end
144
-
145
- context 'when the first day of the year is in the last week of the previous calendar-week-based year' do
146
- before(:each) { context.rebuild(1999, 1) }
147
-
148
- it 'is part of the previous calendar-week-based year' do
149
- expect(week_number_by_day_of_year[0]).to eql 53
150
- end
151
- end
152
-
153
- context 'when the last day of the year is in the last week of that calendar-week-based year' do
154
- before(:each) { context.rebuild(1999, 1) }
155
-
156
- it 'is part of the current calendar-week-based year' do
157
- expect(week_number_by_day_of_year[364]).to eql 52
158
- end
159
- end
160
-
161
- context 'when the last day of the year is in the first week of the next calendar-week-based year' do
162
- before(:each) { context.rebuild(1997, 1) }
163
-
164
- it 'is part of the next calendar-week-based year' do
165
- expect(week_number_by_day_of_year[364]).to eql 1
166
- end
167
- end
168
- end
169
-
170
- describe '#negative_week_number_by_day_of_year' do
171
- subject(:negative_week_number_by_day_of_year) { context.negative_week_number_by_day_of_year }
172
-
173
- context 'when the first day of the year is in the first week of that calendar-week-based year' do
174
- before(:each) { context.rebuild(1997, 1) }
175
-
176
- it 'is part of the current calendar-week-based year' do
177
- expect(negative_week_number_by_day_of_year[0]).to eql -52
178
- end
179
- end
180
-
181
- context 'when the first day of the year is in the last week of the previous calendar-week-based year' do
182
- before(:each) { context.rebuild(1999, 1) }
183
-
184
- it 'is part of the previous calendar-week-based year' do
185
- expect(negative_week_number_by_day_of_year[0]).to eql -1
186
- end
187
- end
188
-
189
- context 'when the last day of the year is in the last week of that calendar-week-based year' do
190
- before(:each) { context.rebuild(1999, 1) }
191
-
192
- it 'is part of the current calendar-week-based year' do
193
- expect(negative_week_number_by_day_of_year[364]).to eql -1
194
- end
195
- end
196
-
197
- context 'when the last day of the year is in the first week of the next calendar-week-based year' do
198
- before(:each) { context.rebuild(1997, 1) }
199
-
200
- it 'is part of the next calendar-week-based year' do
201
- expect(negative_week_number_by_day_of_year[364]).to eql -53
202
- end
203
- end
204
- end
205
-
206
- describe '#first_weekday_of_year' do
207
- subject { context.first_weekday_of_year }
208
-
209
- it { is_expected.to eq 3 }
210
- end
211
-
212
- describe '#weekday_by_day_of_year' do
213
- subject { context.weekday_by_day_of_year }
214
-
215
- it { is_expected.to start_with(3, 4, 5, 6, 0, 1, 2) }
216
- end
217
-
218
- describe '#elapsed_days_in_year_by_month' do
219
- subject { context.elapsed_days_in_year_by_month }
220
-
221
- context 'in a leap year' do
222
- before(:each) { context.rebuild(2000, 1) }
223
-
224
- it { is_expected.to start_with(0, 31, 60, 91) }
225
- end
226
-
227
- context 'in a non leap year' do
228
- before(:each) { context.rebuild(1997, 1) }
229
-
230
- it { is_expected.to start_with(0, 31, 59, 90) }
231
- end
232
- end
233
-
234
- describe '#day_of_year_mask' do
235
- let(:context) do
236
- RRule::Context.new(
237
- { freq: 'MONTHLY', count: 3, bynweekday: [RRule::Weekday.parse('3TU'), RRule::Weekday.parse('-2MO')] },
238
- Time.parse('Wed Jan 1 00:00:00 PST 1997'),
239
- 'America/Los_Angeles'
240
- )
241
- end
242
-
243
- subject(:day_of_year_mask) { context.day_of_year_mask }
244
-
245
- it 'correctly masks all days except the third Tuesday and the next-to-last Monday in January 1997' do
246
- day_of_year_mask.each_with_index do |available, day_of_year|
247
- expect(available).to be [19, 20].include?(day_of_year)
248
- end
249
- end
250
-
251
- context 'when the month is advanced' do
252
- before(:each) { context.rebuild(1997, 2) }
253
-
254
- it 'correctly masks all days except the third Tuesday and the next-to-last Monday in February 1997' do
255
- day_of_year_mask.each_with_index do |available, day_of_year|
256
- expect(available).to be [48, 47].include?(day_of_year)
257
- end
258
- end
259
- end
260
- end
261
- end
@@ -1,35 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe RRule::ByMonthDay do
4
- let(:context) do
5
- RRule::Context.new(
6
- { freq: 'MONTHLY', count: 4 },
7
- Time.parse('Wed Jan 1 00:00:00 PST 1997'),
8
- 'America/Los_Angeles'
9
- )
10
- end
11
-
12
- subject { described_class.new([3, -3], context).reject?(date.yday - 1) }
13
-
14
- before(:each) { context.rebuild(1997, 1) }
15
-
16
- describe '#reject?' do
17
- context 'for the third day of the month' do
18
- let(:date) { Date.new(1997, 1, 3) }
19
-
20
- it { is_expected.to be false }
21
- end
22
-
23
- context 'for the fourth day of the month' do
24
- let(:date) { Date.new(1997, 1, 4) }
25
-
26
- it { is_expected.to be true }
27
- end
28
-
29
- context 'for the third-to-last day of the month' do
30
- let(:date) { Date.new(1997, 1, 29) }
31
-
32
- it { is_expected.to be false }
33
- end
34
- end
35
- end
@@ -1,35 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe RRule::ByMonth do
4
- let(:context) do
5
- RRule::Context.new(
6
- { freq: 'MONTHLY', count: 4 },
7
- Time.parse('Wed Jan 1 00:00:00 PST 1997'),
8
- 'America/Los_Angeles'
9
- )
10
- end
11
-
12
- subject { described_class.new([1, 3], context).reject?(date.yday) }
13
-
14
- before(:each) { context.rebuild(1997, 1) }
15
-
16
- describe '#reject?' do
17
- context 'for a day in January' do
18
- let(:date) { Date.new(1997, 1, 15) }
19
-
20
- it { is_expected.to be false }
21
- end
22
-
23
- context 'for a day in February' do
24
- let(:date) { Date.new(1997, 2, 15) }
25
-
26
- it { is_expected.to be true }
27
- end
28
-
29
- context 'for a day in March' do
30
- let(:date) { Date.new(1997, 3, 15) }
31
-
32
- it { is_expected.to be false }
33
- end
34
- end
35
- end
@@ -1,35 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe RRule::ByWeekDay do
4
- let(:context) do
5
- RRule::Context.new(
6
- { freq: 'WEEKLY', count: 4 },
7
- Time.parse('Wed Jan 1 00:00:00 PST 1997'),
8
- 'America/Los_Angeles'
9
- )
10
- end
11
-
12
- subject { described_class.new([RRule::Weekday.parse('TU'), RRule::Weekday.parse('FR')], context).reject?(date.yday - 1) }
13
-
14
- before(:each) { context.rebuild(1997, 1) }
15
-
16
- describe '#reject?' do
17
- context 'for the Friday of the week' do
18
- let(:date) { Date.new(1997, 1, 3) }
19
-
20
- it { is_expected.to be false }
21
- end
22
-
23
- context 'for the Saturday of the week' do
24
- let(:date) { Date.new(1997, 1, 4) }
25
-
26
- it { is_expected.to be true }
27
- end
28
-
29
- context 'for the Tuesday of the next week' do
30
- let(:date) { Date.new(1997, 1, 7) }
31
-
32
- it { is_expected.to be false }
33
- end
34
- end
35
- end
@@ -1,41 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe RRule::ByWeekNumber do
4
- let(:context) do
5
- RRule::Context.new(
6
- { freq: 'YEARLY', wkst: 1 },
7
- Time.parse('Wed Jan 1 00:00:00 PST 1997'),
8
- 'America/Los_Angeles'
9
- )
10
- end
11
-
12
- subject { described_class.new([2, -3], context).reject?(date.yday - 1) }
13
-
14
- before(:each) { context.rebuild(1997, 1) }
15
-
16
- describe '#reject?' do
17
- context 'for the first week of the year' do
18
- let(:date) { Date.new(1997, 1, 2) }
19
-
20
- it { is_expected.to be true }
21
- end
22
-
23
- context 'for the second week of the year' do
24
- let(:date) { Date.new(1997, 1, 8) }
25
-
26
- it { is_expected.to be false }
27
- end
28
-
29
- context 'for the fourth week of the year' do
30
- let(:date) { Date.new(1997, 1, 22) }
31
-
32
- it { is_expected.to be true }
33
- end
34
-
35
- context 'for the third-to-last week of the year' do
36
- let(:date) { Date.new(1997, 12, 9) }
37
-
38
- it { is_expected.to be false }
39
- end
40
- end
41
- end
@@ -1,35 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe RRule::ByYearDay do
4
- let(:context) do
5
- RRule::Context.new(
6
- { freq: 'YEARLY', count: 4 },
7
- Time.parse('Wed Jan 1 00:00:00 PST 1997'),
8
- 'America/Los_Angeles'
9
- )
10
- end
11
-
12
- subject { described_class.new([45, -45], context).reject?(date.yday - 1) }
13
-
14
- before(:each) { context.rebuild(1997, 1) }
15
-
16
- describe '#reject?' do
17
- context 'for the 45th day of the year' do
18
- let(:date) { Date.new(1997, 2, 14) }
19
-
20
- it { is_expected.to be false }
21
- end
22
-
23
- context 'for the 60th day of the year' do
24
- let(:date) { Date.new(1997, 3, 1) }
25
-
26
- it { is_expected.to be true }
27
- end
28
-
29
- context 'for the 45th-from-last day of the month' do
30
- let(:date) { Date.new(1997, 11, 17) }
31
-
32
- it { is_expected.to be false }
33
- end
34
- end
35
- end