Skip to content

Instantly share code, notes, and snippets.

@cutalion
Created October 25, 2012 13:23
Show Gist options
  • Save cutalion/3952512 to your computer and use it in GitHub Desktop.
Save cutalion/3952512 to your computer and use it in GitHub Desktop.
Similar controller specs
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
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