Skip to content

Instantly share code, notes, and snippets.

@mcmire
Created April 19, 2012 22:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcmire/2424524 to your computer and use it in GitHub Desktop.
Save mcmire/2424524 to your computer and use it in GitHub Desktop.
Dropping `bundle exec guard` to speed up the test feedback loop

With bundle exec:

$ bundle exec guard
[resave spec_fast/models/user_spec.rb]
Run options: --seed 25736
Started

User
   SKIP test_0001_works (0.00s)

Finished in 0.00282s
1 tests, 0 assertions, 0 failures, 0 errors, 1 skips
ruby spec_fast/models/user_spec.rb (1.33792 seconds)

Without bundle exec:

$ guard
[resave spec_fast/models/user_spec.rb]
Run options: --seed 59910
Started

User
   SKIP test_0001_works (0.00s)

Finished in 0.00153s
1 tests, 0 assertions, 0 failures, 0 errors, 1 skips
ruby spec_fast/models/user_spec.rb (0.453997 seconds)
gem 'guard-shell'
gem 'minitest-reporters'
require 'benchmark'
guard 'shell' do
run = lambda do |file|
cmd = "ruby #{file}"
secs = Benchmark.realtime { system(cmd) }
puts "#{cmd} (#{secs} seconds)"
end
watch(%r{^spec_fast/.+_spec\.rb$}) {|m| run.(m[0]) }
end
# spec_fast/spec_helper.rb
require 'minitest/autorun'
require 'pp'
require 'minitest/reporters'
MiniTest::Unit.runner = MiniTest::SuiteRunner.new
MiniTest::Unit.runner.reporters << MiniTest::Reporters::SpecReporter.new
# app/models/user.rb
class User
# nothing to see here
end
# spec_fast/models/user_spec.rb
require_relative '../spec_helper'
require_relative '../../app/models/user'
describe User do
it "works"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment