Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## RSpec Stacktrace
- 1)
- 'Contacts#index should find all contacts and place them in @contacts' FAILED
- expected: [],
- got: nil (using ==)
- ./spec/controllers/contacts_spec.rb:15:
- ## Spec
- describe "#show" do
- before(:each) do
- @contact = mock(Contact, {})
- end
- it "should raise a NotFound error if can't find a contact by id" do
- Contact.should_receive(:find_by_id).with(1).and_return(nil)
- lambda do
- dispatch_to(Contacts, :show, :id => @contact.id)
- end.should raise_error(Merb::ControllerExceptions::NotFound)
- end
- end
- ## Controller
- def show
- @contact = current_user.contacts.find_by_id(params[:id])
- raise NotFound unless @contact
- display @contact
- end
Add Comment
Please, Sign In to add comment