Guest User

Untitled

a guest
Apr 8th, 2018
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. require File.join(File.dirname(__FILE__), "..", 'spec_helper.rb')
  2.  
  3. describe Contacts, "index action" do
  4. before(:each) do
  5. Contact.auto_migrate!
  6. end
  7.  
  8. it "should successfully create new contact" do
  9. user = mock(User, { :id => 1, :username => "flappy", :email => "flappy@email.com", :password => "665665", :password_confirmation => "665665" })
  10. dispatch_to(Contacts, :create, :name => "Mayor McCheese", :user_id => 1 ) { |controller| controller.stub!(:current_user).and_return(@user) }
  11.  
  12. lambda do
  13. c = create_contact
  14. c.should redirect
  15. end.should change(Contact, :count).by(1)
  16. end
  17.  
  18. private
  19. def create_contact(options = {})
  20. post "/contacts", :contact => { :name => "Sergey Vatilik", :user_id => 1 }.merge(options)
  21. end
  22. end
Add Comment
Please, Sign In to add comment