[Rspec-devel] [PATCH] Adds -I option to spec, error handling on options parse

Daniel Harple dharple at generalconsumption.org
Tue May 9 13:14:33 EDT 2006


On May 9, 2006, at 3:35 PM, David Chelimsky wrote:
> Thanks for the patch! Definitely like the backtrace cleanup on parse
> errors, but I wonder what benefit are you seeking in adding
> directories to the load path? Please explain.

It adds another way to run your specs:

     1) $LOAD_PATH manipulation
     # foo_spec.rb
     $LOAD_PATH.unshift(File.dirname(__FILE__) + "../lib")
     require 'my_lib'

     $ spec spec/foo_spec.rb

     2) use Ruby's -I option. Not much gained here.
     # foo_spec.rb
     require 'rubygems'
     require 'spec'
     require 'my_lib'

     $ ruby -Ilib spec/foo_spec.rb

     3) Use the Rake task
     # foo_spec.rb
     require 'my_lib'

     # Rakefile
     # ...

     $ rake spec

     4) Proposed -I option for spec
     # foo_spec.rb
     require 'my_lib'

     $ spec -Ilib spec/foo_spec.rb

In case (1) and (2) I have to place extra code in my spec to get it  
up and running. In (3) I must be use rake. With (4), the -I option, I  
could have a simple alias in my ~/.profile[1]:

     alias run_spec='spec -Ilib'

     $ run_spec spec/ # run them all
     $ run_spec spec/foo_spec.rb # run a specific spec

[1]: Ok, this is technically code, too.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: hide_OptionParser_backtrace.patch
Type: application/octet-stream
Size: 1477 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/rspec-devel/attachments/20060509/b703ccec/attachment-0002.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: include_load_path_option.patch
Type: application/octet-stream
Size: 1220 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/rspec-devel/attachments/20060509/b703ccec/attachment-0003.obj 
-------------- next part --------------


-- Daniel



More information about the Rspec-devel mailing list