Below are some tools, workarounds, and gotchas to help speed things up when getting testing working.
To get tests to run properly you'll need to add a line to spec_helper.rb file.
.
.
.
RSpec.configure do |config|
.
.
.
config.include Capybara::DSL
end
After installing the RubyTest package you can issue the following commands to run tests directly from Sublime.
- CMD-Shift-R: run a single test (if run on an it block) or group of tests (if run on a describe block)
- CMD-Shift-E: run the last test(s)
- CMD-Shift-T: run all the tests in current file
The Spork test server loads the environment once, and then maintains a pool of processes for running future tests.
Start Spork by going into your desired rails directory and issuing the spork
command. It will then be up and running in that terminal window.
Configure RSpec to automatically use Spork by adding this to the .rspec file
--colour
--drb
For fast real time testing you can combine Guard and Spork. First issue this command in terminal
guard init spork
Then you'll need to change the Guardfile
require 'active_support/inflector'
guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'test' },
:rspec_env => { 'RAILS_ENV' => 'test' } do
watch('config/application.rb')
watch('config/environment.rb')
watch('config/environments/test.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', after_all_pass: false, cli: '--drb' do
.
.
.
end