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 |
I should note all problems listed are intermittent with the exception of the last one.
- Regarding your
spec/spec_helper.rb
, I think you should move more into the
Spork.prefork
block. I'm not 100% sure of the behavior of parts that are
outside of it, but that is what I'm used to seeing. - Regarding Listen polling, isn't that a matter of having something like this in your
Gemfile
?:
case RUBY_PLATFORM
when /linux/i
gem 'rb-inotify'
when /darwin/i
gem 'rb-fsevent'
end
- I'm not sure about the refusal to run tests when manually hitting enter.
bundle exec guard -d
should tell you more. - Running all tests is expected to happen after each successful pass of an rspec triggered by a watch rule. You can disable that like this:
guard 'rspec', all_after_pass: false
- Being slow: Needs some more info.
- Are you seeing the
Starting Spork for RSpec
output before these slow runs? (That means it's restarting all of Spork, basically nullifying the benefits of Sporking). - Are you properly using DRb? (That means having
--drb
in the.rspec
file or on thecli:
option of theguard 'rspec'
call) - I'd advise you to check out
spork -d
's output, but it seems like it's not working on Rails 3.2.7 right now: sporkrb/spork/#206 - Can you gist some of the
guard -d
output?
- Are you seeing the
Let me know how it goes!
—☈
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm seeing a bunch of problems here include: