cucumber-rails 1.4.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +7 -0
  2. data/.github/ISSUE_TEMPLATE.md +52 -0
  3. data/.github/PULL_REQUEST_TEMPLATE.md +42 -0
  4. data/.gitignore +3 -0
  5. data/.rspec +4 -1
  6. data/.rubocop.yml +68 -0
  7. data/.travis.yml +53 -26
  8. data/Appraisals +27 -63
  9. data/{History.md → CHANGELOG.md} +299 -19
  10. data/CONTRIBUTING.md +18 -27
  11. data/Gemfile +2 -4
  12. data/LICENSE +1 -1
  13. data/README.md +73 -29
  14. data/Rakefile +18 -14
  15. data/bin/install_geckodriver.sh +19 -0
  16. data/bin/install_webpacker.sh +9 -0
  17. data/config/cucumber.yml +5 -3
  18. data/cucumber-rails.gemspec +37 -25
  19. data/dev_tasks/cucumber.rake +3 -3
  20. data/dev_tasks/rspec.rake +3 -6
  21. data/dev_tasks/yard/default/layout/html/footer.erb +1 -1
  22. data/dev_tasks/yard/default/layout/html/layout.erb +5 -5
  23. data/dev_tasks/yard/default/layout/html/logo.erb +1 -1
  24. data/dev_tasks/yard/default/layout/html/setup.rb +6 -1
  25. data/dev_tasks/yard.rake +7 -14
  26. data/features/allow_rescue.feature +17 -12
  27. data/features/annotations.feature +20 -0
  28. data/features/capybara_javascript_drivers.feature +42 -32
  29. data/features/choose_javascript_database_strategy.feature +38 -57
  30. data/features/configuration.feature +48 -0
  31. data/features/database_cleaner.feature +20 -20
  32. data/features/disable_automatic_database_cleaning.feature +13 -19
  33. data/features/emulate_javascript.feature +65 -48
  34. data/features/install_cucumber_rails.feature +6 -5
  35. data/features/no_database.feature +8 -15
  36. data/features/raising_errors.feature +10 -4
  37. data/features/rerun_profile.feature +18 -8
  38. data/features/rest_api.feature +13 -13
  39. data/features/step_definitions/cucumber_rails_steps.rb +52 -66
  40. data/features/support/aruba.rb +5 -0
  41. data/features/support/cucumber_rails_helper.rb +85 -0
  42. data/features/support/env.rb +4 -35
  43. data/features/support/hooks.rb +8 -0
  44. data/gemfiles/rails_4_2.gemfile +10 -0
  45. data/gemfiles/rails_5_0.gemfile +10 -0
  46. data/gemfiles/rails_5_1.gemfile +10 -0
  47. data/gemfiles/rails_5_2.gemfile +10 -0
  48. data/gemfiles/rails_6_0.gemfile +9 -0
  49. data/lib/cucumber/rails/action_dispatch.rb +21 -0
  50. data/lib/cucumber/rails/application.rb +17 -8
  51. data/lib/cucumber/rails/capybara/javascript_emulation.rb +47 -39
  52. data/lib/cucumber/rails/capybara/select_dates_and_times.rb +8 -6
  53. data/lib/cucumber/rails/capybara.rb +2 -0
  54. data/lib/cucumber/rails/database.rb +36 -17
  55. data/lib/cucumber/rails/hooks/active_record.rb +14 -12
  56. data/lib/cucumber/rails/hooks/allow_rescue.rb +2 -0
  57. data/lib/cucumber/rails/hooks/database_cleaner.rb +6 -4
  58. data/lib/cucumber/rails/hooks/mail.rb +4 -4
  59. data/lib/cucumber/rails/hooks.rb +2 -0
  60. data/lib/cucumber/rails/rspec.rb +5 -3
  61. data/lib/cucumber/rails/world.rb +26 -9
  62. data/lib/cucumber/rails.rb +21 -18
  63. data/lib/generators/cucumber/{install/USAGE → USAGE} +2 -2
  64. data/lib/generators/cucumber/{install/install_generator.rb → install_generator.rb} +28 -15
  65. data/lib/generators/cucumber/{install/templates → templates}/config/cucumber.yml.erb +4 -3
  66. data/lib/generators/cucumber/{install/templates → templates}/script/cucumber +1 -0
  67. data/lib/generators/cucumber/{install/templates → templates}/support/_rails_each_run.rb.erb +4 -4
  68. data/lib/generators/cucumber/{install/templates → templates}/support/_rails_prefork.rb.erb +0 -0
  69. data/lib/generators/cucumber/{install/templates → templates}/support/capybara.rb +2 -0
  70. data/lib/generators/cucumber/{install/templates → templates}/support/edit_warning.txt +0 -0
  71. data/lib/generators/cucumber/{install/templates → templates}/support/rails.rb.erb +0 -0
  72. data/lib/generators/cucumber/{install/templates → templates}/support/rails_spork.rb.erb +2 -2
  73. data/lib/generators/cucumber/{install/templates → templates}/tasks/cucumber.rake.erb +19 -8
  74. data/spec/cucumber/rails/database_spec.rb +46 -33
  75. data/spec/generators/cucumber/install_generator_spec.rb +55 -0
  76. data/spec/spec_helper.rb +14 -2
  77. metadata +228 -142
  78. data/Gemfile.appraisal +0 -3
  79. data/features/step_definitions/mongo_steps.rb +0 -3
  80. data/features/support/bundler_pre_support.rb +0 -28
  81. data/features/support/fixtures/bundler-1.0.21.gem +0 -0
  82. data/features/support/fixtures/bundler-1.1.rc.gem +0 -0
  83. data/features/support/legacy_web_steps_support.rb +0 -290
  84. data/gemfiles/capybara_1_1.gemfile +0 -17
  85. data/gemfiles/rails_3_0.gemfile +0 -16
  86. data/gemfiles/rails_3_1.gemfile +0 -17
  87. data/gemfiles/rails_3_2.gemfile +0 -17
  88. data/gemfiles/rails_4_0.gemfile +0 -20
  89. data/lib/cucumber/rails/action_controller.rb +0 -12
  90. data/spec/generators/cucumber/install/install_generator_spec.rb +0 -47
@@ -3,69 +3,79 @@ Feature: Capybara Javascript Drivers
3
3
 
4
4
  Background: A simple calendar app
5
5
  Given I have created a new Rails app and installed cucumber-rails
6
- And I successfully run `bundle exec rails g scaffold appointment name:string when:datetime`
7
- And I write to "features/step_definitions/date_time_steps.rb" with:
8
- """
9
- When /^(?:|I )select "([^"]+)" as the "([^"]+)" time$/ do |time, selector|
10
- select_time(time, :from => selector)
11
- end
12
-
13
- When /^(?:|I )select "([^"]+)" as the "([^"]+)" date$/ do |date, selector|
14
- select_date(date, :from => selector)
15
- end
16
-
17
- When /^(?:|I )select "([^"]+)" as the "([^"]+)" date and time$/ do |datetime, selector|
18
- select_datetime(datetime, :from => selector)
19
- end
20
- """
6
+ And I force selenium to run Firefox in headless mode
7
+ When I run `bundle exec rails g scaffold appointment name:string when:datetime`
21
8
 
22
9
  Scenario: Use a particular driver
23
- Given I write to "features/create_appointment.feature" with:
10
+ When I write to "features/create_appointment.feature" with:
24
11
  """
25
12
  @javascript
26
13
  Feature: Create appointments
27
- Scenario: Constitution on May 17
14
+ Scenario: Visit the Constitution on May 17
28
15
  Given I am on the new appointment page
29
16
  And I fill in "Norway's constitution" for "Name"
30
- And I select "2009-02-20 15:10:00 UTC" as the "When" date and time
17
+ And I select "2015-02-20 15:10:00 UTC" as the "When" date and time
31
18
  And I press "Create Appointment"
32
19
  Then I should see "Norway's constitution"
33
- And I should see "2009-02-20 15:10:00 UTC"
20
+ And I should see "2015-02-20 15:10:00 UTC"
21
+ """
22
+ And I write to "features/create_appointment_steps.rb" with:
23
+ """
24
+ Given('I am on the new appointment page') do
25
+ visit new_appointment_path
26
+ end
34
27
 
28
+ When('I fill in {string} for {string}') do |value, field|
29
+ fill_in(field, with: value)
30
+ end
31
+
32
+ When('I press {string}') do |button|
33
+ click_button(button)
34
+ end
35
+
36
+ Then('I should see {string}') do |text|
37
+ expect(page).to have_content(text)
38
+ end
39
+
40
+ When('I select {string} as the {string} date and time') do |datetime, selector|
41
+ select_datetime(datetime, from: selector)
42
+ end
35
43
  """
