Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- in my project, I have something like this:
- 63 before do
- 64 user.projects << project
- 66 end
- 67
- 68 it 'can create new task using valid attributes (creating new task)' do
- 69 lambda do
- 70 post :create, :project_id => project,
- 71 :task => valid_attributes
- 72 end.should change(Task, :count).by(1)
- 73 end
- so for your case I'd try something like:
- let!(user) { FactoryGirl.create :user }
- let!(task) { FactoryGirl.create :task, :user => @user }
- let!(valid_attributes_for_check_for_task) { FactoryGirl.attributes_for :check, :task_id => @task }
- before :each do
- sign_in(user)
- end
- it 'saves the new Check to the database' do
- lambda do
- post :create, task_id => @task.id,
- check => valid_attributes_for_check_for_task
- end.should change(Check, :count).by(1)
- end
Add Comment
Please, Sign In to add comment