Permalink
Browse files

Got cucumber working with rails 3 example app [unstable]

  • Loading branch information...
1 parent 93ed4a2 commit 1e91e455cb4a92268430f43627794cebef5b5a65 @ianwhite committed Mar 14, 2011
View
@@ -7,17 +7,18 @@ end
desc "setup a rails app for running cucumber"
file "cucumber_test_app" do
- puts "** setting up cucumber test app ** (rails 2.3 only at present)"
+ puts "** setting up cucumber test app **"
Rake::Task['cucumber:setup'].invoke
end
namespace :cucumber do
task :setup do
rm_rf "cucumber_test_app"
- sh "rails cucumber_test_app"
+ sh "rails new cucumber_test_app"
cd "cucumber_test_app" do
- sh "script/generate rspec"
- sh "script/generate cucumber"
+ sh "echo 'gem \"cucumber-rails\"' >> Gemfile"
+ sh "echo 'gem \"rspec-rails\"' >> Gemfile"
+ sh "bundle install"
end
sh "ln -s #{File.expand_path('.')} cucumber_test_app/vendor/plugins/pickle"
end
View
@@ -1,7 +1,7 @@
require 'autotest/bundler'
Autotest.add_hook :initialize do |autotest|
- %w{.git .DS_Store ._* vendor tmp email}.each do |exception|
+ %w{.git .DS_Store ._* vendor tmp email cucumber_test_app}.each do |exception|
autotest.add_exception(exception)
end
end
View
@@ -1,12 +1,12 @@
# Routes
-ActionController::Routing::Routes.draw do |map|
- map.resources :spoons, :controller => 'default'
- map.resources :forks, :controller => 'default' do |fork|
- fork.resources :tines, :controller => 'default' do |tine|
- tine.resources :comments, :controller => 'default'
+Rails.application.routes.draw do
+ resources :spoons, :controller => 'default'
+ resources :forks, :controller => 'default' do
+ resources :tines, :controller => 'default' do
+ resources :comments, :controller => 'default'
end
end
- map.resources :users, :controller => 'default'
+ resources :users, :controller => 'default'
end
# Migrations
@@ -98,14 +98,10 @@ def edit
# notifiers
class Notifier < ActionMailer::Base
- include ActionController::UrlWriter
+ include Rails.application.routes.url_helpers
# BC 2.1
- if respond_to?(:view_paths)
- view_paths << "#{File.dirname(__FILE__)}/views"
- else
- self.template_root = "#{File.dirname(__FILE__)}/views"
- end
+ self.view_paths = "#{File.dirname(__FILE__)}/views"
def user_email(user)
@recipients = user.email
@@ -8,11 +8,11 @@
end
Given(/^cucumber has been freshly generated$/) do
- `cd #{Rails.root}; script/generate cucumber -f --webrat`
+ `cd #{Rails.root}; rails g cucumber:install -f --webrat`
end
Given(/^pickle path email has been freshly generated$/) do
- `cd #{Rails.root}; script/generate -f pickle paths email`
+ `cd #{Rails.root}; rails g pickle paths email -f`
end
Given(/^env\.rb already requires (.+)$/) do |file|
View
@@ -4,7 +4,7 @@
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
# files.
-ENV["RAILS_ENV"] ||= "cucumber"
+ENV["RAILS_ENV"] ||= "test"
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
@@ -45,8 +45,12 @@
# subsequent scenarios. If you do this, we recommend you create a Before
# block that will explicitly put your database in a known state.
Cucumber::Rails::World.use_transactional_fixtures = true
-
# How to clean your database when transactions are turned off. See
# http://github.com/bmabey/database_cleaner for more info.
-require 'database_cleaner'
-DatabaseCleaner.strategy = :truncation
+if defined?(ActiveRecord::Base)
+ begin
+ require 'database_cleaner'
+ DatabaseCleaner.strategy = :truncation
+ rescue LoadError => ignore_if_database_cleaner_not_present
+ end
+end

0 comments on commit 1e91e45

Please sign in to comment.