cucumber-rails 0.4.1 → 0.5.0.beta1
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/History.txt +9 -0
- data/README.md +74 -0
- data/config/cucumber.yml +1 -0
- data/cucumber-rails.gemspec +18 -18
- data/features/capybara_javascript_drivers.feature +1 -0
- data/features/emulate_javascript.feature +33 -0
- data/features/multiple_databases.feature +74 -0
- data/features/no_database.feature +1 -0
- data/features/pseduo_class_selectors.feature +24 -0
- data/features/select_dates.feature +36 -0
- data/features/step_definitions/cucumber_rails_steps.rb +1 -0
- data/lib/cucumber/rails.rb +1 -5
- data/lib/cucumber/rails/capybara/javascript_emulation.rb +4 -4
- data/lib/cucumber/rails/capybara/select_dates_and_times.rb +1 -1
- data/lib/cucumber/rails/hooks/database_cleaner.rb +0 -25
- data/lib/generators/cucumber/feature/feature_generator.rb +7 -16
- data/{templates/feature → lib/generators/cucumber/feature/templates}/feature.erb +0 -0
- data/{templates/feature → lib/generators/cucumber/feature/templates}/steps.erb +0 -0
- data/lib/generators/cucumber/install/install_generator.rb +68 -23
- data/{templates/install → lib/generators/cucumber/install/templates}/config/cucumber.yml.erb +0 -0
- data/{templates/install → lib/generators/cucumber/install/templates}/environments/cucumber.rb.erb +0 -4
- data/{templates/install → lib/generators/cucumber/install/templates}/script/cucumber +0 -0
- data/{templates/install/step_definitions/capybara_steps.rb.erb → lib/generators/cucumber/install/templates/step_definitions/web_steps.rb.erb} +2 -2
- data/{templates/install → lib/generators/cucumber/install/templates}/step_definitions/web_steps_cs.rb.erb +0 -0
- data/{templates/install → lib/generators/cucumber/install/templates}/step_definitions/web_steps_da.rb.erb +0 -0
- data/{templates/install → lib/generators/cucumber/install/templates}/step_definitions/web_steps_de.rb.erb +15 -24
- data/{templates/install → lib/generators/cucumber/install/templates}/step_definitions/web_steps_es.rb.erb +0 -0
- data/{templates/install → lib/generators/cucumber/install/templates}/step_definitions/web_steps_ja.rb.erb +0 -0
- data/{templates/install → lib/generators/cucumber/install/templates}/step_definitions/web_steps_ko.rb.erb +0 -0
- data/{templates/install → lib/generators/cucumber/install/templates}/step_definitions/web_steps_no.rb.erb +0 -0
- data/{templates/install → lib/generators/cucumber/install/templates}/step_definitions/web_steps_pt-BR.rb.erb +0 -0
- data/{templates/install → lib/generators/cucumber/install/templates}/support/_rails_each_run.rb.erb +12 -0
- data/{templates/install → lib/generators/cucumber/install/templates}/support/_rails_prefork.rb.erb +0 -0
- data/{templates/install → lib/generators/cucumber/install/templates}/support/capybara.rb +0 -0
- data/{templates/install → lib/generators/cucumber/install/templates}/support/edit_warning.txt +0 -0
- data/{templates/install → lib/generators/cucumber/install/templates}/support/paths.rb +3 -3
- data/{templates/install → lib/generators/cucumber/install/templates}/support/rails.rb.erb +1 -1
- data/{templates/install → lib/generators/cucumber/install/templates}/support/rails_spork.rb.erb +1 -1
- data/{templates/install → lib/generators/cucumber/install/templates}/support/selectors.rb +3 -3
- data/{templates/install → lib/generators/cucumber/install/templates}/support/web_steps_warning.txt +0 -0
- data/{templates/install → lib/generators/cucumber/install/templates}/tasks/cucumber.rake.erb +0 -0
- metadata +64 -73
- data/HACKING.rdoc +0 -22
- data/README.rdoc +0 -68
- data/VERSION +0 -1
- data/generators/cucumber/USAGE +0 -13
- data/generators/cucumber/cucumber_generator.rb +0 -46
- data/generators/feature/USAGE +0 -12
- data/generators/feature/feature_generator.rb +0 -47
- data/lib/cucumber/rails/version.rb +0 -22
- data/lib/cucumber/rails2.rb +0 -16
- data/lib/cucumber/rails2/action_controller.rb +0 -29
- data/lib/generators/cucumber/feature/feature_base.rb +0 -29
- data/lib/generators/cucumber/install/install_base.rb +0 -149
- data/templates/install/step_definitions/webrat_steps.rb.erb +0 -277
- data/templates/install/support/webrat.rb +0 -8
data/History.txt
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
== 0.5.0.beta1
|
2
|
+
|
3
|
+
* Dropped support for Rails 2 (Aslak Hellesøy)
|
4
|
+
* Dropped support for Webrat (Aslak Hellesøy)
|
5
|
+
* Removed database cleaner strategy overrides (#134 Daniel Morrison, Daniel Duvall)
|
6
|
+
* Upgrade to Capybara 1.0.0.beta1 or newer (#130 Simon Menke, Klaus Hartl, Aslak Hellesøy)
|
7
|
+
* Generated paths.rb cleanup (#133 Tim Pope)
|
8
|
+
* Allow css pseudo-classes in scopers (#122 twalpole)
|
9
|
+
|
1
10
|
== 0.4.1 2011-04-05
|
2
11
|
|
3
12
|
=== Bugfixes
|
data/README.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Cucumber-Rails
|
2
|
+
|
3
|
+
Cucumber-Rails brings Cucumber to Rails3. It contains 2 generators - one
|
4
|
+
for bootstrapping your Rails app for Cucumber, and a second one for generating features.
|
5
|
+
|
6
|
+
Cucumber-Rails also contains Cucumber Step Definitions that wrap Capybara,
|
7
|
+
giving you a head start for writing Cucumber features against your Rails app.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Before you can use the generator, add the gem to your project's Gemfile as follows:
|
12
|
+
|
13
|
+
group :test do
|
14
|
+
gem 'cucumber-rails'
|
15
|
+
# database_cleaner is not required, but highly recommended
|
16
|
+
gem 'database_cleaner'
|
17
|
+
end
|
18
|
+
|
19
|
+
Then install it by running:
|
20
|
+
|
21
|
+
bundle install
|
22
|
+
|
23
|
+
Learn about the various options:
|
24
|
+
|
25
|
+
ruby rails generate cucumber:install --help
|
26
|
+
|
27
|
+
Finally, bootstrap your Rails app, for example:
|
28
|
+
|
29
|
+
rails generate cucumber:install
|
30
|
+
|
31
|
+
## Generating a Cucumber feature
|
32
|
+
|
33
|
+
IMPORTANT: Only do this if you are new to Cucumber. We recommend you write your
|
34
|
+
Cucumber features by hand once you get the hang of it.
|
35
|
+
|
36
|
+
Example:
|
37
|
+
|
38
|
+
ruby rails generate cucumber:feature post title:string body:text published:boolean
|
39
|
+
ruby rails generate scaffold post title:string body:text published:boolean
|
40
|
+
rake db:migrate
|
41
|
+
rake cucumber
|
42
|
+
|
43
|
+
## Running Cucumber
|
44
|
+
|
45
|
+
With Rake:
|
46
|
+
|
47
|
+
rake cucumber
|
48
|
+
|
49
|
+
Without Rake:
|
50
|
+
|
51
|
+
[bundle exec] cucumber
|
52
|
+
|
53
|
+
## Hacking on Cucumber-Rails
|
54
|
+
|
55
|
+
If you have a bugfix or a new feature you want to contribute, please fork on Github and make your own feature branch:
|
56
|
+
|
57
|
+
git clone git@github.com:you/cucumber-rails.git
|
58
|
+
git checkout -b 87-my-awesome-bugfix
|
59
|
+
|
60
|
+
The feature branch should contain a ticket number (if applicable) and a descriptive name that aligns with the ticket name.
|
61
|
+
When you think you're done send a pull request.
|
62
|
+
|
63
|
+
### Setting up your environment
|
64
|
+
|
65
|
+
I strongly recommend rvm and ruby 1.9.2. When you have that, cd into your cucumber-rails repository and:
|
66
|
+
|
67
|
+
gem install bundler
|
68
|
+
bundle install
|
69
|
+
|
70
|
+
### Running all features
|
71
|
+
|
72
|
+
rake cucumber
|
73
|
+
|
74
|
+
One of the features uses MongoDB, which needs to be running in order to make features/mongoid.feature to pass.
|
data/config/cucumber.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
default: --tags ~@broken
|
data/cucumber-rails.gemspec
CHANGED
@@ -1,36 +1,36 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
$LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
|
3
|
-
require 'cucumber/rails/version'
|
4
3
|
|
5
4
|
Gem::Specification.new do |s|
|
6
5
|
s.name = 'cucumber-rails'
|
7
|
-
s.version =
|
6
|
+
s.version = '0.5.0.beta1'
|
8
7
|
s.authors = ["Aslak Hellesøy", "Dennis Blöte", "Rob Holland"]
|
9
8
|
s.description = "Cucumber Generators and Runtime for Rails"
|
10
|
-
s.summary = "
|
9
|
+
s.summary = "#{s.name}-#{s.version}"
|
11
10
|
s.email = 'cukes@googlegroups.com'
|
12
11
|
s.homepage = "http://cukes.info"
|
13
12
|
|
14
|
-
s.add_dependency('cucumber',
|
15
|
-
s.add_dependency('rack-test',
|
16
|
-
s.add_dependency('nokogiri',
|
17
|
-
s.
|
18
|
-
s.add_development_dependency('
|
19
|
-
s.add_development_dependency('
|
20
|
-
s.add_development_dependency('
|
21
|
-
s.add_development_dependency('
|
22
|
-
s.add_development_dependency('
|
23
|
-
s.add_development_dependency('
|
24
|
-
s.add_development_dependency('
|
25
|
-
s.add_development_dependency('
|
26
|
-
s.add_development_dependency('
|
27
|
-
s.add_development_dependency('
|
13
|
+
s.add_dependency('cucumber', '>= 0.10.2')
|
14
|
+
s.add_dependency('rack-test', '>= 0.5.7')
|
15
|
+
s.add_dependency('nokogiri', '>= 1.4.4')
|
16
|
+
s.add_dependency('capybara', '>= 1.0.0.beta1')
|
17
|
+
s.add_development_dependency('bundler', '>= 1.0.12')
|
18
|
+
s.add_development_dependency('aruba', '>= 0.3.6')
|
19
|
+
s.add_development_dependency('rails', '>= 3.0.7')
|
20
|
+
s.add_development_dependency('sqlite3-ruby', '>= 1.3.3')
|
21
|
+
s.add_development_dependency('rspec', '>= 2.6.0.rc6')
|
22
|
+
s.add_development_dependency('rspec-rails', '>= 2.2.0')
|
23
|
+
s.add_development_dependency('factory_girl', '>= 2.0.0.beta2')
|
24
|
+
s.add_development_dependency('database_cleaner', '>= 0.6.7')
|
25
|
+
s.add_development_dependency('mongoid', '>= 2.0.1')
|
26
|
+
s.add_development_dependency('bson_ext', '>= 1.3.0')
|
27
|
+
# s.add_development_dependency('akephalos', '>= 0.2.5')
|
28
28
|
|
29
29
|
s.rubygems_version = ">= 1.6.1"
|
30
30
|
s.files = `git ls-files`.split("\n")
|
31
31
|
s.test_files = `git ls-files -- {spec,features}/*`.split("\n")
|
32
32
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
33
|
-
s.extra_rdoc_files = ["LICENSE", "README.
|
33
|
+
s.extra_rdoc_files = ["LICENSE", "README.md", "History.txt"]
|
34
34
|
s.rdoc_options = ["--charset=UTF-8"]
|
35
35
|
s.require_path = "lib"
|
36
36
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
Feature: Emulate Javascript
|
2
|
+
|
3
|
+
Scenario: Delete a widget
|
4
|
+
Given I have created a new Rails 3 app "widgets" with cucumber-rails support
|
5
|
+
And I successfully run `rails generate scaffold widget name:string`
|
6
|
+
And I write to "features/f.feature" with:
|
7
|
+
"""
|
8
|
+
Feature: Widget inventory
|
9
|
+
Scenario: Delete a widget
|
10
|
+
Given there is a widget named "wrench"
|
11
|
+
When I go to the widgets page
|
12
|
+
And I follow "Destroy"
|
13
|
+
Then I should not see "wrench"
|
14
|
+
"""
|
15
|
+
And I write to "features/step_definitions/s.rb" with:
|
16
|
+
"""
|
17
|
+
Given /^there is a widget named "([^"]*)"$/ do |name|
|
18
|
+
Factory(:widget, :name => name)
|
19
|
+
end
|
20
|
+
"""
|
21
|
+
And I write to "features/support/factories.rb" with:
|
22
|
+
"""
|
23
|
+
Factory.define :widget do |f|
|
24
|
+
f.name 'testwidget'
|
25
|
+
end
|
26
|
+
"""
|
27
|
+
When I run `rake db:migrate cucumber`
|
28
|
+
Then it should pass with:
|
29
|
+
"""
|
30
|
+
1 scenario (1 passed)
|
31
|
+
4 steps (4 passed)
|
32
|
+
"""
|
33
|
+
|
@@ -0,0 +1,74 @@
|
|
1
|
+
Feature: Multiple Databases
|
2
|
+
In order to use Database Cleaner with multiple database repositories
|
3
|
+
As an engineer
|
4
|
+
I want to specify explicit strategies for each
|
5
|
+
|
6
|
+
Background: A Rails 3 app utilizing multiple database repositories exists
|
7
|
+
Given I have created a new Rails 3 app "rails-3-app" with cucumber-rails support
|
8
|
+
And I remove the file "features/step_definitions/web_steps.rb"
|
9
|
+
And I append to "config/database.yml" with:
|
10
|
+
"""
|
11
|
+
|
12
|
+
ursidae:
|
13
|
+
adapter: sqlite3
|
14
|
+
database: db/ursidae.sqlite3
|
15
|
+
"""
|
16
|
+
And I write to "app/models/bear.rb" with:
|
17
|
+
"""
|
18
|
+
class Bear < ActiveRecord::Base
|
19
|
+
establish_connection "ursidae"
|
20
|
+
end
|
21
|
+
"""
|
22
|
+
And a directory named "db/migrate"
|
23
|
+
And I write to "db/migrate/001_create_bears.rb" with:
|
24
|
+
"""
|
25
|
+
class CreateBears < ActiveRecord::Migration
|
26
|
+
def self.up
|
27
|
+
if Rails.env == 'ursidae'
|
28
|
+
create_table :bears do |t|
|
29
|
+
t.string :name, :null => false
|
30
|
+
end
|
31
|
+
add_index :bears, :name, :unique => true
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
"""
|
36
|
+
And I successfully run `bundle exec rake db:migrate`
|
37
|
+
And I successfully run `bundle exec rake db:migrate RAILS_ENV=ursidae`
|
38
|
+
And I write to "features/support/env.rb" with:
|
39
|
+
"""
|
40
|
+
require 'cucumber/rails'
|
41
|
+
DatabaseCleaner.strategy = :transaction
|
42
|
+
DatabaseCleaner[:active_record, {:connection => "ursidae"}].strategy = :truncation
|
43
|
+
"""
|
44
|
+
And I write to "features/create_bear.feature" with:
|
45
|
+
"""
|
46
|
+
Feature: Screws up in transactional test and must use truncation
|
47
|
+
Scenario: I create a bear
|
48
|
+
When I create a bear
|
49
|
+
And something transactional happens
|
50
|
+
"""
|
51
|
+
And I write to "features/step_definitions/create_bear_steps.rb" with:
|
52
|
+
"""
|
53
|
+
When /^I create a bear$/ do
|
54
|
+
Bear.create!(:name => "yogi")
|
55
|
+
end
|
56
|
+
When /^something transactional happens$/ do
|
57
|
+
Bear.transaction { Bear.find_by_name("yogi").lock! }
|
58
|
+
end
|
59
|
+
"""
|
60
|
+
|
61
|
+
Scenario: Default transactional strategy is not attempted on second database
|
62
|
+
When I run `bundle exec rake cucumber FEATURE=features/create_bear.feature`
|
63
|
+
Then it should pass with:
|
64
|
+
"""
|
65
|
+
1 scenario (1 passed)
|
66
|
+
2 steps (2 passed)
|
67
|
+
"""
|
68
|
+
And the output should not contain "cannot rollback - no transaction is active"
|
69
|
+
|
70
|
+
Scenario: Truncation strategy is used on the second database
|
71
|
+
Given I successfully run `bundle exec rails runner 'Bear.create(:name => "boo boo")'`
|
72
|
+
And I successfully run `bundle exec rake cucumber FEATURE=features/create_bear.feature`
|
73
|
+
When I run `bundle exec rails runner 'raise "ahh! bears!" if Bear.count > 0'`
|
74
|
+
Then the exit status should be 0
|
@@ -0,0 +1,24 @@
|
|
1
|
+
Feature: Pseudo-class Selectors
|
2
|
+
|
3
|
+
Scenario: Look within css pseudo-class selectors
|
4
|
+
Given a project without ActiveRecord
|
5
|
+
And a cukes resource
|
6
|
+
And I write to "app/views/cukes/index.html.erb" with:
|
7
|
+
"""
|
8
|
+
<div>foo</div>
|
9
|
+
<div>bar</div>
|
10
|
+
"""
|
11
|
+
And I write to "features/tests.feature" with:
|
12
|
+
"""
|
13
|
+
Feature: Tests
|
14
|
+
Scenario: Tests
|
15
|
+
When I go to the cukes page
|
16
|
+
Then I should see "bar" within "div:nth-child(2)"
|
17
|
+
And I should not see "foo" within "div:nth-child(2)"
|
18
|
+
"""
|
19
|
+
And I run `rake cucumber`
|
20
|
+
Then it should pass with:
|
21
|
+
"""
|
22
|
+
1 scenario (1 passed)
|
23
|
+
3 steps (3 passed)
|
24
|
+
"""
|
@@ -53,6 +53,42 @@ Feature: Select dates
|
|
53
53
|
<% end %>
|
54
54
|
"""
|
55
55
|
When I run `bundle exec rake db:migrate cucumber`
|
56
|
+
Then it should pass with:
|
57
|
+
"""
|
58
|
+
1 scenario (1 passed)
|
59
|
+
6 steps (6 passed)
|
60
|
+
"""
|
61
|
+
|
62
|
+
Scenario: Select date when the order of fields is changed and label is set to the first select
|
63
|
+
Given I successfully run `bundle exec rails g scaffold appointment name:string when:date`
|
64
|
+
And I write to "features/create_appointment.feature" with:
|
65
|
+
"""
|
66
|
+
Feature: Create appointments
|
67
|
+
Scenario: Constitution on May 17
|
68
|
+
Given I am on the new appointment page
|
69
|
+
And I fill in "Norway's constitution" for "Name"
|
70
|
+
And I select "2009-02-20" as the "When" date
|
71
|
+
And I press "Create Appointment"
|
72
|
+
Then I should see "Norway's constitution"
|
73
|
+
And I should see "2009-02-20"
|
74
|
+
"""
|
75
|
+
And I write to "app/views/appointments/_form.html.erb" with:
|
76
|
+
"""
|
77
|
+
<%= form_for(@appointment) do |f| %>
|
78
|
+
<div class="field">
|
79
|
+
<%= f.label :name %><br />
|
80
|
+
<%= f.text_field :name %>
|
81
|
+
</div>
|
82
|
+
<div class="field">
|
83
|
+
<%= f.label :when, :for => "appointment_when_2i" %><br />
|
84
|
+
<%= f.date_select :when, :order=>[:month, :day, :year] %>
|
85
|
+
</div>
|
86
|
+
<div class="actions">
|
87
|
+
<%= f.submit %>
|
88
|
+
</div>
|
89
|
+
<% end %>
|
90
|
+
"""
|
91
|
+
When I run `bundle exec rake db:migrate cucumber`
|
56
92
|
Then it should pass with:
|
57
93
|
"""
|
58
94
|
1 scenario (1 passed)
|
@@ -12,6 +12,7 @@ Given /^I have created a new Rails 3 app "([^"]*)" with cucumber\-rails support$
|
|
12
12
|
gem "capybara", :group => :test
|
13
13
|
gem "rspec-rails", :group => :test
|
14
14
|
gem "database_cleaner", :group => :test
|
15
|
+
gem 'factory_girl', :group => :test
|
15
16
|
|
16
17
|
"""
|
17
18
|
And I successfully run `bundle exec rails generate cucumber:install`
|
data/lib/cucumber/rails.rb
CHANGED
@@ -11,7 +11,7 @@ module Cucumber
|
|
11
11
|
|
12
12
|
def click_with_javascript_emulation
|
13
13
|
if link_with_non_get_http_method?
|
14
|
-
::Capybara::
|
14
|
+
::Capybara::RackTest::Form.new(driver, js_form(element_node.document, self[:href], emulated_method)).submit(self)
|
15
15
|
else
|
16
16
|
click_without_javascript_emulation
|
17
17
|
end
|
@@ -64,20 +64,20 @@ module Cucumber
|
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
|
-
class Capybara::
|
67
|
+
class Capybara::RackTest::Node
|
68
68
|
include ::Cucumber::Rails::Capybara::JavascriptEmulation
|
69
69
|
end
|
70
70
|
|
71
71
|
Before('~@no-js-emulation') do
|
72
72
|
# Enable javascript emulation
|
73
|
-
::Capybara::
|
73
|
+
::Capybara::RackTest::Node.class_eval do
|
74
74
|
alias_method :click, :click_with_javascript_emulation
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
78
78
|
Before('@no-js-emulation') do
|
79
79
|
# Disable javascript emulation
|
80
|
-
::Capybara::
|
80
|
+
::Capybara::RackTest::Node.class_eval do
|
81
81
|
alias_method :click, :click_without_javascript_emulation
|
82
82
|
end
|
83
83
|
end
|
@@ -28,7 +28,7 @@ module Cucumber
|
|
28
28
|
|
29
29
|
# @example "event_starts_at_"
|
30
30
|
def get_base_dom_id_from_label_tag(field)
|
31
|
-
find(:xpath, "//label[contains(., '#{field}')]")['for'].gsub(/(
|
31
|
+
find(:xpath, "//label[contains(., '#{field}')]")['for'].gsub(/(_[1-5]i)$/, '')
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
@@ -1,32 +1,7 @@
|
|
1
|
-
# Default setup for DatabaseCleaner that will work for most projects.
|
2
|
-
# If you need your own setup, roll your own.
|
3
1
|
begin
|
4
2
|
require 'database_cleaner'
|
5
3
|
|
6
4
|
Before do
|
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
|
12
|
-
end
|
13
|
-
|
14
|
-
Before('~@no-txn', '~@selenium', '~@culerity', '~@celerity', '~@javascript') do
|
15
|
-
DatabaseCleaner.strategy = $__cucumber_global_database_cleaner_strategy
|
16
|
-
end
|
17
|
-
|
18
|
-
Before('@no-txn,@selenium,@culerity,@celerity,@javascript') do
|
19
|
-
DatabaseCleaner.strategy = :truncation
|
20
|
-
end
|
21
|
-
|
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")
|
30
5
|
DatabaseCleaner.start
|
31
6
|
end
|
32
7
|
|
@@ -1,11 +1,9 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__), 'named_arg')
|
2
|
-
require File.join(File.dirname(__FILE__), 'feature_base')
|
3
2
|
|
4
3
|
module Cucumber
|
5
4
|
class FeatureGenerator < ::Rails::Generators::NamedBase
|
5
|
+
source_root File.expand_path("../templates", __FILE__)
|
6
6
|
|
7
|
-
include Cucumber::Generators::FeatureBase
|
8
|
-
|
9
7
|
argument :fields, :optional => true, :type => :array, :banner => "[field:type, field:type]"
|
10
8
|
|
11
9
|
attr_reader :named_args
|
@@ -15,23 +13,16 @@ module Cucumber
|
|
15
13
|
end
|
16
14
|
|
17
15
|
def generate
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
16
|
+
empty_directory 'features/step_definitions'
|
17
|
+
template 'feature.erb', "features/manage_#{plural_name}.feature"
|
18
|
+
template 'steps.erb', "features/step_definitions/#{singular_name}_steps.rb"
|
19
|
+
gsub_file 'features/support/paths.rb', /'\/'/mi do |match|
|
20
|
+
"#{match}\n when /the new #{singular_name} page/\n new_#{singular_name}_path\n"
|
21
|
+
end
|
22
22
|
end
|
23
23
|
|
24
24
|
def self.banner
|
25
25
|
"#{$0} cucumber:feature ModelName [field:type, field:type]"
|
26
26
|
end
|
27
|
-
|
28
|
-
def self.gem_root
|
29
|
-
File.expand_path("../../../../../", __FILE__)
|
30
|
-
end
|
31
|
-
|
32
|
-
def self.source_root
|
33
|
-
File.join(gem_root, 'templates', 'feature')
|
34
|
-
end
|
35
|
-
|
36
27
|
end
|
37
28
|
end
|