AgilionApps / AgilionRecipes

Agilion Chef Recipes
3 stars 2 forks source link

Add guard/spork gem to Rails template #8

Open beerlington opened 11 years ago

beerlington commented 11 years ago

Here's what I've got working so far with Vagrant (Im only working with RSpec at the moment so Cucumber stuff is disabled):

Command

guard start --force-polling --no-interactions

Gemfile

group :test do
  gem 'guard-rspec'
  gem 'guard-spork'
end

Guardfile

guard 'spork', :cucumber => false do
  watch('config/application.rb')
  watch('config/environment.rb')
  watch(%r{^config/environments/.*\.rb$})
  watch(%r{^config/initializers/.*\.rb$})
  watch('Gemfile')
  watch('Gemfile.lock')
  watch('spec/spec_helper.rb') { :rspec }
  watch(%r{features/support/}) { :cucumber }
end

guard 'rspec', :cli => "--drb" do
  watch('spec/spec_helper.rb')                        { "spec" }
  watch('config/routes.rb')                           { "spec/routing" }
  watch('app/controllers/application_controller.rb')  { "spec/controllers" }
  watch(%r{^spec/.+_spec\.rb$})
  watch(%r{^app/(.+)\.rb$})                           { |m| "spec/#{m[1]}_spec.rb" }
  watch(%r{^app/(.*)(\.erb|\.haml)$})                 { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
  watch(%r{^lib/(.+)\.rb$})                           { |m| "spec/lib/#{m[1]}_spec.rb" }
end
beerlington commented 11 years ago

You also need to run:

spork --bootstrap

More info at http://railscasts.com/episodes/285-spork?view=asciicast

alanpeabody commented 11 years ago

If guard running on the server is too slow, we could try running guard on the host, but have it execute the tests on the server:

vagrant ssh -c 'cd /vagrant && rspec spec'
beerlington commented 11 years ago

I wonder if we could have spork or spring running on the VM and when we issue your command above it would use that dRb server. that way it would still be fast and we could get immediate feedback.

alanpeabody commented 11 years ago

I would like to re-examine this now that we have NFS working.