Created
October 25, 2012 13:23
-
-
Save cutalion/3952512 to your computer and use it in GitHub Desktop.
Similar controller specs
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
describe SomeController do | |
context "if user is not logged in" do | |
specify "GET 'show' should redirect to login page" do | |
get :show | |
response.should redirect_to login_path | |
end | |
specify "PUT 'update' should redirect to login page" do | |
put :update | |
response.should redirect_to login_path | |
end | |
# ... | |
end | |
end |
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
describe SomeController do | |
context "if user is not logged in" do | |
actions = [ | |
Proc.new { get :show }, | |
Proc.new { get :edit }, | |
Proc.new { put :update }, | |
# .... | |
] | |
actions.each do |action| | |
specify do | |
instance_eval &action | |
should redirect_to login_path | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment