Created
May 4, 2011 14:27
-
-
Save toamitkumar/955308 to your computer and use it in GitHub Desktop.
dynamic routes in unit tests
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
# Add a controller to test some functionality in controller rspec | |
class MyTestController < ApplicationController | |
def index | |
render :nothing => true | |
end | |
end | |
# add | |
before do | |
YourApplication::Application.routes.draw do | |
match "/my_routes", :to => "my_test#index" | |
# other routes in the app which your tests might need | |
# as they are gone after you opened the draw block :( | |
end | |
end | |
# reload the routes from routes.rb | |
after do | |
YourApplication::Application.reload_routes! | |
end | |
# your unit tests |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment