Created
July 6, 2012 08:57
-
-
Save piotrze/3059044 to your computer and use it in GitHub Desktop.
ApplicationController mock tryout with rspec-mock
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#spec/support/prefork/request_helpers.rb | |
module RequestHelpers | |
def sign_in | |
controllers_to_mock.each do |controller| | |
controller.any_instance.stub(:current_user).and_return(user) | |
controller.any_instance.stub(:signed_in?).and_return(true) | |
end | |
ensure_signed_in | |
end | |
def sign_out | |
controllers_to_mock.each do |controller| | |
controller.any_instance.unstub(:current_user) | |
controller.any_instance.unstub(:signed_in?) | |
end | |
end | |
private | |
def controllers_to_mock | |
ApplicationController.subclasses[3..-1] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment