Commit ac95a8e8f2b10d0544c9c891da3623e9dece11ac

Authored by Heitor
Committed by Rafael Manzo
1 parent f22cae9c

Started the fixes for reading group tests

Showing 1 changed file with 28 additions and 29 deletions   Show diff stats
spec/models/reading_group_spec.rb
1 1 require 'rails_helper'
2 2  
3 3 describe ReadingGroup, :type => :model do
4   - pending 'waiting for kalibro configurations integration' do
5   - describe 'methods' do
6   - describe 'persisted?' do
7   - before :each do
8   - @subject = FactoryGirl.build(:reading_group)
9   - ReadingGroup.expects(:exists?).with(@subject.id).returns(false)
10   - end
  4 + describe 'methods' do
  5 + describe 'persisted?' do
  6 + before :each do
  7 + @subject = FactoryGirl.build(:reading_group)
  8 + end
11 9  
12   - it 'should return false' do
13   - expect(@subject.persisted?).to eq(false)
14   - end
  10 + it 'should return false' do
  11 + expect(@subject.persisted?).to eq(false)
  12 + end
  13 + end
  14 +
  15 + describe 'update' do
  16 + before :each do
  17 + @qt = FactoryGirl.build(:reading_group)
  18 + @qt_params = Hash[FactoryGirl.attributes_for(:reading_group).map { |k,v| [k.to_s, v.to_s] }] #FIXME: Mocha is creating the expectations with strings, but FactoryGirl returns everything with sybols and integers
15 19 end
16 20  
17   - describe 'update' do
  21 + context 'with valid attributes' do
18 22 before :each do
19   - @qt = FactoryGirl.build(:reading_group)
20   - @qt_params = Hash[FactoryGirl.attributes_for(:reading_group).map { |k,v| [k.to_s, v.to_s] }] #FIXME: Mocha is creating the expectations with strings, but FactoryGirl returns everything with sybols and integers
  23 + @qt.expects(:save).with(@qt_params).returns(true)
21 24 end
22 25  
23   - context 'with valid attributes' do
24   - before :each do
25   - @qt.expects(:save).returns(true)
26   - end
27   -
28   - it 'should return true' do
29   - expect(@qt.update(@qt_params)).to eq(true)
30   - end
  26 + it 'should return true' do
  27 + expect(@qt.save(@qt_params)).to eq(true)
31 28 end
  29 + end
32 30  
33   - context 'with invalid attributes' do
34   - before :each do
35   - @qt.expects(:save).returns(false)
36   - end
  31 + context 'with invalid attributes' do
  32 + before :each do
  33 + @qt.expects(:save).with(@qt_params).returns(false)
  34 + end
37 35  
38   - it 'should return false' do
39   - expect(@qt.update(@qt_params)).to eq(false)
40   - end
  36 + it 'should return false' do
  37 + expect(@qt.save(@qt_params)).to eq(false)
41 38 end
42 39 end
  40 + end
43 41  
44   - describe 'readings' do
  42 + describe 'readings' do
  43 + pending 'method readings_of' do
45 44 subject { FactoryGirl.build(:reading_group) }
46 45 let(:reading) { FactoryGirl.build(:reading) }
47 46  
... ...