projects_controller_spec.rb
1.21 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
require 'spec_helper'
describe ProjectsController do
describe 'new' do
before :each do
get :new
end
it { should respond_with(:success) }
it { should render_template(:new) }
end
describe 'create' do
context 'with a valid fields' do
before :each do
@subject = FactoryGirl.build(:project)
Project.expects(:new).at_least_once.with(@subject.to_hash).returns(@subject)
Project.any_instance.expects(:save).returns(true)
post :create, :project => @subject.to_hash
end
it 'should redirect to the show view' do
pending("Probably incompatibility between Rails 4 and RSpec. It isn't expecting an slash at the end." ) do
response.should redirect_to project_path(@subject)
end
end
it { should respond_with(:redirect) }
end
context 'with an invalid field' do
before :each do
@subject = FactoryGirl.build(:project)
Project.expects(:new).at_least_once.with(@subject.to_hash).returns(@subject)
Project.any_instance.expects(:save).returns(false)
post :create, :project => @subject.to_hash
end
it { should render_template(:new) }
end
end
end