36
- When I run `bundle exec rake db:migrate`
44
+ And I run `bundle exec rake db:migrate`
37
45
  And I run `bundle exec rake cucumber`
38
- Then it should pass with:
46
+ Then the feature run should pass with:
39
47
  """
40
48
  1 scenario (1 passed)
41
49
  6 steps (6 passed)
42
50
  """
43
51
 
44
52
  Scenario: Mixed DB access
45
- Given I write to "features/create_appointment.feature" with:
53
+ When I write to "features/create_appointment.feature" with:
46
54
  """
47
55
  @javascript
48
56
  Feature: Create appointments
49
- Scenario: Constitution on May 17
57
+ Scenario: Visit the Constitution on May 17
50
58
  Given a random appointment
51
- And I am viewing random appointment
59
+ And I am viewing the appointment
52
60
  Then I should see "Random appointment"
53
-
54
61
  """
55
- And I write to "features/step_definitions/custom_steps.rb" with:
62
+ And I write to "features/step_definitions/create_appointment_steps.rb" with:
56
63
  """
57
- Given /^a random appointment$/ do
58
- @appointment = Appointment.create!(:name => 'Random appointment', :when => DateTime.now)
64
+ Given('a random appointment') do
65
+ @appointment = Appointment.create!(name: 'Random appointment', when: DateTime.now)
59
66
  end
60
67
 
61
- Given /^I am viewing random appointment$/ do
68
+ Given('I am viewing the appointment') do
62
69
  visit appointment_path(@appointment)
63
70
  end
64
- """
65
71
 
66
- When I run `bundle exec rake db:migrate`
72
+ Then('I should see {string}') do |text|
73
+ expect(page).to have_content(text)
74
+ end
75
+ """
76
+ And I run `bundle exec rake db:migrate`
67
77
  And I run `bundle exec rake cucumber`
68
- Then it should pass with:
78
+ Then the feature run should pass with:
69
79
  """
70
80
  1 scenario (1 passed)
71
81
  3 steps (3 passed)
@@ -1,9 +1,9 @@
1
1
  Feature: Choose javascript database strategy
2
2
 
3
- When running a scenario with the @javascript tag, Capybara will fire up a web server
3
+ Whilst running a scenario with the @javascript tag, Capybara will fire up a web server
4
4
  in the same process in a separate thread to your cukes. By default, this means ActiveRecord will give it a
5
5
  separate database connection, which in turn means data you put into your database from
6
- Cucumber step definitions (e.g. using FactoryGirl) won't be visible to the web server
6
+ Cucumber step definitions (e.g. using FactoryBot) won't be visible to the web server
7
7
  until the database transaction is committed.
8
8
 
9
9
  So if you use a transaction strategy for cleaning up your database at the end of a scenario,
@@ -26,9 +26,23 @@ Feature: Choose javascript database strategy
26
26
  Background:
27
27
  Given I have created a new Rails app and installed cucumber-rails
28
28
  And I have a "Widget" ActiveRecord model object
29
+ When I write to "features/step_definitions/widget_steps.rb" with:
30
+ """
31
+ When('I create {int} widgets') do |number|
32
+ number.times { Widget.create! }
33
+ end
34
+
35
+ Then('I should have {int} widgets') do |number|
36
+ expect(Widget.count).to eq(number)
37
+ end
38
+
39
+ Then('the DatabaseCleaner strategy should be {word}') do |strategy_name|
40
+ expect(DatabaseCleaner.cleaners.values.first.strategy.to_s).to match(/#{strategy_name}/i)
41
+ end
42
+ """
29
43
 
