Commit e4998ac7fb74261067ac7d125fe09dc5891b616a

Authored by Heitor
Committed by Rafael Manzo
1 parent d2b39c78

Finished integration for Reading

app/models/reading.rb
1 1 class Reading < KalibroClient::Configurations::Reading
2   - include KalibroRecord
3   -
4   - attr_accessor :label, :grade, :color
5   -
6   - validates :label, presence: true, kalibro_uniqueness: true
7   - validates :grade, presence: true, numericality: true
8   - validates :color, presence: true
9 2 end
... ...
spec/models/reading_spec.rb
... ... @@ -1,31 +0,0 @@
1   -require 'rails_helper'
2   -
3   -describe Reading, :type => :model do
4   - pending 'waiting for kalibro configurations integration' do
5   - describe 'validations' do
6   - subject {FactoryGirl.build(:reading)}
7   -
8   - context 'active model validations' do
9   - before :each do
10   - Reading.expects(:all).at_least_once.returns([])
11   - end
12   -
13   - it { is_expected.to validate_presence_of(:label) }
14   - it { is_expected.to validate_presence_of(:color) }
15   - it { is_expected.to validate_presence_of(:grade) }
16   - it { is_expected.to validate_numericality_of(:grade) }
17   - end
18   -
19   - context 'kalibro validations' do
20   - before :each do
21   - Reading.expects(:request).returns(42)
22   - end
23   -
24   - it 'should validate uniqueness' do
25   - KalibroUniquenessValidator.any_instance.expects(:validate_each).with(subject, :label, subject.label)
26   - subject.save
27   - end
28   - end
29   - end
30   - end
31   -end