[rspec-devel] [ rspec-Bugs-10333 ] can't load spec tasks from rakefiles with pluginized rspec [r1802]
noreply at rubyforge.org
noreply at rubyforge.org
Mon Apr 30 19:54:30 EDT 2007
Bugs item #10333, was opened at 2007-04-24 05: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: Closed
>Resolution: Rejected
Priority: 3
Submitted By: Ian White (ianwhite)
>Assigned to: Aslak Hellesøy (aslak_hellesoy)
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: Aslak Hellesøy (aslak_hellesoy)
Date: 2007-04-30 19:54
Message:
Incomplete info. Feel free to reopen with more context info.
----------------------------------------------------------------------
Comment By: Aslak Hellesøy (aslak_hellesoy)
Date: 2007-04-24 06:27
Message:
Before investigating this we need to know the versions of all
relevant software, for example:
* OS X 10.4.9
* Ruby 1.8.6
* RSpec 1.8.2 or RSpec trunk r1643
* Spec::Rails 1.8.2 or Spec::Rails tag r1234...
* Rails 1.2.3 or Rails edge r5645
* Whatever other relevant software.
Without this information it's like solving 1 equation (your
question) with 5 unknown variables (the versions).
----------------------------------------------------------------------
Comment By: Ian White (ianwhite)
Date: 2007-04-24 06: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 06: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