metric_configuration_spec.rb
1.13 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
require 'spec_helper'
describe MetricConfiguration do
subject {FactoryGirl.build(:metric_configuration)}
describe 'methods' do
describe 'mezuro_ranges' do
let(:mezuro_range) { FactoryGirl.build(:mezuro_range) }
before :each do
MezuroRange.expects(:ranges_of).with(subject.id).returns([mezuro_range])
end
it 'should returns a list with its ranges' do
subject.mezuro_ranges.should eq([mezuro_range])
end
end
end
describe 'validations' do
context 'active model validations' do
before :each do
MetricConfiguration.expects(:metric_configurations_of).at_least_once.returns([])
end
it { should validate_presence_of(:code) }
it { should validate_presence_of(:weight) }
it { should validate_presence_of(:aggregation_form) }
end
context 'code validations' do
before :each do
MetricConfiguration.expects(:request).returns(42)
end
it 'should validate uniqueness' do
CodeUniquenessValidator.any_instance.expects(:validate_each).with(subject, :code, subject.code)
subject.save
end
end
end
end