rspec-rails: random numbers of random test fail with ActionController::UrlGenerationError: No route matches

as title, run all test, 10+ or 100+ test fail, run them individually, they will pass, also if run a sub directory like spec/controllers/api or spec/controllers/admin all test within will pass. the error is all similar:

204) Admin::CourseProvidersController delete destroy
     Failure/Error: delete :destroy, { id: @course_provider.id }
     ActionController::UrlGenerationError:
       No route matches {:action=>"destroy", :controller=>"admin/course_providers", :id=>"16"}
     # ./spec/controllers/admin/course_providers_controller_spec.rb:54:in `block (2 levels) in <top (required)>'
     # ./spec/spec_helper.rb:70:in `block (2 levels) in <top (required)>'

we recently upgrade rspec and this occur, follow is the version

    rspec-core (3.0.0)
      rspec-support (~> 3.0.0)
    rspec-expectations (3.0.0)
      rspec-support (~> 3.0.0)
    rspec-mocks (3.0.1)
      rspec-support (~> 3.0.0)
    rspec-rails (3.0.1)
      rspec-core (~> 3.0.0)
      rspec-expectations (~> 3.0.0)
      rspec-mocks (~> 3.0.0)
      rspec-support (~> 3.0.0)
    rspec-support (3.0.0)
  rspec-rails (>= 3.0.0)

I know this info is too little for you guys to debug, is there any way to get more info for you to debug what’s going on?

About this issue

  • Original URL
  • State: closed
  • Created 12 years ago
  • Comments: 15 (7 by maintainers)

Most upvoted comments

@JonRowe @myronmarston finally I fix this issue,

 before do
    Rails.application.routes.draw do
      get 'temp_admin/index', controller: :temp_admin, action: :index
    end
  end

I add reload_routes! fix all test

  after do
    Rails.application.reload_routes!
  end

thanks for your time, with our stupid code, have a nice day 😃