I have adopted Avdi Grimm's naming convention for integration specs (*_integration_spec.rb) from Object on Rails.
I use Spork for specs which load the full rails stack such as controllers, integration models specs, ... For models unit tests and libs, I don't want the overhead of Spork.
The challenge was to come up with a simple regex using "Negative lookbehind assertion" in order to avoid running specs twice each time a file is saved. I found out a bit late that the "ignore" keyword from Guard DSL is global.
I'd like some feedback about that approach. What do you use for this? Is it overkill. I have seen some people using an "unit" folder.
Thanks,
JM
This is how my Guardfile looks:
group 'tests-with-spork' do guard 'rspec', :version => 2, :cli => "--drb", :all_after_pass => false do watch('spec/spec_helper.rb') { "spec" } watch(%r{^spec/controllers/.+_spec\.rb$}
)
watch(%r{^spec/models/.+_spec\.rb$})
watch(%r{^spec/helpers/.+_spec\.rb$})
watch(%r{^spec/routing/.+_spec\.rb$})
watch(%r{^spec/requests/.+_spec\.rb$})
watch(%r{^spec/integration/.+_spec\.rb$})
watch(%r{^app/models/(.+)\.rb$}) { |m| "spec/models/#{m[1]}_spec.rb" }
watch(%r{^app/helpers/(.+)\.rb$}) { |m| "spec/helpers/#{m[1]}_spec.rb" }
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) do |m|
[
"spec/routing/#{m[1]}_routing_spec.rb",
"spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb"
]
end
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
watch('config/routes.rb') { "spec/routing" }
watch('app/controllers/application_controller.rb') { "spec/controllers"}
end end group 'unit-tests' do guard 'rspec', :version => 2, :all_on_start => false, :all_after_pass => false, :bundler => false do watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb"
}
watch(%r{^spec/lib/.+_spec\.rb$})
end
endHi Jean-Michel,Yeah I think it's overkill, if I understand well your setup you have some spec in /lib that are using Spork & integration specs?
Why not having only unit-test style with /lib files and a specific folder ("spec/integration") for your integrations specs. I'm not sure about the advantage of using _integration_spec.rb...