Guest User

Untitled

a guest
Apr 20th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. ## RSpec Stacktrace
  2. 1)
  3. 'Contacts#index should find all contacts and place them in @contacts' FAILED
  4. expected: [],
  5. got: nil (using ==)
  6. ./spec/controllers/contacts_spec.rb:15:
  7.  
  8. ## Spec
  9. describe "#show" do
  10. before(:each) do
  11. @contact = mock(Contact, {})
  12. end
  13.  
  14. it "should raise a NotFound error if can't find a contact by id" do
  15. Contact.should_receive(:find_by_id).with(1).and_return(nil)
  16. lambda do
  17. dispatch_to(Contacts, :show, :id => @contact.id)
  18. end.should raise_error(Merb::ControllerExceptions::NotFound)
  19. end
  20. end
  21.  
  22. ## Controller
  23. def show
  24. @contact = current_user.contacts.find_by_id(params[:id])
  25. raise NotFound unless @contact
  26. display @contact
  27. end
Add Comment
Please, Sign In to add comment