-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored Tests to use let() method, and use right relations in orde…
…r to simulate required app conditions to test the controllers and models.
- Loading branch information
Gerson Scanapieco
committed
Oct 12, 2013
1 parent
e122b03
commit 3287cd7
Showing
11 changed files
with
228 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
require 'spec_helper' | ||
|
||
describe "FeedbacksController" do | ||
|
||
describe "GET #new" do | ||
it "assigns a new feedback object" do | ||
get :new | ||
feedback = assigns[:feedback] | ||
|
||
expect(feedback).not_to be_nil | ||
end | ||
|
||
it "renders the :new view" do | ||
get :new | ||
|
||
expect(response).to render_template :new | ||
end | ||
end | ||
|
||
describe "POST #create" do | ||
before do | ||
let(:attrs) { FactoryGirl.attributes_for(:feedback) } | ||
end | ||
|
||
it "creates a new database record" do | ||
expect{ put :create, feedback: attrs}.to change(Feedback,:count).by(1) | ||
end | ||
|
||
it "redirects to :show view" do | ||
put :create, feedback: attrs | ||
|
||
expect(response).to redirect_to :show | ||
end | ||
|
||
it "shows a success message" do | ||
put :create, feedback: attrs | ||
|
||
expect(flash[:notice]).to eql "Feedback successfully created" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
require 'spec_helper' | ||
|
||
describe "FeedbacksController" do | ||
|
||
describe "GET #new" do | ||
it "assigns a new feedback object" do | ||
get :new | ||
invitation = assigns[:invitation] | ||
|
||
expect(invitation).not_to be_nil | ||
end | ||
|
||
it "renders the :new view" do | ||
get :new | ||
|
||
expect(response).to render_template :new | ||
end | ||
end | ||
|
||
describe "POST #create" do | ||
before do | ||
let(:attrs) {FactoryGirl.attributes_for(:invitation)} | ||
end | ||
|
||
it "creates a new database record" do | ||
expect{ put :create, invitation: attrs}.to change(Invitation,:count).by(1) | ||
end | ||
|
||
it "redirects to :show view" do | ||
put :create, invitation: attrs | ||
|
||
expect(response).to redirect_to :show | ||
end | ||
|
||
it "shows a success message" do | ||
put :create, invitation: attrs | ||
|
||
expect(flash[:notice]).to eql "Invitation successfully created" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.