Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require File.join(File.dirname(__FILE__), "..", 'spec_helper.rb')
- describe Contacts, "index action" do
- before(:each) do
- Contact.auto_migrate!
- end
- it "should successfully create new contact" do
- user = mock(User, { :id => 1, :username => "flappy", :email => "flappy@email.com", :password => "665665", :password_confirmation => "665665" })
- dispatch_to(Contacts, :create, :name => "Mayor McCheese", :user_id => 1 ) { |controller| controller.stub!(:current_user).and_return(@user) }
- lambda do
- c = create_contact
- c.should redirect
- end.should change(Contact, :count).by(1)
- end
- private
- def create_contact(options = {})
- post "/contacts", :contact => { :name => "Sergey Vatilik", :user_id => 1 }.merge(options)
- end
- end
Add Comment
Please, Sign In to add comment