30
44
  Scenario: Set the strategy to truncation and run a javascript scenario.
31
- Given I append to "features/env.rb" with:
45
+ When I append to "features/env.rb" with:
32
46
  """
33
47
  DatabaseCleaner.strategy = :transaction
34
48
  Cucumber::Rails::Database.javascript_strategy = :truncation
@@ -37,13 +51,13 @@ Feature: Choose javascript database strategy
37
51
  """
38
52
  Feature:
39
53
  Background:
40
- Given I have created 2 widgets
54
+ When I create 2 widgets
41
55
 
42
56
  @javascript
43
57
  Scenario:
44
- Then the DatabaseCleaner strategy should be truncation
45
58
  When I create 3 widgets
46
- Then I should have 5 widgets
59
+ Then the DatabaseCleaner strategy should be truncation
60
+ And I should have 5 widgets
47
61
 
48
62
  @javascript
49
63
  Scenario:
@@ -54,29 +68,15 @@ Feature: Choose javascript database strategy
54
68
  Then the DatabaseCleaner strategy should be transaction
55
69
  And I should have 2 widgets
56
70
  """
57
- And I write to "features/step_definitions/widget_steps.rb" with:
71
+ And I run the cukes
72
+ Then the feature run should pass with:
58
73
  """
59
- Given /created? (\d) widgets/ do |num|
60
- num.to_i.times { Widget.create! }
61
- end
62
-
63
- Then /should have (\d) widgets/ do |num|
64
- Widget.count.should == num.to_i
65
- end
66
-
67
- Then /^the DatabaseCleaner strategy should be (\w+)$/ do |strategy_name|
68
- DatabaseCleaner.connections.first.strategy.to_s.should =~ /#{strategy_name}/i
69
- end
74
+ 3 scenarios (3 passed)
75
+ 10 steps (10 passed)
70
76
  """
71
- When I run the cukes
72
- Then it should pass with:
73
- """
74
- 3 scenarios (3 passed)
75
- 10 steps (10 passed)
76
- """
77
77
 
78
- Scenario: Set the strategy to deletion and run a javascript scenario.
79
- Given I append to "features/env.rb" with:
78
+ Scenario: Set the strategy to deletion and run a javascript scenario.
79
+ When I append to "features/env.rb" with:
80
80
  """
81
81
  Cucumber::Rails::Database.javascript_strategy = :deletion
82
82
  """
@@ -85,7 +85,7 @@ Feature: Choose javascript database strategy
85
85
  @javascript
86
86
  Feature:
87
87
  Background:
88
- Given I have created 2 widgets
88
+ When I create 2 widgets
89
89
 
90
90
  Scenario:
91
91
  When I create 3 widgets
@@ -94,26 +94,17 @@ Feature: Choose javascript database strategy
94
94
  Scenario:
95
95
  Then I should have 2 widgets
96
96
  """
97
- And I write to "features/step_definitions/widget_steps.rb" with:
97
+ And I run the cukes
98
+ Then the feature run should pass with:
98
99
  """
99
- Given /created? (\d) widgets/ do |num|
100
- num.to_i.times { Widget.create! }
101
- end
102
-
103
- Then /should have (\d) widgets/ do |num|
104
- Widget.count.should == num.to_i
105
- end
100
+ 2 scenarios (2 passed)
101
+ 5 steps (5 passed)
106
102
  """
107
- When I run the cukes
108
- Then it should pass with:
109
- """
110
- 2 scenarios (2 passed)
111
- 5 steps (5 passed)
112
- """
103
+
113
104
  Scenario: Set the strategy to truncation with an except option and run a javascript scenario.
114
- Given I append to "features/env.rb" with:
105
+ When I append to "features/env.rb" with:
115
106
  """
116
- Cucumber::Rails::Database.javascript_strategy = :truncation, {:except=>%w[widgets]}
107
+ Cucumber::Rails::Database.javascript_strategy = :truncation, { except: %w[widgets] }
117
108
  """
