ice_t 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ice_t/rule/base.rb +1 -1
- data/lib/ice_t/version.rb +1 -1
- data/spec/rules/monthly_rule_spec.rb +1 -28
- data/spec/support/shared_examples/rule_example.rb +13 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb428538b8a07c2a90ccbdbf9278611e26b8c3e7
|
4
|
+
data.tar.gz: 4d480848e28958d21f470ca58fb8555e7bbf09b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54c69688a04d0f7e15c7c16dbb50157458389582f04f6e3a8c7d410b415bb8f759c0070b97e3379203d172d89f1f231bff493451099b58bd836017561939d11a
|
7
|
+
data.tar.gz: dc5d8e56b1125384aa1bf6aedf72ecb4e826e508fe9e48a55a2cef7172a7c3def870752c0c512a74bf74a3def081b9289d25954fc2d6d61892b60ef7aa0e7df2
|
data/lib/ice_t/rule/base.rb
CHANGED
@@ -53,7 +53,7 @@ module IceT
|
|
53
53
|
|
54
54
|
def occurrences(start_time, end_time)
|
55
55
|
diff = IceT::TimeHelper.diff_by_unit(start_time, end_time, self.class.unit)
|
56
|
-
(
|
56
|
+
(0..diff).step(self.interval).map { |i|
|
57
57
|
start_time.advance(self.class.unit => i)
|
58
58
|
}
|
59
59
|
end
|
data/lib/ice_t/version.rb
CHANGED
@@ -1,33 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe IceT::Rule::Monthly do
|
4
|
-
|
5
4
|
let(:klass) { IceT::Rule::Monthly }
|
6
|
-
it_behaves_like "a rule"
|
7
|
-
|
8
|
-
let!(:interval) { 1 }
|
9
|
-
let!(:start_time) { 1.year.ago }
|
10
|
-
let!(:end_time) { Time.now }
|
11
|
-
let(:rule) { IceT::Rule::Monthly.new(interval) }
|
12
|
-
|
13
|
-
|
14
|
-
describe "#occurrences" do
|
15
|
-
|
16
|
-
subject { rule.occurrences(start_time, end_time) }
|
17
|
-
|
18
|
-
it "returns an array" do
|
19
|
-
expect(subject).to be_an(Array)
|
20
|
-
end
|
21
|
-
|
22
|
-
context "one year ago until now" do
|
23
|
-
it "returns an array with 12 elements" do
|
24
|
-
expect(subject.size).to eql(12)
|
25
|
-
end
|
26
|
-
it "contains end_time as last element" do
|
27
|
-
expect(subject.last.to_date).to eql(end_time.to_date)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
32
|
-
|
5
|
+
it_behaves_like "a rule"
|
33
6
|
end
|
@@ -9,6 +9,19 @@ shared_examples 'a rule' do
|
|
9
9
|
|
10
10
|
describe '#occurrences' do
|
11
11
|
it { expect(klass.new).to respond_to(:occurrences) }
|
12
|
+
|
13
|
+
let(:rule){ klass.new(1) }
|
14
|
+
let(:start_time){ Time.now }
|
15
|
+
let(:duration){ eval("2.#{klass.unit}") }
|
16
|
+
let(:end_time){ start_time + duration }
|
17
|
+
subject { rule.occurrences(start_time, start_time + duration) }
|
18
|
+
|
19
|
+
it 'does contain the start_time' do
|
20
|
+
expect(subject.first).to eql(start_time)
|
21
|
+
end
|
22
|
+
it 'does contain the end_time' do
|
23
|
+
expect(subject.last).to eql(end_time)
|
24
|
+
end
|
12
25
|
end
|
13
26
|
|
14
27
|
describe '::from_json' do
|