RobL Vs

Background

RSpec 1.2.7 and Spork

I just updated the RSpec gem today since seeing from The RSpec book update that there is a new release.

 1rl@bloodandguts:~/project$ ./script/spec_server 
 2Loading Rails environment
 3
 4*****************************************************************
 5DEPRECATION WARNING: you are using deprecated behaviour that will
 6be removed from a future version of RSpec.
 7
 8/usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
 9
10* spec_server is deprecated.
11* please use spork (gem install spork) instead.
12*****************************************************************

So…here we go.

1rl@bloodandguts:~/project$ sudo gem install spork
2Successfully installed spork-0.5.7
31 gem installed
4Installing ri documentation for spork-0.5.7...
5Updating ri class cache with 7915 classes...
6Installing RDoc documentation for spork-0.5.7...

Update the spec helper with the bootstrap command

1rl@bloodandguts:~/project$ spork --bootstrap
2Using RSpec
3Bootstrapping /home/rl/project/spec/spec_helper.rb.
4Done. Edit /home/rl/project/spec/spec_helper.rb now with your favorite text editor and follow the instructions.

The spec_helper will have instructions on how to edit the file although I mostly took the previous contents of the file and placed it in the ‘Spork.prefork’ block.

 1require 'rubygems'
 2require 'spork'
 3
 4Spork.prefork do
 5  # Loading more in this block will cause your tests to run faster. However, 
 6  # if you change any configuration or code from libraries loaded here, you'll
 7  # need to restart spork for it take effect.
 8end
 9
10Spork.each_run do
11  # This code will be run each time you run your specs.
12
13end
14
15# --- Instructions ---
16# - Sort through your spec_helper file. Place as much environment loading 
17#   code that you don't normally modify during development in the 
18#   Spork.prefork block.
19# - Place the rest under Spork.each_run block
20# - Any code that is left outside of the blocks will be ran during preforking
21#   and during each_run!
22# - These instructions should self-destruct in 10 seconds.  If they don't,
23#   feel free to delete them.
24#
25
26# This file is copied to ~/spec when you run 'ruby script/generate rspec'
27# from the project root directory.

Starting the server with just ‘spork’

1rl@bloodandguts:~/project$ spork
2Using RSpec
3Preloading Rails environment
4Loading Spork.prefork block...
5Spork is ready and listening on 8989!

And run your spec for good measure.

1rl@bloodandguts:~/project$ spec --drb spec/models/user_spec.rb 
2.....
3
4Finished in 6.806868 seconds
5
65 examples, 0 failures, 0 pending