Skip to content
Browse files

Ensure that rake works in environments without rspec gem installed

  • Loading branch information...
1 parent cfbbedb commit a8e3e2e2386c4504afaa90a78816213dd74e5ca9 @spejman spejman committed Jan 5, 2011
Showing with 26 additions and 1 deletion.
  1. +26 −1 generators/steak/templates/steak.rake
View
27 generators/steak/templates/steak.rake
@@ -1,6 +1,31 @@
unless ARGV.any? {|a| a =~ /^gems/} # Don't load anything when running the gems:* tasks
-require 'spec/rake/spectask'
+begin
+ require 'spec/rake/spectask'
+rescue MissingSourceFile
+ module Spec
+ module Rake
+ class SpecTask
+ def initialize(name)
+ task name do
+ # if rspec-rails is a configured gem, this will output helpful material and exit ...
+ require File.expand_path(File.join(File.dirname(__FILE__),"..","..","config","environment"))
+
+ # ... otherwise, do this:
+ raise <<-MSG
+
+#{"*" * 80}
+* You are trying to run an rspec rake task defined in
+* #{__FILE__},
+* but rspec can not be found in vendor/gems, vendor/plugins or system gems.
+#{"*" * 80}
+MSG
+ end
+ end
+ end
+ end
+ end
+end
namespace :spec do
desc "Run the code examples in spec/acceptance"

0 comments on commit a8e3e2e

Please sign in to comment.
Something went wrong with that request. Please try again.