Skip to content

Instantly share code, notes, and snippets.

@jameswalton
Created June 10, 2012 19:13
Show Gist options
  • Select an option

  • Save jameswalton/2906986 to your computer and use it in GitHub Desktop.

Select an option

Save jameswalton/2906986 to your computer and use it in GitHub Desktop.
Check controller spec
require 'spec_helper'
describe ChecksController do
before :each do
@user = create(:user)
@task = create(:task, user: @user)
@check = build(:check, task_id: @task.id)
sign_in @user
end
context 'with valid attributes' do
it 'saves the new Check to the database' do
expect{
post :create, task_id: @task.id, check: attributes_for(:check, task_id: @task.id)
}.to change(Check, :count).by(1)
end
it 'redirects to the parent Task show page' do
task = create(:task)
post :create, task_id: @task.id, check: attributes_for(:check, task: task.id)
response.should redirect_to task_path(task)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment