variation 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/variation/change.rb +6 -0
- data/lib/variation/profile.rb +5 -0
- data/lib/variation/version.rb +1 -1
- data/spec/change_spec.rb +41 -0
- data/spec/errors_spec.rb +3 -0
- data/spec/profile_spec.rb +54 -0
- metadata +3 -1
data/lib/variation/change.rb
CHANGED
data/lib/variation/profile.rb
CHANGED
data/lib/variation/version.rb
CHANGED
data/spec/change_spec.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Change do
|
4
|
+
describe '#==' do
|
5
|
+
context 'same change class' do
|
6
|
+
context 'same length and end value' do
|
7
|
+
it 'should return true' do
|
8
|
+
c1 = LinearChange.new(:end_value => 2, :length => 1)
|
9
|
+
c2 = LinearChange.new(:end_value => 2, :length => 1)
|
10
|
+
(c1 == c2).should be_true
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'different length and/or end value' do
|
15
|
+
it 'should return false' do
|
16
|
+
c1 = LinearChange.new(:end_value => 3, :length => 1)
|
17
|
+
c2 = LinearChange.new(:end_value => 2, :length => 1)
|
18
|
+
(c1 == c2).should be_false
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'different change class' do
|
24
|
+
context 'same length and end value' do
|
25
|
+
it 'should return false' do
|
26
|
+
c1 = LinearChange.new(:end_value => 2, :length => 1)
|
27
|
+
c2 = SigmoidChange.new(:end_value => 2, :length => 1)
|
28
|
+
(c1 == c2).should be_false
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'different length and/or end value' do
|
33
|
+
it 'should return false' do
|
34
|
+
c1 = LinearChange.new(:end_value => 2, :length => 3)
|
35
|
+
c2 = LinearChange.new(:end_value => 2, :length => 1)
|
36
|
+
(c1 == c2).should be_false
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/spec/errors_spec.rb
CHANGED
data/spec/profile_spec.rb
CHANGED
@@ -32,6 +32,60 @@ describe Profile do
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
+
describe '#==' do
|
36
|
+
context 'start values are equal' do
|
37
|
+
context 'changes are not all equal' do
|
38
|
+
it 'should return false' do
|
39
|
+
p1 = Profile.new(:start_value => 2, :changes => {
|
40
|
+
1 => LinearChange.new(:end_value => 4, :length => 2)
|
41
|
+
})
|
42
|
+
p2 = Profile.new(:start_value => 2, :changes => {
|
43
|
+
1 => LinearChange.new(:end_value => 5, :length => 2)
|
44
|
+
})
|
45
|
+
(p1 == p2).should be_false
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'changes are all equal' do
|
50
|
+
it 'should return true' do
|
51
|
+
p1 = Profile.new(:start_value => 2, :changes => {
|
52
|
+
1 => LinearChange.new(:end_value => 5, :length => 2)
|
53
|
+
})
|
54
|
+
p2 = Profile.new(:start_value => 2, :changes => {
|
55
|
+
1 => LinearChange.new(:end_value => 5, :length => 2)
|
56
|
+
})
|
57
|
+
(p1 == p2).should be_true
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
context 'start values are not equal' do
|
63
|
+
context 'changes are not all equal' do
|
64
|
+
it 'should return false' do
|
65
|
+
p1 = Profile.new(:start_value => 1, :changes => {
|
66
|
+
1 => LinearChange.new(:end_value => 4, :length => 2)
|
67
|
+
})
|
68
|
+
p2 = Profile.new(:start_value => 2, :changes => {
|
69
|
+
1 => LinearChange.new(:end_value => 5, :length => 2)
|
70
|
+
})
|
71
|
+
(p1 == p2).should be_false
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
context 'changes are all equal' do
|
76
|
+
it 'should return false' do
|
77
|
+
p1 = Profile.new(:start_value => 1, :changes => {
|
78
|
+
1 => LinearChange.new(:end_value => 5, :length => 2)
|
79
|
+
})
|
80
|
+
p2 = Profile.new(:start_value => 2, :changes => {
|
81
|
+
1 => LinearChange.new(:end_value => 5, :length => 2)
|
82
|
+
})
|
83
|
+
(p1 == p2).should be_false
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
35
89
|
describe '#function' do
|
36
90
|
before :all do
|
37
91
|
@profiles = [
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: variation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -103,6 +103,7 @@ files:
|
|
103
103
|
- lib/variation/profile.rb
|
104
104
|
- lib/variation/range.rb
|
105
105
|
- lib/variation/version.rb
|
106
|
+
- spec/change_spec.rb
|
106
107
|
- spec/changes/immediate_change_spec.rb
|
107
108
|
- spec/changes/linear_change_spec.rb
|
108
109
|
- spec/changes/sigmoid_change_spec.rb
|
@@ -142,6 +143,7 @@ specification_version: 3
|
|
142
143
|
summary: Compute values that change with time, with various transitions (immediate,
|
143
144
|
linear, sigmoid)
|
144
145
|
test_files:
|
146
|
+
- spec/change_spec.rb
|
145
147
|
- spec/changes/immediate_change_spec.rb
|
146
148
|
- spec/changes/linear_change_spec.rb
|
147
149
|
- spec/changes/sigmoid_change_spec.rb
|