Created
September 15, 2011 22:35
-
-
Save agibralter/1220670 to your computer and use it in GitHub Desktop.
Is this the correct setup for spork + rspec + guard? It still seems like the specs are quite slow...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--colour | |
--drb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Guard::RSpec is running, with RSpec 2! | |
Running all specs | |
Running tests with args ["--color", "--format", "progress", "--format", "Guard::RSpec::Formatter::NotificationRSpec", "--out", "/dev/null", "--require", "/Users/agib/.rvm/gems/ruby-1.9.2-p290@fun/gems/guard-rspec-0.4.5/lib/guard/rspec/formatters/notification_rspec.rb", "spec"]... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Spork | |
guard 'spork', cucumber: false, test_unit: false, wait: 60 do | |
watch('config/application.rb') | |
watch('config/environment.rb') | |
watch(%r{^config/environments/.*\.rb$}) | |
watch(%r{^config/initializers/.*\.rb$}) | |
watch('spec/spec_helper.rb') | |
watch(%r{^spec/support/.*\.rb$}) | |
end | |
# RSpec | |
guard 'rspec' do | |
watch(%r{^spec/.+_spec\.rb$}) | |
watch('spec/spec_helper.rb') { 'spec' } | |
watch(%r{^spec/support/(.+)\.rb$}) { 'spec' } | |
watch(%r{^lib/(.+)\.rb$}) do |m| | |
"spec/lib/#{m[1]}_spec.rb" | |
end | |
watch(%r{^app/(.+)\.rb$}) do |m| | |
"spec/#{m[1]}_spec.rb" | |
end | |
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", | |
"spec/acceptance/#{m[1]}_spec.rb" | |
] | |
end | |
watch('app/controllers/application_controller.rb') { 'spec/controllers' } | |
watch('config/routes.rb') { 'spec/routing_spec.rb' } | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- encoding : utf-8 -*- | |
require 'spork' | |
Spork.prefork do | |
ENV["RAILS_ENV"] ||= 'test' | |
# https://gist.github.com/1054078 | |
require "rails/application" | |
Spork.trap_method(Rails::Application, :reload_routes!) | |
Spork.trap_method(Rails::Application::RoutesReloader, :reload!) | |
require File.expand_path("../../config/environment", __FILE__) | |
require 'rspec/rails' | |
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f } | |
RSpec.configure do |config| | |
config.mock_with :rspec | |
config.use_transactional_fixtures = true | |
# Allow {focus: true} to be passed to an example or group to only have that | |
# one run. | |
# config.filter_run :focus => true | |
# config.run_all_when_everything_filtered = true | |
end | |
SimpleCov.start if ENV["COVERAGE"] | |
end | |
Spork.each_run do | |
FunApp::Application.reload_routes! | |
FactoryGirl.reload | |
end |
@oreoshake I actually figured it out -- thinking sphinx was starting searchd and indexing before each run of my tests. It was crazy slow. Now that I've fixed it, it's super fast. :)
Nice! I would still argue that sphinx doesn't belong in your tests, but that depends on what kind of testing you're doing :)
Oh, of course! It was only supposed to start before certain tests but it was
starting before every single one. :)
I know it's been two years, but if you still have that configuration file for Thinking Sphinx for RSpec and Spork, I would love to see it. Been trying to get the three of them configured right for a while now and there aren't many examples to be found.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Guard + spork don't speed up your tests, they just speed up the startup time by not requiring a full reload of the environment. If your specs are slow, it may indicate you're not mocking correctly