118
109
  And I write to "features/widgets.feature" with:
119
110
  """
@@ -126,19 +117,9 @@ Feature: Choose javascript database strategy
126
117
  Scenario:
127
118
  Then I should have 3 widgets
128
119
  """
129
- And I write to "features/step_definitions/widget_steps.rb" with:
120
+ And I run the cukes
121
+ Then the feature run should pass with:
130
122
  """
131
- Given /created? (\d) widgets/ do |num|
132
- num.to_i.times { Widget.create! }
133
- end
134
-
135
- Then /should have (\d) widgets/ do |num|
136
- Widget.count.should == num.to_i
137
- end
123
+ 2 scenarios (2 passed)
124
+ 3 steps (3 passed)
138
125
  """
139
- When I run the cukes
140
- Then it should pass with:
141
- """
142
- 2 scenarios (2 passed)
143
- 3 steps (3 passed)
144
- """
@@ -0,0 +1,48 @@
1
+ Feature: Cucumber Rails Configuration
2
+
3
+ In order to configure how Cucumber-Rails runs
4
+ As a developer
5
+ I should be able to alter the settings of my project
6
+
7
+ Scenario: Default configuration
8
+ Given I have created a new Rails app with no database and installed cucumber-rails
9
+ When I write to "features/config.feature" with:
10
+ """
11
+ Feature: Rack Test Methods
12
+ Scenario: Default Methods are added to the World
13
+ Then Rack Test should be mixed into the Cucumber World
14
+ """
15
+ When I write to "features/step_definitions/config_steps.rb" with:
16
+ """
17
+ Then('Rack Test should be mixed into the Cucumber World') do
18
+ expect(self.class.ancestors).to include(Rack::Test::Methods)
19
+ end
20
+ """
21
+ And I run `bundle exec rake cucumber`
22
+ Then the feature run should pass with:
23
+ """
24
+ 1 scenario (1 passed)
25
+ 1 step (1 passed)
26
+ """
27
+
28
+ Scenario: Altered configuration
29
+ Given I have created a new Rails app with no database and installed cucumber-rails
30
+ And I set the environment variable "CR_REMOVE_RACK_TEST_HELPERS" to "true"
31
+ When I write to "features/config.feature" with:
32
+ """
33
+ Feature: Rack Test Methods
34
+ Scenario: Rack Test Methods can be removed from the world
35
+ Then Rack Test should not be mixed into the Cucumber World
36
+ """
37
+ When I write to "features/step_definitions/config_steps.rb" with:
38
+ """
39
+ Then('Rack Test should not be mixed into the Cucumber World') do
40
+ expect(self.class.ancestors).not_to include(Rack::Test::Methods)
41
+ end
42
+ """
43
+ And I run `bundle exec rake cucumber`
44
+ Then the feature run should pass with:
45
+ """
46
+ 1 scenario (1 passed)
47
+ 1 step (1 passed)
48
+ """
@@ -1,44 +1,44 @@
1
- Feature: DatabaseCleaner
1
+ Feature: Database Cleaner
2
2
 
3
3
  Scenario: Create records in background
4
4
  Given I have created a new Rails app and installed cucumber-rails
5
- And I write to "features/widgets.feature" with:
5
+ When I write to "features/widgets.feature" with:
6
6
  """
7
7
  Feature: Create widgets
8
- Background: some widdgets
8
+ Background: 2 initial widgets
9
9
  Given I have 2 widgets
10
-
11
- Scenario: Add 3
10
+
11
+ Scenario: Add 3 widgets
12
12
  When I create 3 more widgets
13
13
  Then I should have 5 widgets
14
14
 
15
- Scenario: Add 7
15
+ Scenario: Add 7 widgets
16
16
  When I create 7 more widgets
17
17
  Then I should have 9 widgets
18
18
  """
19
- And I successfully run `rails generate model widget name:string`
19
+ And I run `rails generate model widget name:string`
20
20
  And I write to "features/step_definitions/widget_steps.rb" with:
21
21
  """
22
- Given /^I have (\d+) widgets$/ do |n|
23
- n.to_i.times do |i|
24
- Widget.create! :name => "Widget #{Widget.count + i}"
22
+ Given('I have {int} widgets') do |number|
23
+ number.times do |i|
24
+ Widget.create! name: "Widget #{Widget.count + i}"
25
25
  end
26
26
  end
27
27
 
28
- When /^I create (\d+) more widgets$/ do |n|
29
- n.to_i.times do |i|
30
- Widget.create! :name => "Widget #{Widget.count + i}"
28
+ When('I create {int} more widgets') do |number|
29
+ number.times do |i|
30
+ Widget.create! name: "Widget #{Widget.count + i}"
31
31
  end
32
32
  end
33
33
 
34
- Then /^I should have (\d+) widgets$/ do |n|
35
- Widget.count.should == n.to_i
34
+ Then('I should have {int} widgets') do |number|
35
+ expect(Widget.count).to eq(number)
36
36
  end
37
37
  """
38
38
  And I run `bundle exec rake db:migrate`
39
39
  And I run `bundle exec rake cucumber`
40
- Then it should pass with:
41
- """
42
- 2 scenarios (2 passed)
43
- 6 steps (6 passed)
44
- """
40
+ Then the feature run should pass with:
41
+ """
42
+ 2 scenarios (2 passed)
43
+ 6 steps (6 passed)
44
+ """
@@ -12,7 +12,7 @@ Feature: Disable automatic database cleaning
12
12
 
13
13
  Scenario: Disabling automatic cleaning
14
14
  Given I have created a new Rails app and installed cucumber-rails
15
- And I append to "features/env.rb" with:
15
+ When I append to "features/env.rb" with:
16
16
  """
17
17
  Cucumber::Rails::Database.autorun_database_cleaner = false
18
18
  """
@@ -27,29 +27,23 @@ Feature: Disable automatic database cleaning
27
27
  When I create 5 widgets
28
28
  Then I should have 8 widgets
29
29
  """
30
- And I successfully run `rails generate model widget name:string`
30
+ And I run `rails generate model widget name:string`
31
31
  And I write to "features/step_definitions/widget_steps.rb" with:
32
32
  """
33
- Given /^I have (\d+) widgets$/ do |n|
34
- n.to_i.times do |i|
35
- Widget.create! :name => "Widget #{Widget.count + i}"
33
+ When('I create {int} widgets') do |number|
34
+ number.times do |i|
35
+ Widget.create! name: "Widget #{Widget.count + i}"
36
36
  end
37
37
  end
38
38
 
39
- When /^I create (\d+) widgets$/ do |n|
40
- n.to_i.times do |i|
41
- Widget.create! :name => "Widget #{Widget.count + i}"
42
- end
43
- end
44
-
45
- Then /^I should have (\d+) widgets$/ do |n|
46
- Widget.count.should == n.to_i
39
+ Then('I should have {int} widgets') do |number|
40
+ expect(Widget.count).to eq(number)
47
41
  end
48
- """
42
+ """
49
43
  And I run `bundle exec rake db:migrate`
50
44
  And I run `bundle exec rake cucumber`
51
- Then it should pass with:
52
- """
53
- 2 scenarios (2 passed)
54
- 4 steps (4 passed)
55
- """
45
+ Then the feature run should pass with:
46
+ """
47
+ 2 scenarios (2 passed)
48
+ 4 steps (4 passed)
49
+ """
@@ -1,44 +1,53 @@
1
1
  Feature: Emulate Javascript
2
2
 
3
- Scenario: See a widget
3
+ Background:
4
4
  Given I have created a new Rails app and installed cucumber-rails
5
- And I successfully run `rails generate scaffold widget name:string`
6
- And I write to "features/f.feature" with:
5
+ And I force selenium to run Firefox in headless mode
6
+ When I run `rails generate scaffold widget name:string`
7
+ And I write to "features/step_definitions/widget_steps.rb" with:
8
+ """
9
+ Given('there is a widget named {string}') do |name|
10
+ FactoryBot.create(:widget, name: name)
11
+ end
12
+
13
+ When('I am on the widgets page') do
14
+ visit widgets_path
15
+ end
16
+
17
+ Then('I should see {string}') do |text|
18
+ expect(page).to have_content(text)
19
+ end
20
+ """
21
+ And I write to "features/support/factories/widget.rb" with:
22
+ """
23
+ FactoryBot.define do
24
+ factory :widget do
25
+ name { 'testwidget' }
26
+ end
27
+ end
28
+ """
29
+
30
+ Scenario: See a widget
31
+ When I write to "features/widgets.feature" with:
7
32
  """
8
33
  @javascript
9
34
  Feature: Widget inventory
10
35
  Scenario: Delete a widget
11
36
  Given there is a widget named "wrench"
12
- When I go to the widgets page
37
+ And I am on the widgets page
13
38
  Then I should see "wrench"
14
39
  """
15
- And I write to "features/step_definitions/s.rb" with:
16
- """
17
- Given /^there is a widget named "([^"]*)"$/ do |name|
18
- FactoryGirl.create(:widget, :name => name)
19
- end
20
- """
21
- And I write to "features/support/factories.rb" with:
40
+ And I run `bundle exec rake db:migrate`
41
+ And I run `bundle exec rake cucumber`
42
+ Then the feature run should pass with:
22
43
  """
23
- FactoryGirl.define do
24
- factory :widget do
25
- name 'testwidget'
26
- end
27
- end
44
+ 1 scenario (1 passed)
45
+ 3 steps (3 passed)
28
46
  """
29
- When I run `bundle exec rake db:migrate`
30
- And I run `bundle exec rake cucumber`
31
- Then it should pass with:
32
- """
33
- 1 scenario (1 passed)
34
- 3 steps (3 passed)
35
- """
36
47
 
37
48
  Scenario: Pass on the CSRF token
38
- Given I have created a new Rails app and installed cucumber-rails
39
- And I successfully run `rails generate scaffold widget name:string`
40
- And I successfully run `sed -i -e 's/forgery_protection *= false/forgery_protection = true/' config/environments/test.rb`
41
- And I successfully run `rails generate controller session establish`
49
+ When I run `sed -i -e 's/forgery_protection *= false/forgery_protection = true/' config/environments/test.rb`
50
+ And I run `rails generate controller session establish`
42
51
  And I write to "app/controllers/session_controller.rb" with:
43
52
  """
44
53
  class SessionController < ApplicationController
@@ -51,42 +60,50 @@ Feature: Emulate Javascript
51
60
  """
52
61
  class ApplicationController < ActionController::Base
53
62
  protect_from_forgery
54
- before_filter :except => :establish do
55
- render :text => "denied", :status => :forbidden and return false unless session[:verified]
63
+
64
+ before_action except: :establish do
65
+ render text: 'denied', status: :forbidden and return false unless session[:verified]
56
66
  end
57
67
  end
58
68
  """
59
- And I write to "features/f.feature" with:
69
+ And I write to "features/widgets.feature" with:
60
70
  """
61
71
  Feature: Widget inventory
62
72
  Scenario: Delete a widget
63
73
  Given there is a widget named "wrench"
64
- When I go to the session establish page
65
- And I go to the widgets page
74
+ And I am on the session establish page
75
+ And I am on the widgets page
66
76
  Then I should see "wrench"
67
77
  When I follow "Destroy"
68
78
  Then I should not see "denied"
69
79
  And I should be on the widgets page
70
80
  And I should not see "wrench"
71
81
  """
72
- And I write to "features/step_definitions/s.rb" with:
82
+ And I append to "features/step_definitions/widget_steps.rb" with:
83
+ # TODO: Remove the newline below (Required) once bug is fixed: https://github.com/cucumber/aruba/issues/662
73
84
  """
74
- Given /^there is a widget named "([^"]*)"$/ do |name|
75
- FactoryGirl.create(:widget, :name => name)
85
+
86
+ Given('I am on the session establish page') do
87
+ visit session_establish_path
76
88
  end
