Chris Spears Dev

Blog about programming and computer graphics!

Thursday, December 5, 2013

Stubbing Out A User For Your Rspec Test

How to stub out a user when testing a controller with rspec:

# for controllers
user = User.create(:name => 'user@example.com', :password => 'caplin')
ApplicationController.stub(:current_user).and_return(user)
Posted by Unknown at 3:03 PM
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest

No comments:

Post a Comment

Newer Post Older Post Home
Subscribe to: Post Comments (Atom)

Blog Archive

  • ►  2018 (1)
    • ►  July (1)
  • ►  2017 (1)
    • ►  July (1)
  • ►  2016 (5)
    • ►  July (1)
    • ►  June (1)
    • ►  April (2)
    • ►  January (1)
  • ►  2015 (10)
    • ►  August (1)
    • ►  June (1)
    • ►  May (1)
    • ►  April (1)
    • ►  March (4)
    • ►  January (2)
  • ►  2014 (39)
    • ►  November (1)
    • ►  September (2)
    • ►  August (2)
    • ►  July (1)
    • ►  June (2)
    • ►  April (3)
    • ►  March (9)
    • ►  February (8)
    • ►  January (11)
  • ▼  2013 (57)
    • ▼  December (6)
      • Using virtualenvwrapper
      • Updating Python On Mac OS X
      • DataSquid Screen Grabs
      • Used JSFiddle For The First Time!
      • Stubbing Out A User For Your Rspec Test
      • Refactoring Rspec/Capybara tests (with a little he...
    • ►  November (2)
    • ►  October (15)
    • ►  September (6)
    • ►  August (2)
    • ►  July (5)
    • ►  June (21)

About Me

Unknown
View my complete profile
Simple theme. Powered by Blogger.