cucumber-rails 0.4.0.beta.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.rvmrc +1 -1
- data/HACKING.rdoc +6 -8
- data/History.txt +18 -2
- data/README.rdoc +8 -10
- data/cucumber-rails.gemspec +10 -6
- data/dev_tasks/cucumber.rake +1 -1
- data/features/allow_rescue.feature +61 -0
- data/features/inspect_query_string.feature +36 -0
- data/features/install_cucumber_rails.feature +16 -0
- data/features/mongoid.feature +53 -0
- data/features/named_selectors.feature +33 -0
- data/features/no_database.feature +69 -0
- data/features/rerun_profile.feature +1 -2
- data/features/rest_api.feature +46 -0
- data/features/routing.feature +21 -0
- data/features/select_dates.feature +25 -0
- data/features/step_definitions/cucumber_rails_steps.rb +65 -4
- data/features/support/env.rb +5 -1
- data/generators/cucumber/cucumber_generator.rb +1 -27
- data/lib/cucumber/rails.rb +3 -20
- data/lib/cucumber/rails/capybara.rb +7 -0
- data/lib/cucumber/rails/capybara/select_dates_and_times.rb +21 -14
- data/lib/cucumber/rails/hooks.rb +3 -0
- data/lib/cucumber/rails/hooks/database_cleaner.rb +16 -3
- data/lib/cucumber/rails/rspec.rb +2 -0
- data/lib/cucumber/rails/version.rb +14 -9
- data/lib/cucumber/rails/world.rb +6 -0
- data/lib/cucumber/rails2.rb +1 -1
- data/lib/cucumber/rails3.rb +7 -7
- data/lib/generators/cucumber/install/install_base.rb +11 -51
- data/templates/install/config/cucumber.yml.erb +1 -1
- data/templates/install/step_definitions/capybara_steps.rb.erb +63 -85
- data/templates/install/step_definitions/web_steps_cs.rb.erb +11 -20
- data/templates/install/step_definitions/web_steps_da.rb.erb +11 -20
- data/templates/install/step_definitions/web_steps_es.rb.erb +11 -20
- data/templates/install/step_definitions/web_steps_ja.rb.erb +1 -0
- data/templates/install/step_definitions/web_steps_ko.rb.erb +1 -0
- data/templates/install/step_definitions/web_steps_no.rb.erb +11 -20
- data/templates/install/step_definitions/web_steps_pt-BR.rb.erb +11 -20
- data/templates/install/step_definitions/webrat_steps.rb.erb +11 -10
- data/templates/install/support/_rails_each_run.rb.erb +3 -19
- data/templates/install/support/edit_warning.txt +19 -5
- data/templates/install/support/selectors.rb +39 -0
- data/templates/install/tasks/cucumber.rake.erb +4 -0
- metadata +100 -82
- data/features/rails2.feature +0 -45
- data/features/rails3.feature +0 -123
- data/features/support/matchers/files.rb +0 -17
- data/spec/generators/cucumber/install/install_base_spec.rb +0 -75
@@ -0,0 +1,21 @@
|
|
1
|
+
Feature: Routing
|
2
|
+
|
3
|
+
Scenario: Visit undefined route
|
4
|
+
Given a project without ActiveRecord
|
5
|
+
And I remove the file "public/index.html"
|
6
|
+
And I write to "features/tests.feature" with:
|
7
|
+
"""
|
8
|
+
Feature: Tests
|
9
|
+
Scenario: Tests
|
10
|
+
When I go to the home page
|
11
|
+
"""
|
12
|
+
And I run `rake cucumber`
|
13
|
+
Then it should fail with:
|
14
|
+
"""
|
15
|
+
1 scenario (1 failed)
|
16
|
+
1 step (1 failed)
|
17
|
+
"""
|
18
|
+
And the stdout should contain:
|
19
|
+
"""
|
20
|
+
No route matches "/" (ActionController::RoutingError)
|
21
|
+
"""
|
@@ -0,0 +1,25 @@
|
|
1
|
+
Feature: Select dates
|
2
|
+
|
3
|
+
Background: A simple calendar app
|
4
|
+
Given I have created a new Rails 3 app "rails-3-app" with cucumber-rails support
|
5
|
+
And I successfully run `bundle exec rails g scaffold appointment name:string when:datetime`
|
6
|
+
|
7
|
+
Scenario: Select dates
|
8
|
+
Given I write to "features/create_appointment.feature" with:
|
9
|
+
"""
|
10
|
+
Feature: Create appointments
|
11
|
+
Scenario: Constitution on May 17
|
12
|
+
Given I am on the new appointment page
|
13
|
+
And I fill in "Norway's constitution" for "Name"
|
14
|
+
And I select "2009-02-20 15:10:00 UTC" as the "When" date and time
|
15
|
+
And I press "Create Appointment"
|
16
|
+
Then I should see "Norway's constitution"
|
17
|
+
And I should see "2009-02-20 15:10:00 UTC"
|
18
|
+
"""
|
19
|
+
When I run `bundle exec rake db:migrate cucumber`
|
20
|
+
Then it should pass with:
|
21
|
+
"""
|
22
|
+
1 scenario (1 passed)
|
23
|
+
6 steps (6 passed)
|
24
|
+
"""
|
25
|
+
|
@@ -1,13 +1,74 @@
|
|
1
1
|
Given /^I have created a new Rails 3 app "([^"]*)" with cucumber\-rails support$/ do |app_name|
|
2
2
|
steps %Q{
|
3
|
-
When I successfully run
|
3
|
+
When I successfully run `rails new #{app_name}`
|
4
4
|
Then it should pass with:
|
5
5
|
"""
|
6
6
|
README
|
7
7
|
"""
|
8
8
|
And I cd to "#{app_name}"
|
9
|
-
And I
|
10
|
-
|
11
|
-
|
9
|
+
And I append to "Gemfile" with:
|
10
|
+
"""
|
11
|
+
gem "cucumber-rails", :group => :test, :path => "../../.."
|
12
|
+
gem "capybara", :group => :test
|
13
|
+
gem "rspec-rails", :group => :test
|
14
|
+
gem "database_cleaner", :group => :test
|
15
|
+
"""
|
16
|
+
And I successfully run `bundle exec rails generate cucumber:install`
|
12
17
|
}
|
13
18
|
end
|
19
|
+
|
20
|
+
Given /^a project without ActiveRecord$/ do
|
21
|
+
steps %Q{
|
22
|
+
Given I successfully run `rails new cuke-app`
|
23
|
+
And I cd to "cuke-app"
|
24
|
+
And I append to "Gemfile" with:
|
25
|
+
"""
|
26
|
+
gem "cucumber-rails", :group => :test, :path => "../../.."
|
27
|
+
gem "capybara", :group => :test
|
28
|
+
gem "rspec-rails", :group => :test
|
29
|
+
"""
|
30
|
+
And I successfully run `bundle exec rails generate cucumber:install`
|
31
|
+
And I overwrite "features/support/env.rb" with:
|
32
|
+
"""
|
33
|
+
require 'cucumber/rails'
|
34
|
+
"""
|
35
|
+
|
36
|
+
And I write to "config/application.rb" with:
|
37
|
+
"""
|
38
|
+
require File.expand_path('../boot', __FILE__)
|
39
|
+
|
40
|
+
require 'action_controller/railtie'
|
41
|
+
require 'action_mailer/railtie'
|
42
|
+
require 'active_resource/railtie'
|
43
|
+
require 'rails/test_unit/railtie'
|
44
|
+
|
45
|
+
Bundler.require(:default, Rails.env) if defined?(Bundler)
|
46
|
+
|
47
|
+
module CukeApp
|
48
|
+
class Application < Rails::Application
|
49
|
+
config.encoding = "utf-8"
|
50
|
+
config.filter_parameters += [:password]
|
51
|
+
end
|
52
|
+
end
|
53
|
+
"""
|
54
|
+
And I remove the file "config/database.yml"
|
55
|
+
}
|
56
|
+
end
|
57
|
+
|
58
|
+
And /^a cukes resource$/ do
|
59
|
+
steps %Q{
|
60
|
+
Given I write to "config/routes.rb" with:
|
61
|
+
"""
|
62
|
+
CukeApp::Application.routes.draw do
|
63
|
+
resources :cukes
|
64
|
+
end
|
65
|
+
"""
|
66
|
+
And I write to "app/controllers/cukes_controller.rb" with:
|
67
|
+
"""
|
68
|
+
class CukesController < ApplicationController
|
69
|
+
def index
|
70
|
+
end
|
71
|
+
end
|
72
|
+
"""
|
73
|
+
}
|
74
|
+
end
|
data/features/support/env.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
|
-
ENV['CUCUMBER_RAILS_TEST'] = 'yeah baby'
|
2
1
|
$:.unshift(File.dirname(__FILE__) + '/../../lib')
|
3
2
|
require 'rubygems'
|
4
3
|
require 'bundler/setup'
|
5
4
|
require 'rspec/expectations'
|
6
5
|
require 'aruba/cucumber'
|
6
|
+
|
7
|
+
Before do
|
8
|
+
@aruba_timeout_seconds = 60 # A long time needed some times to install gems (bundle install)
|
9
|
+
unset_bundler_env_vars
|
10
|
+
end
|
@@ -4,8 +4,6 @@ require File.expand_path(File.join(File.dirname(__FILE__), '../../lib/generators
|
|
4
4
|
class CucumberGenerator < Rails::Generator::Base
|
5
5
|
include Cucumber::Generators::InstallBase
|
6
6
|
|
7
|
-
attr_accessor :driver
|
8
|
-
attr_accessor :framework
|
9
7
|
attr_reader :language, :template_dir
|
10
8
|
|
11
9
|
def initialize(runtime_args, runtime_options = {})
|
@@ -19,14 +17,6 @@ class CucumberGenerator < Rails::Generator::Base
|
|
19
17
|
end
|
20
18
|
end
|
21
19
|
|
22
|
-
def framework
|
23
|
-
options[:framework] ||= detect_current_framework || detect_default_framework
|
24
|
-
end
|
25
|
-
|
26
|
-
def driver
|
27
|
-
options[:driver] ||= detect_current_driver || detect_default_driver
|
28
|
-
end
|
29
|
-
|
30
20
|
def self.gem_root
|
31
21
|
File.expand_path('../../../', __FILE__)
|
32
22
|
end
|
@@ -48,23 +38,7 @@ class CucumberGenerator < Rails::Generator::Base
|
|
48
38
|
def add_options!(opt)
|
49
39
|
opt.separator ''
|
50
40
|
opt.separator 'Options:'
|
51
|
-
opt.on('--
|
52
|
-
options[:driver] = :webrat
|
53
|
-
end
|
54
|
-
|
55
|
-
opt.on('--capybara', 'Setup cucumber for use with capybara') do
|
56
|
-
options[:driver] = :capybara
|
57
|
-
end
|
58
|
-
|
59
|
-
opt.on('--rspec', "Setup cucumber for use with RSpec") do
|
60
|
-
options[:framework] = :rspec
|
61
|
-
end
|
62
|
-
|
63
|
-
opt.on('--testunit', "Setup cucumber for use with test/unit") do
|
64
|
-
options[:framework] = :testunit
|
65
|
-
end
|
66
|
-
|
67
|
-
opt.on('--spork', 'Setup cucumber for use with Spork') do
|
41
|
+
opt.on('--spork', 'Use Spork to run features') do
|
68
42
|
options[:spork] = true
|
69
43
|
end
|
70
44
|
end
|
data/lib/cucumber/rails.rb
CHANGED
@@ -4,26 +4,9 @@ if Rails.version.to_f < 3.0
|
|
4
4
|
else
|
5
5
|
require 'cucumber/rails3'
|
6
6
|
end
|
7
|
-
|
8
|
-
require 'cucumber/rails/world'
|
9
|
-
require 'cucumber/rails/hooks/database_cleaner'
|
10
|
-
require 'cucumber/rails/hooks/allow_rescue'
|
11
|
-
|
12
|
-
if defined?(Capybara)
|
13
|
-
require 'capybara/rails'
|
14
|
-
require 'capybara/cucumber'
|
15
|
-
require 'capybara/session'
|
16
|
-
require 'cucumber/rails/capybara/javascript_emulation'
|
17
|
-
require 'cucumber/rails/capybara/select_dates_and_times'
|
18
|
-
end
|
19
7
|
|
20
|
-
|
21
|
-
|
8
|
+
require 'cucumber/rails/world'
|
9
|
+
require 'cucumber/rails/hooks'
|
10
|
+
require 'cucumber/rails/capybara'
|
22
11
|
|
23
12
|
require 'cucumber/web/tableish'
|
24
|
-
|
25
|
-
if !defined?(ActiveRecord::Base)
|
26
|
-
module Cucumber::Rails
|
27
|
-
def World.fixture_table_names; []; end # Workaround for projects that don't use ActiveRecord
|
28
|
-
end
|
29
|
-
end
|
@@ -3,26 +3,33 @@ module Cucumber
|
|
3
3
|
module Capybara
|
4
4
|
module SelectDatesAndTimes
|
5
5
|
def select_date(field, options = {})
|
6
|
-
date
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
6
|
+
date = Date.parse(options[:with])
|
7
|
+
base_dom_id = get_base_dom_id_from_label_tag(field)
|
8
|
+
|
9
|
+
find(:xpath, "//select[@id='#{base_dom_id}_1i']").select(date.year.to_s)
|
10
|
+
find(:xpath, "//select[@id='#{base_dom_id}_2i']").select(date.strftime('%B'))
|
11
|
+
find(:xpath, "//select[@id='#{base_dom_id}_3i']").select(date.day.to_s)
|
12
12
|
end
|
13
13
|
|
14
14
|
def select_time(field, options = {})
|
15
|
-
time
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
15
|
+
time = Time.zone.parse(options[:with])
|
16
|
+
base_dom_id = get_base_dom_id_from_label_tag(field)
|
17
|
+
|
18
|
+
find(:xpath, "//select[@id='#{base_dom_id}_4i']").select(time.hour.to_s.rjust(2, '0'))
|
19
|
+
find(:xpath, "//select[@id='#{base_dom_id}_5i']").select(time.min.to_s.rjust(2, '0'))
|
20
20
|
end
|
21
21
|
|
22
22
|
def select_datetime(field, options = {})
|
23
23
|
select_date(field, options)
|
24
24
|
select_time(field, options)
|
25
25
|
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
# @example "event_starts_at_"
|
30
|
+
def get_base_dom_id_from_label_tag(field)
|
31
|
+
find(:xpath, "//label[contains(., '#{field}')]")['for'].gsub(/(1i)$/, '')
|
32
|
+
end
|
26
33
|
end
|
27
34
|
end
|
28
35
|
end
|
@@ -30,14 +37,14 @@ end
|
|
30
37
|
|
31
38
|
World(::Cucumber::Rails::Capybara::SelectDatesAndTimes)
|
32
39
|
|
33
|
-
When /^(?:|I )select "([^"]
|
40
|
+
When /^(?:|I )select "([^"]+)" as the "([^"]+)" time$/ do |time, selector|
|
34
41
|
select_time(selector, :with => time)
|
35
42
|
end
|
36
43
|
|
37
|
-
When /^(?:|I )select "([^"]
|
44
|
+
When /^(?:|I )select "([^"]+)" as the "([^"]+)" date$/ do |date, selector|
|
38
45
|
select_date(selector, :with => date)
|
39
46
|
end
|
40
47
|
|
41
|
-
When /^(?:|I )select "([^"]
|
48
|
+
When /^(?:|I )select "([^"]+)" as the "([^"]+)" date and time$/ do |datetime, selector|
|
42
49
|
select_datetime(selector, :with => datetime)
|
43
50
|
end
|
@@ -1,19 +1,32 @@
|
|
1
|
+
# Default setup for DatabaseCleaner that will work for most projects.
|
2
|
+
# If you need your own setup, roll your own.
|
1
3
|
begin
|
2
4
|
require 'database_cleaner'
|
3
5
|
|
4
6
|
Before do
|
5
|
-
|
7
|
+
begin
|
8
|
+
$__cucumber_global_database_cleaner_strategy ||= DatabaseCleaner.connections[0].strategy # There is no accessor on the DatabaseCleaner
|
9
|
+
rescue DatabaseCleaner::NoStrategySetError => e
|
10
|
+
e.message << "\nYou can set the strategy in your features/support/env.rb"
|
11
|
+
end
|
6
12
|
end
|
7
13
|
|
8
14
|
Before('~@no-txn', '~@selenium', '~@culerity', '~@celerity', '~@javascript') do
|
9
|
-
|
15
|
+
DatabaseCleaner.strategy = :truncation
|
10
16
|
end
|
11
17
|
|
12
18
|
Before('@no-txn,@selenium,@culerity,@celerity,@javascript') do
|
13
|
-
|
19
|
+
DatabaseCleaner.strategy = $__cucumber_global_database_cleaner_strategy
|
14
20
|
end
|
15
21
|
|
16
22
|
Before do
|
23
|
+
# TODO: May have to patch DatabaseCleaner's Transaction class to do what we used to do:
|
24
|
+
# run_callbacks :setup if respond_to?(:run_callbacks)
|
25
|
+
# IIRC There was a cucumber-rails ticket that added that to support multiple connections...
|
26
|
+
# Similar in After (use run_callbacks :teardown if respond_to?(:run_callbacks))
|
27
|
+
#
|
28
|
+
# May also have to add this to Transaction:
|
29
|
+
# include ActiveSupport::Testing::SetupAndTeardown if ActiveSupport::Testing.const_defined?("SetupAndTeardown")
|
17
30
|
DatabaseCleaner.start
|
18
31
|
end
|
19
32
|
|
data/lib/cucumber/rails/rspec.rb
CHANGED
@@ -1,15 +1,20 @@
|
|
1
1
|
module Cucumber
|
2
2
|
module Rails
|
3
|
-
VERSION = '0.4.0
|
3
|
+
VERSION = '0.4.0'
|
4
4
|
DEPS = {
|
5
|
-
'
|
6
|
-
'
|
7
|
-
|
8
|
-
'
|
9
|
-
'
|
10
|
-
'
|
11
|
-
'
|
12
|
-
'
|
5
|
+
'aruba' => '>= 0.3.4',
|
6
|
+
'cucumber' => '>= 0.10.1',
|
7
|
+
|
8
|
+
'bundler' => '>= 1.0.10',
|
9
|
+
'rack-test' => '>= 0.5.7',
|
10
|
+
'nokogiri' => '>= 1.4.4',
|
11
|
+
'rails' => '>= 3.0.3',
|
12
|
+
'capybara' => '>= 0.4.1',
|
13
|
+
'webrat' => '>= 0.7.3',
|
14
|
+
'rspec-rails' => '>= 2.2.0',
|
15
|
+
'database_cleaner' => '>= 0.6.0',
|
16
|
+
'sqlite3-ruby' => '>= 1.3.3',
|
17
|
+
'mongoid' => '>= 2.0.0.rc.7'
|
13
18
|
}
|
14
19
|
end
|
15
20
|
end
|
data/lib/cucumber/rails/world.rb
CHANGED
@@ -1,10 +1,16 @@
|
|
1
1
|
module Cucumber #:nodoc:
|
2
2
|
module Rails #:nodoc:
|
3
3
|
class World < ActionController::IntegrationTest #:nodoc:
|
4
|
+
include Rack::Test::Methods
|
4
5
|
include ActiveSupport::Testing::SetupAndTeardown if ActiveSupport::Testing.const_defined?("SetupAndTeardown")
|
6
|
+
|
5
7
|
def initialize #:nodoc:
|
6
8
|
@_result = Test::Unit::TestResult.new if defined?(Test::Unit::TestResult)
|
7
9
|
end
|
10
|
+
|
11
|
+
if !defined?(ActiveRecord::Base)
|
12
|
+
def self.fixture_table_names; []; end # Workaround for projects that don't use ActiveRecord
|
13
|
+
end
|
8
14
|
end
|
9
15
|
end
|
10
16
|
end
|
data/lib/cucumber/rails2.rb
CHANGED
@@ -12,5 +12,5 @@ else
|
|
12
12
|
end
|
13
13
|
|
14
14
|
if !Rails.configuration.cache_classes
|
15
|
-
warn "WARNING: You have set Rails' config.cache_classes to false (most likely in config/environments/cucumber.rb). This setting is known to
|
15
|
+
warn "WARNING: You have set Rails' config.cache_classes to false (most likely in config/environments/cucumber.rb). This setting is known to cause problems with database transactions. Set config.cache_classes to true if you want to use transactions. For more information see https://rspec.lighthouseapp.com/projects/16211/tickets/165."
|
16
16
|
end
|
data/lib/cucumber/rails3.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
require 'cucumber/rails3/application'
|
2
2
|
ENV["RAILS_ENV"] ||= "test"
|
3
|
-
|
4
|
-
require File.expand_path(
|
3
|
+
ENV["RAILS_ROOT"] ||= File.expand_path(File.dirname(caller.detect{|f| f =~ /\/env\.rb:/}) + '/../..')
|
4
|
+
require File.expand_path(ENV["RAILS_ROOT"] + '/config/environment')
|
5
5
|
require 'cucumber/rails3/action_controller'
|
6
6
|
|
7
7
|
if defined?(ActiveRecord::Base)
|
8
|
-
require 'rails/test_help'
|
8
|
+
require 'rails/test_help'
|
9
9
|
else
|
10
|
-
require '
|
11
|
-
require '
|
10
|
+
require 'action_dispatch/testing/test_process'
|
11
|
+
require 'action_dispatch/testing/integration'
|
12
12
|
end
|
13
13
|
|
14
14
|
if !Rails.application.config.cache_classes
|
15
|
-
warn "WARNING: You have set Rails' config.cache_classes to false (most likely in config/environments/
|
16
|
-
end
|
15
|
+
warn "WARNING: You have set Rails' config.cache_classes to false (most likely in config/environments/cucumber.rb). This setting is known to cause problems with database transactions. Set config.cache_classes to true if you want to use transactions. For more information see https://rspec.lighthouseapp.com/projects/16211/tickets/165."
|
16
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'rbconfig'
|
2
|
-
|
2
|
+
require 'cucumber/rails/version'
|
3
3
|
|
4
4
|
module Cucumber
|
5
5
|
module Generators
|
@@ -14,13 +14,6 @@ module Cucumber
|
|
14
14
|
create_feature_support(m)
|
15
15
|
create_tasks(m)
|
16
16
|
create_database(m) unless options[:skip_database]
|
17
|
-
|
18
|
-
cucumber_rails_options = {:group => :test}
|
19
|
-
cucumber_rails_options[:path] = '../../..' if ENV['CUCUMBER_RAILS_TEST']
|
20
|
-
add_gem('cucumber-rails', Cucumber::Rails::VERSION, cucumber_rails_options)
|
21
|
-
add_gem(driver_from_options.to_s, Cucumber::Rails::DEPS[driver_from_options.to_s], :group => :test)
|
22
|
-
add_gem(framework_from_options.to_s, Cucumber::Rails::DEPS[framework_from_options.to_s], :group => :test)
|
23
|
-
add_gem('database_cleaner', Cucumber::Rails::DEPS['database_cleaner'], :group => :test)
|
24
17
|
end
|
25
18
|
|
26
19
|
# Checks and prints the limitations
|
@@ -73,22 +66,18 @@ module Cucumber
|
|
73
66
|
def create_feature_support(m)
|
74
67
|
if rails2?
|
75
68
|
m.directory 'features/support'
|
76
|
-
m.file 'support/paths.rb',
|
77
|
-
|
78
|
-
if spork?
|
79
|
-
m.template 'support/rails_spork.rb.erb', 'features/support/env.rb'
|
80
|
-
else
|
81
|
-
m.template 'support/rails.rb.erb', 'features/support/env.rb'
|
82
|
-
end
|
69
|
+
m.file 'support/paths.rb', 'features/support/paths.rb'
|
70
|
+
m.file 'support/selectors.rb', 'features/support/selectors.rb'
|
83
71
|
else
|
84
72
|
m.empty_directory 'features/support'
|
85
|
-
m.copy_file
|
73
|
+
m.copy_file 'support/paths.rb', 'features/support/paths.rb'
|
74
|
+
m.copy_file 'support/selectors.rb', 'features/support/selectors.rb'
|
75
|
+
end
|
86
76
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
end
|
77
|
+
if spork?
|
78
|
+
m.template 'support/rails_spork.rb.erb', 'features/support/env.rb'
|
79
|
+
else
|
80
|
+
m.template 'support/rails.rb.erb', 'features/support/env.rb'
|
92
81
|
end
|
93
82
|
end
|
94
83
|
|
@@ -103,6 +92,7 @@ module Cucumber
|
|
103
92
|
end
|
104
93
|
|
105
94
|
def create_database(m)
|
95
|
+
return unless File.exist?('config/database.yml')
|
106
96
|
unless File.read('config/database.yml').include? 'cucumber:'
|
107
97
|
m.gsub_file 'config/database.yml', /^test:.*\n/, "test: &test\n"
|
108
98
|
m.gsub_file 'config/database.yml', /\z/, "\ncucumber:\n <<: *test"
|
@@ -121,26 +111,6 @@ module Cucumber
|
|
121
111
|
end
|
122
112
|
end
|
123
113
|
|
124
|
-
def detect_current_driver
|
125
|
-
detect_in_env([['capybara', :capybara], ['webrat', :webrat]])
|
126
|
-
end
|
127
|
-
|
128
|
-
def detect_default_driver
|
129
|
-
@default_driver = first_loadable([['capybara', :capybara], ['webrat', :webrat]])
|
130
|
-
raise "I don't know which driver you want. Use --capybara or --webrat, or gem install capybara or webrat." unless @default_driver
|
131
|
-
@default_driver
|
132
|
-
end
|
133
|
-
|
134
|
-
def detect_current_framework
|
135
|
-
detect_in_env([['spec', :rspec]]) || :testunit
|
136
|
-
end
|
137
|
-
|
138
|
-
def detect_default_framework
|
139
|
-
# TODO need to check this - defaulting to :testunit has been moved from first_loadable
|
140
|
-
# It's unlikely that we don't have test/unit since it comes with Ruby
|
141
|
-
@default_framework ||= first_loadable([['rspec', :rspec]])
|
142
|
-
end
|
143
|
-
|
144
114
|
def spork?
|
145
115
|
options[:spork]
|
146
116
|
end
|
@@ -162,16 +132,6 @@ module Cucumber
|
|
162
132
|
IO.read(File.join(self.class.gem_root, 'VERSION')).chomp
|
163
133
|
end
|
164
134
|
|
165
|
-
def first_loadable(libraries)
|
166
|
-
require 'rubygems'
|
167
|
-
|
168
|
-
libraries.each do |lib_name, lib_key|
|
169
|
-
return lib_key if Gem.available?(lib_name)
|
170
|
-
end
|
171
|
-
|
172
|
-
nil
|
173
|
-
end
|
174
|
-
|
175
135
|
def detect_in_env(choices)
|
176
136
|
return nil unless File.file?("features/support/env.rb")
|
177
137
|
|