77
- """
78
- And I write to "features/support/factories.rb" with:
79
- """
80
- FactoryGirl.define do
81
- factory :widget do
82
- name 'testwidget'
83
- end
89
+
90
+ When('I follow {string}') do |link|
91
+ click_link(link)
92
+ end
93
+
94
+ Then('I should not see {string}') do |text|
95
+ expect(page).not_to have_content(text)
96
+ end
97
+
98
+ Then('I should be on the widgets page') do
99
+ current_path = URI.parse(current_url).path
100
+ expect(current_path).to eq(widgets_path)
84
101
  end
85
102
  """
86
- When I run `bundle exec rake db:migrate`
103
+ And I run `bundle exec rake db:migrate`
87
104
  And I run `bundle exec rake cucumber`
88
- Then it should pass with:
89
- """
90
- 1 scenario (1 passed)
91
- 8 steps (8 passed)
92
- """
105
+ Then the feature run should pass with:
106
+ """
107
+ 1 scenario (1 passed)
108
+ 8 steps (8 passed)
109
+ """
@@ -1,7 +1,7 @@
1
- Feature: Rails
2
- In order to take over the world
3
- Cucumber-Rails should work on major versions
4
- of Rails 3 or 4 and Ruby, with Capybara, Spork and DatabaseCleaner
1
+ Feature: Install Cucumber Rails
2
+
3
+ Cucumber-Rails should work on supported versions
4
+ of Ruby on Rails, with Capybara and DatabaseCleaner
5
5
 
6
6
  Scenario: Install Cucumber-Rails
7
7
  Given I have created a new Rails app and installed cucumber-rails
@@ -9,5 +9,6 @@ Feature: Rails
9
9
  | config/cucumber.yml |
10
10
  | script/cucumber |
11
11
  | features/support/env.rb |
12
+ | features/step_definitions/.gitkeep |
12
13
  | lib/tasks/cucumber.rake |
13
- And the file "features/support/env.rb" should contain "require 'cucumber/rails'"
14
+ And the file "features/support/env.rb" should contain "require 'cucumber/rails'"
@@ -1,11 +1,11 @@
1
1
  Feature: No Database
2
+
2
3
  Allow Cucumber to work with a Rails app without a database
3
4
 
4
- @fails-on-travis
5
5
  Scenario: No ActiveRecord and DatabaseCleaner
6
6
  Given I have created a new Rails app with no database and installed cucumber-rails
7
7
  # Turn off ActiveRecord
8
- And I write to "config/application.rb" with:
8
+ When I write to "config/application.rb" with:
9
9
  """
10
10
  require File.expand_path('../boot', __FILE__)
11
11
 
@@ -17,7 +17,7 @@ Feature: No Database
17
17
 
18
18
  module TestApp
19
19
  class Application < Rails::Application
20
- config.encoding = "utf-8"
20
+ config.encoding = 'utf-8'
21
21
  config.filter_parameters += [:password]
22
22
  end
23
23
  end
@@ -26,20 +26,13 @@ Feature: No Database
26
26
  """
27
27
  require 'cucumber/rails'
28
28
  """
29
- # Remove DatabaseCleaner and SQLite
30
- And I write to "Gemfile" with:
31
- """
32
- source 'http://rubygems.org'
33
- gem 'rails'
34
- gem "cucumber-rails", :group => :test, :path => "../../.."
35
- gem "capybara", :group => :test
36
- gem "rspec-rails", :group => :test
37
- """
29
+ And I remove the 'database_cleaner' gem from the Gemfile
30
+ And I remove the 'sqlite' gem from the Gemfile
38
31
  And I write to "app/controllers/posts_controller.rb" with:
39
32
  """
40
33
  class PostsController < ApplicationController
41
34
  def index
42
- raise "There is an error in index"
35
+ raise 'There is an error in index'
43
36
  end
44
37
  end
45
38
  """
@@ -53,11 +46,11 @@ Feature: No Database
53
46
  """
54
47
  Feature: posts
55
48
  Scenario: See them
56
- When I do it
49
+ When I view the posts
57
50
  """
58
51
  And I write to "features/step_definitions/posts_steps.rb" with:
59
52
  """
60
- When /^I do it$/ do
53
+ When('I view the posts') do
61
54
  visit '/posts'
62
55
  end
63
56
  """