On Wed, Jul 9, 2008 at 10:09 PM, David Chelimsky <<a href="mailto:dchelimsky@gmail.com">dchelimsky@gmail.com</a>> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div style=""><div><div class="Ih2E3d"><div>On Jul 9, 2008, at 5:52 PM, Rick DeNatale wrote:</div><br></div><div>spec:models, views, controllers and helpers are all defined already in vendor/plugins/rspec-rails/tasks/rspec.rake, so the next keyword is being invoked for all of those. You'll need to undefined them before you redefine them here.</div>
<div><br></div><div>spec_tasks.each {|t| Rake::Task::TASKS.delete t}</div><div><br></div><div></div></div></div></blockquote><div><br>Thanks David, I figured it was something like that. I had to modify it a bit since there is no TASKS constant. Rake::Task does have a tasks method, but it wasn't clear that deleting an element would work since it must be flattening the task namespace hierarchy. So I ended up with this:<br>
<br> begin<br> require RAILS_ROOT + '/vendor/plugins/rspec/lib/spec/rake/spectask'<br><br> namespace :spec do<br> spec_subdirs.each do |task|<br> if Rake::Task.task_defined?("spec:#{task}")<br>
Rake::Task["spec:#{task}"].fail_on_error = false<br> else<br> desc "Run the specs under spec/#{task}"<br> Spec::Rake::SpecTask.new(task) do |t|<br> t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]<br>
t.spec_files = FileList["spec/#{task}/*_spec.rb"]<br> t.fail_on_error = false<br> end<br> end<br> if Rake::Task.task_defined?("spec:#{task}:rcov")<br> Rake::Task["spec:#{task}:rcov"].fail_on_error = false<br>
else<br> namespace(task) do<br> Spec::Rake::SpecTask.new(:rcov) do |t|<br> t.spec_opts = ['--options', "\"#{RAILS_ROOT}/spec/spec.opts\""]<br> t.rcov_opts = ['--include', "\"app/#{task}/.*.rb$\""]<br>
t.rcov = true<br> t.fail_on_error = false<br> t.spec_files = FileList["spec/#{task}/*_spec.rb"]<br> end<br> end<br> end<br> end<br> end<br>rescue LoadError => e<br>
puts "Spec tasks are not available - #{e}"<br>end<br><br>But this still DOESN'T WORK.<br><br>It turns out that this code is running BEFORE the plugin creates its tasks so those are overwriting mine.<br><br>
I'm beginning to think that I need to patch RSpec to allow the default value of fail_on_error to be set with either an environment variable or in spec.opts.<br><br>Thoughts?<br></div></div>-- <br>Rick DeNatale<br><br>
My blog on Ruby<br><a href="http://talklikeaduck.denhaven2.com/">http://talklikeaduck.denhaven2.com/</a>