Skip to content

Functional tests cannot add a route #747

@lighthouse-import

Description

@lighthouse-import

Imported from Lighthouse. Original ticket at: http://rails.lighthouseapp.com/projects/8994/tickets/5922
Created by Andrea Campi - 2011-04-09 22:41:49 UTC

I may be overlooking something, but:

I have a functional test that uses its own mock controller, which prepares some data and ends up calling a helper.
Among other things, I want to test that this helper generates the correct URLs, so I need my routes from config/routes.rb.
To be able to invoke actions on my mock controller, I have:

  setup do
    Rails.application.routes.draw do
      match '/foo' => "tags_tree_test/tags_tree_test#index"
    end
  end

  teardown do
    Rails.application.reload_routes!
  end

The problem is that #draw first clears existing routes.
Of course this would just work if I used an existing controller for which I already have a route in config/routes.rb--but I want to run this test in a clean environment.

Am I correct that there's no way to do this?
Do we want to support this use case?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions