Created
June 10, 2012 19:13
-
-
Save jameswalton/2906986 to your computer and use it in GitHub Desktop.
Check controller spec
This file contains hidden or 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
| 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