Permalink
Browse files

Don't force cucumber presence on Rakefile.

Only define the cucumber tasks if cucumber is available, allowing for the
Rakefile to work without Cucumber installed.

Note that Cucumber is still part of the bundle, so unless you're
disabling bundler as well, this patch has no effect.

See #35 for background.

- Closes #35.
  • Loading branch information...
1 parent eaa4468 commit 24f83546d8248c6a1aeef223941034bcf9cd6925 @Flameeyes Flameeyes committed with dchelimsky Feb 2, 2011
Showing with 27 additions and 22 deletions.
  1. +27 −22 Rakefile
View
@@ -5,15 +5,6 @@ Bundler::GemHelper.install_tasks
require 'rake'
require 'rspec/core/rake_task'
require 'rspec/mocks/version'
-require 'cucumber/rake/task'
-
-class Cucumber::Rake::Task::ForkedCucumberRunner
- # When cucumber shells out, we still need it to run in the context of our
- # bundle.
- def run
- sh "bundle exec #{RUBY} " + args.join(" ")
- end
-end
task :cleanup_rcov_files do
rm_rf 'coverage.data'
@@ -24,8 +15,6 @@ RSpec::Core::RakeTask.new(:spec) do |t|
t.rspec_opts = %w[--color]
end
-Cucumber::Rake::Task.new(:cucumber)
-
namespace :spec do
desc "Run all examples using rcov"
RSpec::Core::RakeTask.new :rcov => :cleanup_rcov_files do |t|
@@ -35,17 +24,35 @@ namespace :spec do
end
end
-namespace :cucumber do
- desc "Run cucumber features using rcov"
- Cucumber::Rake::Task.new :rcov => :cleanup_rcov_files do |t|
- t.cucumber_opts = %w{--format progress}
- t.rcov = true
- t.rcov_opts = %[-Ilib -Ispec --exclude "gems/*,features"]
- t.rcov_opts << %[--text-report --sort coverage --aggregate coverage.data]
+task :default => :spec
+
+begin
+ require 'cucumber/rake/task'
+
+ class Cucumber::Rake::Task::ForkedCucumberRunner
+ # When cucumber shells out, we still need it to run in the context of our
+ # bundle.
+ def run
+ sh "bundle exec #{RUBY} " + args.join(" ")
+ end
end
-end
-task :default => [:spec, :cucumber]
+ Cucumber::Rake::Task.new(:cucumber)
+
+ namespace :cucumber do
+ desc "Run cucumber features using rcov"
+ Cucumber::Rake::Task.new :rcov => :cleanup_rcov_files do |t|
+ t.cucumber_opts = %w{--format progress}
+ t.rcov = true
+ t.rcov_opts = %[-Ilib -Ispec --exclude "gems/*,features"]
+ t.rcov_opts << %[--text-report --sort coverage --aggregate coverage.data]
+ end
+ end
+
+ task :default => :cucumber
+rescue LoadError
+ $stderr.puts "unable to load cucumber, some tasks unavailable"
+end
task :clobber do
rm_rf 'pkg'
@@ -66,5 +73,3 @@ task :relish, :version do |t, args|
raise "rake relish[VERSION]" unless args[:version]
sh "relish push rspec/rspec-mocks:#{args[:version]}"
end
-
-task :default => [:spec, :cucumber]

0 comments on commit 24f8354

Please sign in to comment.