Skip to content

Instantly share code, notes, and snippets.

@raphaklaus
Created June 5, 2014 01:29
Show Gist options
  • Save raphaklaus/98c543a8ff0f5d7e21d8 to your computer and use it in GitHub Desktop.
Save raphaklaus/98c543a8ff0f5d7e21d8 to your computer and use it in GitHub Desktop.
require '../spec_helper'
describe ProjectsController, :type => :controller do
before(:all) do
@project = FactoryGirl.build(:project)
@project.save
end
after(:all) do
@project.delete
end
context "Test the orchestrating of the controller" do
it "Must redirect to index when created" do
post :create, project: @project.attributes
response.should redirect_to projects_path
end
it "+1 when created" do
expect {
post :create, project: @project.attributes
}.to change(Project, :count).by(1)
end
it "Can find the project id" do
get :show, id: @project
assigns(:project).should eq(@project)
end
it "Should destroy perfectly" do
expect {
delete :destroy, id: @project
}.to change(Project, :count).by(-1)
end
end
context "Validates the views" do
it "renders the new" do
get :new
response.should render_template :new
end
it "renders the index" do
get :index
response.should render_template :index
end
it "renders the edit" do
get :edit, id: @project
response.should render_template :edit
end
it "renders the show" do
get :show, id: @project
response.should render_template :show
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment