class SetupGuardGenerator < ::Rails::Generators::Base
  GEMS_FOR_GUARD =<<-EOS
group :test, :development do
  # Guard
  gem 'spork'
  gem 'spork-rails'
  gem 'guard-spork'
  gem 'guard-rspec'
  gem 'rb-inotify', '~> 0.8.8'
end
  EOS

  def guard
    append_file "Gemfile", GEMS_FOR_GUARD
    run "bundle install"
    # Setup rspec spork
    run "bundle exec guard init spork"
    run "bundle exec guard init rspec"
    run "spork rspec --bootstrap"

    # Edit rspec settings
    append_file ".rspec", "\n--drb"

    # Edit Gurdfile for rspec
    inject_into_file "Guardfile", ", :all_after_pass => false, :all_on_start => false, :wait => 45 ", :after => "guard 'rspec'"
    puts '-----------------------------------'
    puts 'TODO:'
    puts 'rename Guardfile Guardfile.example '
    puts '-----------------------------------'
  end
end
