guard-jruby-rspec icon indicating copy to clipboard operation
guard-jruby-rspec copied to clipboard

Class reloading for Rails projects

Open nilbus opened this issue 12 years ago • 5 comments

Right now I'm working on a module that will kick in for rails projects that will use ActionDispatch::Reloader to reload rails classes the right way (like it does in development environment) rather than using load. Using load can be problematic for several reasons. Removing methods and classes in the code does not cause them to be undefined. Using RSpec 1 and maybe other test frameworks, each test run makes new duplicate copies of each spec, and the old copies still fail if they originally were. In general, it's not idempotent. This patch I'm working on this morning should fix that for Rails >= 3.1 projects.

Any thoughts on this?

nilbus avatar May 16 '13 13:05 nilbus

I would definitely be interested in accepting something like that (as long as it works on projects that are not rails, too). But I don't think I have any insight to how it should be done. Nonetheless, let me know if I can help with questions.

jkutner avatar May 16 '13 14:05 jkutner

Yes, I definitely intend to make it continue working as is for all rails versions and non-rails projects.

I'm finding that it may be useful to integrate with spork when it's available too. A typically Rails project that uses spork has in the spec_helper.rb a Spork.each_run block that contains things that need to happen after each run like DatabaseCleaner.clean that need to be executed before each test run to make subsequent runs successful.

nilbus avatar May 16 '13 14:05 nilbus

:+1: this would be really awesome

mattbeedle avatar May 28 '13 14:05 mattbeedle

I'll see if I can put together a pull request today with what I have working.

nilbus avatar May 28 '13 14:05 nilbus

This isn't working properly. Some modification after my initial tests is causing class unloading not to work. A method that gets deleted is not undefined for subsequent test runs.

nilbus avatar Jun 03 '13 18:06 nilbus