Commit 1b8c70cacc582afc0d0e1412d9bde76db001ce71
Committed by
Rafael Manzo
1 parent
e4427df7
Exists in
colab
and in
4 other branches
Fixing projects_controller_spec.rb
Signed-off-by: Diego Araújo <diegoamc90@gmail.com>
Showing
2 changed files
with
19 additions
and
14 deletions
Show diff stats
db/schema.rb
... | ... | @@ -11,7 +11,7 @@ |
11 | 11 | # |
12 | 12 | # It's strongly recommended that you check this file into your version control system. |
13 | 13 | |
14 | -ActiveRecord::Schema.define(version: 20130826211404) do | |
14 | +ActiveRecord::Schema.define(version: 20130903180641) do | |
15 | 15 | |
16 | 16 | create_table "project_ownerships", force: true do |t| |
17 | 17 | t.integer "user_id" |
... | ... | @@ -20,6 +20,12 @@ ActiveRecord::Schema.define(version: 20130826211404) do |
20 | 20 | t.datetime "updated_at" |
21 | 21 | end |
22 | 22 | |
23 | + create_table "repositories", force: true do |t| | |
24 | + t.string "name" | |
25 | + t.datetime "created_at" | |
26 | + t.datetime "updated_at" | |
27 | + end | |
28 | + | |
23 | 29 | create_table "users", force: true do |t| |
24 | 30 | t.string "name", default: "", null: false |
25 | 31 | t.string "email", default: "", null: false | ... | ... |
spec/controllers/projects_controller_spec.rb
... | ... | @@ -18,11 +18,10 @@ describe ProjectsController do |
18 | 18 | end |
19 | 19 | |
20 | 20 | context 'with valid fields' do |
21 | - before :each do | |
22 | - @subject = FactoryGirl.build(:project) | |
23 | - @subject_params = Hash[FactoryGirl.attributes_for(:project).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 | |
24 | - | |
25 | - Project.expects(:new).at_least_once.with(@subject_params).returns(@subject) | |
21 | + let(:project) { FactoryGirl.build(:project) } | |
22 | + let(:subject_params) { Hash[FactoryGirl.attributes_for(:project).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 | + | |
24 | + before :each do | |
26 | 25 | Project.any_instance.expects(:save).returns(true) |
27 | 26 | end |
28 | 27 | |
... | ... | @@ -30,17 +29,17 @@ describe ProjectsController do |
30 | 29 | before :each do |
31 | 30 | Project.expects(:exists?).returns(true) |
32 | 31 | |
33 | - post :create, :project => @subject_params | |
32 | + post :create, :project => subject_params | |
34 | 33 | end |
35 | 34 | |
36 | 35 | it 'should redirect to the show view' do |
37 | - response.should redirect_to project_path(@subject) | |
36 | + response.should redirect_to project_path(project) | |
38 | 37 | end |
39 | 38 | end |
40 | 39 | |
41 | 40 | context 'without rendering the show view' do |
42 | 41 | before :each do |
43 | - post :create, :project => @subject_params | |
42 | + post :create, :project => subject_params | |
44 | 43 | end |
45 | 44 | |
46 | 45 | it { should respond_with(:redirect) } |
... | ... | @@ -62,17 +61,17 @@ describe ProjectsController do |
62 | 61 | end |
63 | 62 | end |
64 | 63 | |
65 | - pending 'It is not correctly mocked and still calls Kalibro' do | |
66 | 64 | describe 'show' do |
65 | + subject { FactoryGirl.build(:project) } | |
66 | + let(:repository) { FactoryGirl.build(:repository) } | |
67 | 67 | before :each do |
68 | - @subject = FactoryGirl.build(:project) | |
69 | - Project.expects(:find).with(@subject.id.to_s).returns(@subject) | |
70 | - get :show, :id => @subject.id | |
68 | + Project.expects(:find).with(subject.id.to_s).returns(subject) | |
69 | + subject.expects(:repositories).returns(repository) | |
70 | + get :show, :id => subject.id | |
71 | 71 | end |
72 | 72 | |
73 | 73 | it { should render_template(:show) } |
74 | 74 | end |
75 | - end | |
76 | 75 | |
77 | 76 | describe 'destroy' do |
78 | 77 | before do | ... | ... |