Created
September 19, 2012 22:37
-
-
Save chrisnicola/3752779 to your computer and use it in GitHub Desktop.
Guard problems
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 'spork', :cucumber_env => { 'RAILS_ENV' => 'test' }, :rspec_env => { 'RAILS_ENV' => 'test' } 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('test/test_helper.rb') { :test_unit } | |
watch(%r{features/support/}) { :cucumber } | |
end | |
guard 'rspec', :version => 2 do | |
watch(%r{^spec/.+_spec\.rb$}) | |
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" } | |
watch('spec/spec_helper.rb') { "spec" } | |
watch('spec/factories.rb') { "spec" } | |
# Rails example | |
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{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] } | |
watch(%r{^spec/support/(.+)\.rb$}) { "spec" } | |
watch('config/routes.rb') { "spec/routing" } | |
watch('app/controllers/application_controller.rb') { "spec/controllers" } | |
# Capybara request specs | |
watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" } | |
# Context specs | |
watch(%r{^app/contexts/(.+)\.rb$}) { |m| "spec/contexts/#{m[1]}_spec.rb" } | |
end | |
guard 'livereload' do | |
watch(%r{app/views/.+\.(erb|haml|slim)}) | |
watch(%r{app/helpers/.+\.rb}) | |
watch(%r{public/.+\.(css|js|html)}) | |
watch(%r{config/locales/.+\.yml}) | |
# Rails Assets Pipeline | |
watch(%r{(app|vendor)/assets/\w+/(.+\.(scss|css|js|html)).*}) { |m| "/assets/#{m[2]}" } | |
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
ENV["RAILS_ENV"] ||= 'test' | |
require File.expand_path("../../config/environment", __FILE__) | |
require 'rspec/rails' | |
require 'rspec/autorun' | |
require 'spork' | |
require 'capybara/rspec' | |
require 'capybara/webkit/matchers' | |
# Requires supporting ruby files with custom matchers and macros, etc, | |
# in spec/support/ and its subdirectories. | |
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f} | |
Spork.prefork do | |
# This code will be run each time you run your specs. | |
RSpec.configure do |config| | |
config.include Devise::TestHelpers, :type => :controller | |
# ## Mock Framework | |
# | |
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line: | |
# | |
# config.mock_with :mocha | |
# config.mock_with :flexmock | |
# config.mock_with :rr | |
require 'database_cleaner' | |
config.before(:suite) do | |
DatabaseCleaner[:mongoid].strategy = :truncation | |
end | |
config.before(:each) do | |
DatabaseCleaner.clean | |
ActionMailer::Base.deliveries.clear | |
end | |
# If true, the base class of anonymous controllers will be inferred | |
# automatically. This will be the default behavior in future versions of | |
# rspec-rails. | |
config.infer_base_class_for_anonymous_controllers = false | |
Capybara.javascript_driver = :webkit | |
end | |
end | |
Spork.each_run do | |
end | |
class Helpers | |
def self.test_log_path filename | |
if (ENV['TDDIUM_SESSION_ID']) | |
File.expand_path("#{ENV['HOME']}/results/#{ENV['TDDIUM_SESSION_ID']}/#{ENV['TDDIUM_TEST_EXEC_ID']}/") + '/' + filename | |
else | |
File.expand_path('log/') + '/' + filename | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
spec/spec_helper.rb
, I think you should move more into theSpork.prefork
block. I'm not 100% sure of the behavior of parts that areoutside of it, but that is what I'm used to seeing.
Gemfile
?:bundle exec guard -d
should tell you more.Starting Spork for RSpec
output before these slow runs? (That means it's restarting all of Spork, basically nullifying the benefits of Sporking).--drb
in the.rspec
file or on thecli:
option of theguard 'rspec'
call)spork -d
's output, but it seems like it's not working on Rails 3.2.7 right now: sporkrb/spork/#206guard -d
output?Let me know how it goes!
—☈