Commit 00991f2a2114901e080e05902b5f6098a9238a5e

Authored by Rafael Manzo
Committed by Rafael Manzo
1 parent d40d0704

Fixed unit tests

spec/controllers/projects_controller_spec.rb
... ... @@ -10,7 +10,7 @@ describe ProjectsController do
10 10 it { should respond_with(:success) }
11 11 it { should render_template(:new) }
12 12 end
13   -
  13 +
14 14 describe 'create' do
15 15  
16 16 context 'with a valid fields' do
... ... @@ -20,17 +20,27 @@ describe ProjectsController do
20 20  
21 21 Project.expects(:new).at_least_once.with(@subject_params).returns(@subject)
22 22 Project.any_instance.expects(:save).returns(true)
23   -
24   - post :create, :project => @subject_params
25 23 end
26   -
27   - it 'should redirect to the show view' do
28   - pending("Probably incompatibility between Rails 4 and RSpec. It isn't expecting an slash at the end." ) do
  24 +
  25 + context 'rendering the show' do
  26 + before :each do
  27 + Project.expects(:exists?).returns(true)
  28 +
  29 + post :create, :project => @subject_params
  30 + end
  31 +
  32 + it 'should redirect to the show view' do
29 33 response.should redirect_to project_path(@subject)
30 34 end
31 35 end
32 36  
33   - it { should respond_with(:redirect) }
  37 + context 'without rendering the show view' do
  38 + before :each do
  39 + post :create, :project => @subject_params
  40 + end
  41 +
  42 + it { should respond_with(:redirect) }
  43 + end
34 44 end
35 45  
36 46 context 'with an invalid field' do
... ...
spec/models/project_spec.rb
... ... @@ -3,8 +3,13 @@ require 'spec_helper'
3 3 describe Project do
4 4 describe 'methods' do
5 5 describe 'persisted?' do
  6 + before :each do
  7 + @subject = FactoryGirl.build(:project)
  8 + Project.expects(:exists?).with(@subject.id).returns(false)
  9 + end
  10 +
6 11 it 'should return false' do
7   - subject.persisted?.should eq(false)
  12 + @subject.persisted?.should eq(false)
8 13 end
9 14 end
10 15  
... ...