range_test.rb
1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
require "test_helper"
class RangeTest < ActiveSupport::TestCase
Infinity = 1.0/0.0
def self.amloc_excellent
range = Kalibro::Entities::Range.new
range.beginning = 0.0
range.end = 7.0
range.label = 'Excellent'
range.grade = 10.0
range.color = 'ff00ff00'
range
end
def self.amloc_bad
range = Kalibro::Entities::Range.new
range.beginning = 19.5
range.end = Infinity
range.label = 'Bad'
range.grade = 0.0
range.color = 'ffff0000'
range
end
def self.amloc_excellent_hash
{:beginning => 0.0, :end => 7.0, :label => 'Excellent',
:grade => 10.0, :color => 'ff00ff00'}
end
def self.amloc_bad_hash
{:beginning => 19.5, :end => Infinity, :label => 'Bad',
:grade => 0.0, :color => 'ffff0000'}
end
def setup
@hash = self.class.amloc_bad_hash
@range = self.class.amloc_bad
end
should 'create range from hash' do
assert_equal @range, Kalibro::Entities::Range.from_hash(@hash)
end
should 'convert range to hash' do
assert_equal @hash, @range.to_hash
end
end