Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wrote some basic controller tests for the donors controller. Tested t…
…he index and new pages, as well as the happy and unhappy paths for the create page
- Loading branch information
Erin Joan Snyder
authored and
Erin Joan Snyder
committed
Jul 12, 2014
1 parent
5a95cf5
commit 5564644
Showing
18 changed files
with
50 additions
and
1,266 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
require 'spec_helper' | ||
|
||
describe DonorsController do | ||
context "#index" do | ||
it "should get a 200 response" do | ||
get :index | ||
expect(response.status).to eq 200 | ||
end | ||
end | ||
|
||
context "#new" do | ||
it "should get a 200 response" do | ||
get :new | ||
expect(response.status).to eq 200 | ||
end | ||
end | ||
|
||
context "#create" do | ||
it "creates a donor with valid params" do | ||
expect{ | ||
Donor.create(name: "Erin", city: "San Francisco", phone_number: "555-555-5555", email: "erin@erin.com", username: "ErinJoan", password: "erinisgreat") | ||
}.to change { Donor.count }.by(1) | ||
end | ||
|
||
it "doesn't create a donor when params are left blank" do | ||
expect{ | ||
Donor.create(name: "", city: "", phone_number: "", email: "", username: "", password: "") | ||
}.to_not change{ Donor.count } | ||
end | ||
|
||
it "doesn't create a second donor when params are not unique" do | ||
expect{ | ||
2.times do | ||
Donor.create(name: "Erin", city: "San Francisco", phone_number: "555-555-5555", email: "erin@erin.com", username: "ErinJoan", password: "erinisgreat") | ||
end | ||
}.to change { Donor.count }.by(1) | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.