reading_group_spec.rb
1.19 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 'rails_helper'
describe ReadingGroup, :type => :model do
describe 'methods' do
describe 'persisted?' do
before :each do
@subject = FactoryGirl.build(:reading_group_with_id)
end
end
describe 'update' do
before :each do
@qt = FactoryGirl.build(:reading_group_with_id)
@qt_params = @qt.to_hash
end
context 'with valid attributes' do
before :each do
@qt.expects(:save).with(@qt_params).returns(true)
end
it 'should return true' do
expect(@qt.save(@qt_params)).to eq(true)
end
end
context 'with invalid attributes' do
before :each do
@qt.expects(:save).with(@qt_params).returns(false)
end
it 'should return false' do
expect(@qt.save(@qt_params)).to eq(false)
end
end
end
describe 'readings' do
subject { FactoryGirl.build(:reading_group_with_id) }
let(:reading) { FactoryGirl.build(:reading_with_id) }
it 'should call readings_of on the Reading model' do
subject.expects(:readings).returns([reading])
expect(subject.readings).to include(reading)
end
end
end
end