[rspec-devel] [ rspec-Bugs-10333 ] can't load spec tasks from rakefiles with pluginized rspec [r1802]

noreply at rubyforge.org noreply at rubyforge.org
Tue Apr 24 06:18:14 EDT 2007


Bugs item #10333, was opened at 2007-04-24 09:54
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=10333&group_id=797

Category: rails plugin
Group: None
Status: Open
Resolution: None
Priority: 3
Submitted By: Ian White (ianwhite)
Assigned to: Nobody (None)
Summary: can't load spec tasks from rakefiles with pluginized rspec [r1802]

Initial Comment:
When rspec itself is pluginized (a great idea), all of my custom rakefiles which include spec/rake/whatever don't work.  The reason is noted in the rspec_on_rails tasks - the plugin libs don't get into the load path at this stage.

So everyone could change all of their scripts to check for the presence of the plugin and load the appropriate rspec lib from the right place.  
But how about adding the rspec/lib to the load paths in a rake task in rspec/tasks?  That way, if the rakefile in question is in Rails' purview, it will know about the rspec plugin lib.

This works for me:

in vendor/plugins/rspec/tasks/load_rspec.rake:

$: << File.expand_path(File.join(File.dirname(__FILE__), '../lib'))

Sorry if this isn't a bug - I figured that because it broke existing scripts it should be classified as one.

Cheers,
Ian White

----------------------------------------------------------------------

>Comment By: Ian White (ianwhite)
Date: 2007-04-24 10:18

Message:
Ok, so this works for me in lib/tasks/_load_rspec.rake

if File.exist?(rspec_base = File.join(RAILS_ROOT,
'vendor/plugins/rspec'))
  $: << File.expand_path(File.join(rspec_base, 'lib'))
end

----------------------------------------------------------------------

Comment By: Ian White (ianwhite)
Date: 2007-04-24 10:10

Message:
I just tried this approach for running a custom rcov task
from RAILS_ROOT/lib/tasks and it didn't work as rails loads
lib/tasks before vendor/plugins/**/tasks.  So I just had to
copy load_rspec into lib.tasks.  This could be done when
bootstrapping rspec_on_rails.

Also, perhaps the following is better, to avoid duplication
of the path

$: |= [File.expand_path(File.join(File.dirname(__FILE__),
'../lib'))]


----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=10333&group_id=797


More information about the rspec-devel mailing list