guard / guard-spork

Guard::Spork automatically manage Spork DRb servers
https://rubygems.org/gems/guard-spork
MIT License
296 stars 58 forks source link

rake db:test:prepare #119

Closed mockdeep closed 10 years ago

mockdeep commented 10 years ago

It might be nice to have an option to automatically prepare the test database when loading spork. After migration changes I often forget to run rake db:test:prepare, boot up guard, then have to shut it down again and run it.

xrkhill commented 10 years ago

I could see how that would be useful. Do you want to open a pull request?

On Thursday, August 8, 2013, Robert Fletcher wrote:

It might be nice to have an option to automatically prepare the test database when loading spork. After migration changes I often forget to run rake db:test:prepare, boot up guard, then have to shut it down again and run it.

— Reply to this email directly or view it on GitHubhttps://github.com/guard/guard-spork/issues/119 .

mockdeep commented 10 years ago

Sure, I can take a look. Would you suggest just prepending the command for spork_instance?

xrkhill commented 10 years ago

Sorry for the delay, @mockdeep. I'm new to the project and needed some time to dig into the code. I like this feature, but want to make sure we accommodate users that may not be using Rails or don't want the feature. I think using Guard callbacks may be the best way to tackle this problem. We could add something like the following to the Guardfile template:

# Guardfile
guard 'spork' do
  watch('config/application.rb')
  # ...

  callback([:start_begin, :reload_begin]) do
    puts "Running db:test:prepare"
    `rake db:test:prepare`
  end
end

This would run the rake task when Guard is started, or when reload is run from the Guard console. There are more callbacks available. We could also create some custom hooks in the Spork plugin if the builtin callbacks don't meet our needs. What do you think about that approach?

xrkhill commented 10 years ago

@mockdeep I'm closing this issue. We can discuss other options if callbacks don't meet your needs.

mockdeep commented 10 years ago

Thanks @xrkhill. Sorry for not getting back on this sooner. I was hoping to get around to testing it out more thoroughly, but callbacks look like they'll do the trick.

xrkhill commented 10 years ago

No worries @mockdeep. I'm glad callbacks will work for you.