Created
October 4, 2011 15:45
-
-
Save colindean/1261980 to your computer and use it in GitHub Desktop.
test generator failing
This file contains 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
# this is failing to work as I thought because #test() is creating a function on the fly. | |
# is there a way to do this? | |
[:index, :new].each do |method| | |
test "should redirect when not logged in (#{method})" do | |
get method | |
assert_redirect_to login_url | |
end | |
end | |
# I expect it to generate this and execute it: | |
test "should redirect when not logged in (index)" do | |
get :index | |
assert_redirect_to login_url | |
end | |
test "should redirect when not logged in (new)" do | |
get :new | |
assert_redirect_to login_url | |
end | |
# I get this error: | |
#ERROR should redirect when not logged in (destroy) (0.01s) | |
# ActionController::RoutingError: No route matches {:id=>"980190962", :controller=>"groups", :action=>"method"} | |
# /Users/cdean/.rvm/gems/jruby-1.6.4@velodash/gems/actionpack-3.1.1.rc1/lib/action_dispatch/routing/route_set.rb:464:in `raise_routing_error' | |
# I can tell from the error that this is what's getting generated: | |
test "should redirect when not logged in (new)" do | |
get method | |
assert_redirect_to login_url | |
end | |
#the generated method is literally looking in this scope for the method variable, not the scope of the each. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment