I'm trying to use Minitest for an existing Rails app (3.2), but not having any luck running routing tests. I've tried rspec syntax (should route_to) and TestUnit syntax (assert_routing) but no luck.
Any advice on getting this to work? Specific modules I need to include, etc?
thanks
If you are using minitest-rails you can create route tests by placing the following in test/routes/homepage_test.rb
:
require "minitest_helper"
class HomepageRouteTest < ActionDispatch::IntegrationTest
def test_homepage
assert_routing "/", :controller => "home", :action => "index"
end
end
Alternatively, you can use the Minitest Spec DSL:
require "minitest_helper"
describe "Homepage Route Acceptance Test" do
it "resolves the homepage" do
assert_routing "/", :controller => "home", :action => "index"
end
end
You can run these tests with the following rake task:
rake minitest:routes
@blowmage's answer helped me but it looks like the syntax has changed a bit.
With Rails 4:
require "test_helper"
class HomepageRouteTest < ActionDispatch::IntegrationTest
def test_messages
assert_generates '/messages', :controller => "messages", :action => "index"
end
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With