Skip to content

Commit

Permalink
Add a note about generating a cucumber test app for the 'rake cucumber'
Browse files Browse the repository at this point in the history
  • Loading branch information
ianwhite committed Apr 5, 2010
1 parent 67df857 commit ff13d41
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 47 deletions.
3 changes: 2 additions & 1 deletion .gitignore
@@ -1,4 +1,5 @@
pkg
doc/*
.garlic
webrat*
webrat*
cucumber_test_app
69 changes: 24 additions & 45 deletions Rakefile
Expand Up @@ -4,6 +4,7 @@ $LOAD_PATH.unshift(rspec_base) if File.exist?(rspec_base) and !$LOAD_PATH.includ

require 'spec/rake/spectask'
require 'spec/rake/verify_rcov'
require 'cucumber/rake/task'

$LOAD_PATH.unshift File.dirname(__FILE__) + '/lib'
require 'pickle/version'
Expand Down Expand Up @@ -34,56 +35,34 @@ namespace :rcov do
end
end

# cucumber features require an enclosing rails app
plugins_base = File.expand_path(File.join(File.dirname(__FILE__), '..'))
cucumber_base = File.join(plugins_base, 'cucumber/lib')
if File.exists?(cucumber_base) && plugins_base =~ /\/vendor\/plugins$/ # if we're in rails app
$:.unshift(cucumber_base)
require 'cucumber/rake/task'

desc "Run features for #{PluginName} (progress)"
Cucumber::Rake::Task.new(:features) do |t|
t.fork = true
t.cucumber_opts = ['--format', 'progress', '--require', 'features']
end

desc "Run features for #{PluginName} (full output)"
namespace :features do
Cucumber::Rake::Task.new(:full) do |t|
t.cucumber_opts = ['--format', 'pretty', '--require', 'features']
end
end
desc "Run features for #{PluginName} (progress)"
Cucumber::Rake::Task.new(:cucumber => [:cucumber_test_app]) do |t|
t.cucumber_opts = ['--format', 'progress', '--require', 'features']
end

# the following optional tasks are for CI, gems and doc building
begin
require 'hanna/rdoctask'
require 'garlic/tasks'
require 'grancher/task'
desc "setup a rails app for running cucumber"
file "cucumber_test_app" do
raise <<-EOD
** Please setup a test rails app in cucumber_test_app **
Until this is automated, do something like:
task :cruise => ['garlic:all', 'doc:publish']
rails cucumber_test_app
cd cucumber_test_app
script/generate rspec
script/generate cucumber
cd vendor/plugins
ln -s ../../.. pickle
cd ../../..
Rake::RDocTask.new(:doc) do |d|
d.options << '--all'
d.rdoc_dir = 'doc'
d.main = 'README.rdoc'
d.title = "#{PluginName} API docs"
d.rdoc_files.include('README.rdoc', 'History.txt', 'License.txt', 'Todo.txt', 'lib/**/*.rb')
end
Then run
namespace :doc do
task :publish => :doc do
Rake::Task['doc:push'].invoke unless uptodate?('.git/refs/heads/gh-pages', 'doc')
end

Grancher::Task.new(:push) do |g|
g.keep_all
g.directory 'doc', 'doc'
g.branch = 'gh-pages'
g.push_to = 'origin'
end
end
rescue LoadError
rake cucumber
** thanks! **
EOD
end

begin
Expand Down
2 changes: 1 addition & 1 deletion features/support/env.rb
Expand Up @@ -5,7 +5,7 @@
# files.

ENV["RAILS_ENV"] ||= "cucumber"
require File.expand_path(File.dirname(__FILE__) + '/../../../../../config/environment')
require File.expand_path(File.dirname(__FILE__) + '/../../cucumber_test_app/config/environment')

require 'cucumber/formatter/unicode' # Remove this line if you don't want Cucumber Unicode support
require 'cucumber/rails/world'
Expand Down

0 comments on commit ff13d41

Please sign in to comment.