Guest User

Untitled

a guest
Oct 19th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. in my project, I have something like this:
  2.  
  3. 63 before do
  4. 64 user.projects << project
  5. 66 end
  6. 67
  7. 68 it 'can create new task using valid attributes (creating new task)' do
  8. 69 lambda do
  9. 70 post :create, :project_id => project,
  10. 71 :task => valid_attributes
  11. 72 end.should change(Task, :count).by(1)
  12. 73 end
  13.  
  14. so for your case I'd try something like:
  15.  
  16. let!(user) { FactoryGirl.create :user }
  17. let!(task) { FactoryGirl.create :task, :user => @user }
  18. let!(valid_attributes_for_check_for_task) { FactoryGirl.attributes_for :check, :task_id => @task }
  19.  
  20. before :each do
  21. sign_in(user)
  22. end
  23.  
  24. it 'saves the new Check to the database' do
  25. lambda do
  26. post :create, task_id => @task.id,
  27. check => valid_attributes_for_check_for_task
  28. end.should change(Check, :count).by(1)
  29. end
Add Comment
Please, Sign In to add comment