guard-jruby-rspec
guard-jruby-rspec copied to clipboard
Class reloading for Rails projects
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?
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.
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.
:+1: this would be really awesome
I'll see if I can put together a pull request today with what I have working.
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.