Created
November 30, 2008 16:35
-
-
Save Oshuma/30473 to your computer and use it in GitHub Desktop.
Merb spec helpers to test authenticated actions.
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
| def create_article(options = {}) | |
| create_and_authenticate_user | |
| Article.all.destroy! | |
| request(resource(:articles), :method => "POST", | |
| :params => { :article => { :id => nil, :title => 'Title', | |
| :content => 'Blog post.' }}) | |
| end | |
| def create_and_authenticate_user | |
| User.all.destroy! | |
| User.new(:login => 'luser', | |
| :password => 'secret', :password_confirmation => 'secret').save | |
| authenticate_user | |
| end | |
| def authenticate_user | |
| request(url(:perform_login), :method => "PUT", | |
| :params => {:login => 'luser', :password => 'secret'}) | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment