Spork, autotest, and routes.rb conflict

  • Question
  • Updated 2 years ago
  • Answered
Looks like changing the routes.rb file without restarting spork messes up the tests. Not sure yet but after restarting spork everything worked fine. Will work through book more and let you know.
Photo of Evan Machnic

Evan Machnic

  • 2 Posts
  • 0 Reply Likes
  • happy

Posted 5 years ago

  • 5
Photo of Rails Tutorial

Rails Tutorial, Official Rep

  • 1009 Posts
  • 112 Reply Likes
That's true, but this is just par for the course when using Spork. Some things get preloaded by design, so you have to restart Spork when you change them. It's neither a bug nor a feature; it just is.

I'll look into making separate notes in the tutorial about when you need to restart Spork.
Photo of tinker

tinker

  • 1 Post
  • 3 Reply Likes
I was following the tutorial and it stopped working for me during the 'Green' section. Interestingly enough, both rspec spec/ and autotest+spork would not recognize the addition of:


get "pages/about"

to my routes.rb. When I restarted spork, everything worked, but having to restart Spork just for changing routes seemed unnecessary, so I went a googling.

I found the solution here: http://blog.carbonfive.com/2010/12/10...


# in spec/spec_helper.rb
Spork.each_run do
YourApplication::Application.reload_routes!
end


Change YourApplication to SampleApp, and you should be good to go.
Photo of ylluminate

ylluminate

  • 2 Posts
  • 0 Reply Likes
Been having the same problem here, however the link there @tinker didn't seem to do the trick. I've gotten a lot farther with guard-spork and guard-rspec vs autotest, but still having issues it seems.
Photo of carlos.el.lopesC

carlos.el.lopes

  • 1 Post
  • 1 Reply Like
I'm using guard-spork and guard-rspec and was having the same issue, but the @tinker solution works well for me
Photo of Chandresh Pant

Chandresh Pant

  • 1 Post
  • 0 Reply Likes
@tinker solution works for me as well with Rails 3.1. Thanks.
Photo of peter.i.ehrlich

peter.i.ehrlich

  • 1 Post
  • 0 Reply Likes
Nice, worked for me. It would if, further, there was a way to only do this if it has been routes.rb which has changed...