cucumber-rails 2.0.0 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +135 -18
  3. data/CONTRIBUTING.md +14 -2
  4. data/LICENSE +1 -1
  5. data/README.md +5 -24
  6. data/lib/cucumber/rails.rb +11 -13
  7. data/lib/cucumber/rails/action_dispatch.rb +21 -0
  8. data/lib/cucumber/rails/application.rb +11 -8
  9. data/lib/cucumber/rails/capybara/javascript_emulation.rb +27 -16
  10. data/lib/cucumber/rails/database.rb +7 -57
  11. data/lib/cucumber/rails/database/deletion_strategy.rb +13 -0
  12. data/lib/cucumber/rails/database/shared_connection_strategy.rb +27 -0
  13. data/lib/cucumber/rails/database/strategy.rb +35 -0
  14. data/lib/cucumber/rails/database/truncation_strategy.rb +13 -0
  15. data/lib/cucumber/rails/hooks/database_cleaner.rb +9 -3
  16. data/lib/cucumber/rails/hooks/mail.rb +1 -1
  17. data/lib/cucumber/rails/world.rb +2 -2
  18. data/lib/generators/cucumber/install_generator.rb +10 -13
  19. data/lib/generators/cucumber/templates/config/cucumber.yml.erb +3 -3
  20. data/lib/generators/cucumber/templates/tasks/cucumber.rake.erb +5 -0
  21. metadata +92 -99
  22. data/.github/ISSUE_TEMPLATE.md +0 -52
  23. data/.github/PULL_REQUEST_TEMPLATE.md +0 -42
  24. data/.gitignore +0 -14
  25. data/.rspec +0 -4
  26. data/.rubocop.yml +0 -33
  27. data/.rubocop_todo.yml +0 -59
  28. data/.travis.yml +0 -60
  29. data/Appraisals +0 -35
  30. data/Gemfile +0 -5
  31. data/Rakefile +0 -53
  32. data/bin/install_geckodriver.sh +0 -19
  33. data/bin/install_webpacker.sh +0 -9
  34. data/config/.gitignore +0 -1
  35. data/config/cucumber.yml +0 -17
  36. data/cucumber-rails.gemspec +0 -44
  37. data/dev_tasks/cucumber.rake +0 -5
  38. data/dev_tasks/rspec.rake +0 -5
  39. data/dev_tasks/yard.rake +0 -36
  40. data/dev_tasks/yard/default/layout/html/bubble_32x32.png +0 -0
  41. data/dev_tasks/yard/default/layout/html/footer.erb +0 -5
  42. data/dev_tasks/yard/default/layout/html/index.erb +0 -1
  43. data/dev_tasks/yard/default/layout/html/layout.erb +0 -25
  44. data/dev_tasks/yard/default/layout/html/logo.erb +0 -1
  45. data/dev_tasks/yard/default/layout/html/setup.rb +0 -9
  46. data/features/allow_rescue.feature +0 -65
  47. data/features/annotations.feature +0 -20
  48. data/features/capybara_javascript_drivers.feature +0 -82
  49. data/features/choose_javascript_database_strategy.feature +0 -125
  50. data/features/configuration.feature +0 -48
  51. data/features/database_cleaner.feature +0 -44
  52. data/features/disable_automatic_database_cleaning.feature +0 -49
  53. data/features/emulate_javascript.feature +0 -109
  54. data/features/install_cucumber_rails.feature +0 -14
  55. data/features/no_database.feature +0 -61
  56. data/features/raising_errors.feature +0 -22
  57. data/features/rerun_profile.feature +0 -47
  58. data/features/rest_api.feature +0 -47
  59. data/features/step_definitions/cucumber_rails_steps.rb +0 -69
  60. data/features/support/aruba.rb +0 -5
  61. data/features/support/cucumber_rails_helper.rb +0 -76
  62. data/features/support/env.rb +0 -6
  63. data/features/support/hooks.rb +0 -8
  64. data/gemfiles/rails_4_2.gemfile +0 -10
  65. data/gemfiles/rails_5_0.gemfile +0 -10
  66. data/gemfiles/rails_5_1.gemfile +0 -10
  67. data/gemfiles/rails_5_2.gemfile +0 -10
  68. data/gemfiles/rails_6_0.gemfile +0 -9
  69. data/lib/cucumber/rails/action_controller.rb +0 -17
  70. data/lib/generators/cucumber/templates/support/rails_spork.rb.erb +0 -13
  71. data/spec/cucumber/rails/database_spec.rb +0 -61
  72. data/spec/generators/cucumber/install_generator_spec.rb +0 -55
  73. data/spec/spec_helper.rb +0 -16
@@ -1,44 +0,0 @@
1
- Feature: Database Cleaner
2
-
3
- Scenario: Create records in background
4
- Given I have created a new Rails app and installed cucumber-rails
5
- When I write to "features/widgets.feature" with:
6
- """
7
- Feature: Create widgets
8
- Background: 2 initial widgets
9
- Given I have 2 widgets
10
-
11
- Scenario: Add 3 widgets
12
- When I create 3 more widgets
13
- Then I should have 5 widgets
14
-
15
- Scenario: Add 7 widgets
16
- When I create 7 more widgets
17
- Then I should have 9 widgets
18
- """
19
- And I run `rails generate model widget name:string`
20
- And I write to "features/step_definitions/widget_steps.rb" with:
21
- """
22
- Given('I have {int} widgets') do |number|
23
- number.times do |i|
24
- Widget.create! name: "Widget #{Widget.count + i}"
25
- end
26
- end
27
-
28
- When('I create {int} more widgets') do |number|
29
- number.times do |i|
30
- Widget.create! name: "Widget #{Widget.count + i}"
31
- end
32
- end
33
-
34
- Then('I should have {int} widgets') do |number|
35
- expect(Widget.count).to eq(number)
36
- end
37
- """
38
- And I run `bundle exec rake db:migrate`
39
- And I run `bundle exec rake cucumber`
40
- Then the feature run should pass with:
41
- """
42
- 2 scenarios (2 passed)
43
- 6 steps (6 passed)
44
- """
@@ -1,49 +0,0 @@
1
- Feature: Disable automatic database cleaning
2
-
3
- By default, a set of Before/After hooks are installed to
4
- invoke database_cleaner on every scenario except those tagged
5
- "@no-database-cleaner". Sometimes when a user is switching between
6
- cleaning strategies, this can initiate an undesired database
7
- transaction.
8
-
9
- To avoid the need for users making frequent strategy switches to apply
10
- this tag, a configuration option is provided so that the user can
11
- control the invocation of database_cleaner explicitly.
12
-
13
- Scenario: Disabling automatic cleaning
14
- Given I have created a new Rails app and installed cucumber-rails
15
- When I append to "features/env.rb" with:
16
- """
17
- Cucumber::Rails::Database.autorun_database_cleaner = false
18
- """
19
- And I write to "features/widgets.feature" with:
20
- """
21
- Feature: Create widgets
22
- Scenario: Create 3 widgets
23
- When I create 3 widgets
24
- Then I should have 3 widgets
25
-
26
- Scenario: Create 5 widgets
27
- When I create 5 widgets
28
- Then I should have 8 widgets
29
- """
30
- And I run `rails generate model widget name:string`
31
- And I write to "features/step_definitions/widget_steps.rb" with:
32
- """
33
- When('I create {int} widgets') do |number|
34
- number.times do |i|
35
- Widget.create! name: "Widget #{Widget.count + i}"
36
- end
37
- end
38
-
39
- Then('I should have {int} widgets') do |number|
40
- expect(Widget.count).to eq(number)
41
- end
42
- """
43
- And I run `bundle exec rake db:migrate`
44
- And I run `bundle exec rake cucumber`
45
- Then the feature run should pass with:
46
- """
47
- 2 scenarios (2 passed)
48
- 4 steps (4 passed)
49
- """
@@ -1,109 +0,0 @@
1
- Feature: Emulate Javascript
2
-
3
- Background:
4
- Given I have created a new Rails app and installed cucumber-rails
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:
32
- """
33
- @javascript
34
- Feature: Widget inventory
35
- Scenario: Delete a widget
36
- Given there is a widget named "wrench"
37
- And I am on the widgets page
38
- Then I should see "wrench"
39
- """
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:
43
- """
44
- 1 scenario (1 passed)
45
- 3 steps (3 passed)
46
- """
47
-
48
- Scenario: Pass on the CSRF token
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`
51
- And I write to "app/controllers/session_controller.rb" with:
52
- """
53
- class SessionController < ApplicationController
54
- def establish
55
- session[:verified] = true
56
- end
57
- end
58
- """
59
- And I write to "app/controllers/application_controller.rb" with:
60
- """
61
- class ApplicationController < ActionController::Base
62
- protect_from_forgery
63
-
64
- before_action except: :establish do
65
- render text: 'denied', status: :forbidden and return false unless session[:verified]
66
- end
67
- end
68
- """
69
- And I write to "features/widgets.feature" with:
70
- """
71
- Feature: Widget inventory
72
- Scenario: Delete a widget
73
- Given there is a widget named "wrench"
74
- And I am on the session establish page
75
- And I am on the widgets page
76
- Then I should see "wrench"
77
- When I follow "Destroy"
78
- Then I should not see "denied"
79
- And I should be on the widgets page
80
- And I should not see "wrench"
81
- """
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
84
- """
85
-
86
- Given('I am on the session establish page') do
87
- visit session_establish_path
88
- 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)
101
- end
102
- """
103
- And I run `bundle exec rake db:migrate`
104
- And I run `bundle exec rake cucumber`
105
- Then the feature run should pass with:
106
- """
107
- 1 scenario (1 passed)
108
- 8 steps (8 passed)
109
- """
@@ -1,14 +0,0 @@
1
- Feature: Install Cucumber Rails
2
-
3
- Cucumber-Rails should work on supported versions
4
- of Ruby on Rails, with Capybara and DatabaseCleaner
5
-
6
- Scenario: Install Cucumber-Rails
7
- Given I have created a new Rails app and installed cucumber-rails
8
- Then the following files should exist:
9
- | config/cucumber.yml |
10
- | script/cucumber |
11
- | features/support/env.rb |
12
- | features/step_definitions/.gitkeep |
13
- | lib/tasks/cucumber.rake |
14
- And the file "features/support/env.rb" should contain "require 'cucumber/rails'"
@@ -1,61 +0,0 @@
1
- Feature: No Database
2
-
3
- Allow Cucumber to work with a Rails app without a database
4
-
5
- Scenario: No ActiveRecord and DatabaseCleaner
6
- Given I have created a new Rails app with no database and installed cucumber-rails
7
- # Turn off ActiveRecord
8
- When I write to "config/application.rb" with:
9
- """
10
- require File.expand_path('../boot', __FILE__)
11
-
12
- require 'action_controller/railtie'
13
- require 'action_mailer/railtie'
14
- require 'rails/test_unit/railtie'
15
-
16
- Bundler.require(:default, Rails.env) if defined?(Bundler)
17
-
18
- module TestApp
19
- class Application < Rails::Application
20
- config.encoding = 'utf-8'
21
- config.filter_parameters += [:password]
22
- end
23
- end
24
- """
25
- And I overwrite "features/support/env.rb" with:
26
- """
27
- require 'cucumber/rails'
28
- """
29
- And I remove the 'database_cleaner' gem from the Gemfile
30
- And I remove the 'sqlite' gem from the Gemfile
31
- And I write to "app/controllers/posts_controller.rb" with:
32
- """
33
- class PostsController < ApplicationController
34
- def index
35
- raise 'There is an error in index'
36
- end
37
- end
38
- """
39
- And I write to "config/routes.rb" with:
40
- """
41
- TestApp::Application.routes.draw do
42
- resources :posts
43
- end
44
- """
45
- And I write to "features/posts.feature" with:
46
- """
47
- Feature: posts
48
- Scenario: See them
49
- When I view the posts
50
- """
51
- And I write to "features/step_definitions/posts_steps.rb" with:
52
- """
53
- When('I view the posts') do
54
- visit '/posts'
55
- end
56
- """
57
- And I run `bundle exec rake cucumber`
58
- Then it should fail with:
59
- """
60
- There is an error in index
61
- """
@@ -1,22 +0,0 @@
1
- Feature: Raise Errors
2
-
3
- Scenario: Raise error for undefined route
4
- Given I have created a new Rails app with no database and installed cucumber-rails
5
- When I write to "features/home.feature" with:
6
- """
7
- Feature: Tests
8
- Scenario: Tests
9
- When I go to the home page
10
- """
11
- And I write to "features/home_steps.rb" with:
12
- """
13
- When('I go to the home page') do
14
- visit('/')
15
- end
16
- """
17
- And I run `bundle exec cucumber`
18
- Then it should fail with:
19
- """
20
- 1 scenario (1 failed)
21
- 1 step (1 failed)
22
- """
@@ -1,47 +0,0 @@
1
- Feature: Rerun profile
2
-
3
- In order to concentrate on failing features
4
- As a Rails developer working with Cucumber
5
- I want to rerun only failing features
6
-
7
- Scenario: Rerun
8
- Given I have created a new Rails app and installed cucumber-rails
9
- And a file named "rerun.txt" with:
10
- """
11
- features/rerun_test.feature:2
12
- features/rerun_test.feature:5
13
- """
14
- And a file named "features/rerun_test.feature" with:
15
- """
16
- Feature: Rerun test
17
- Scenario: failing before
18
- Given fixed now
19
-
20
- Scenario: still failing
21
- Given broken
22
-
23
- Scenario: always passing
24
- Given passing
25
- """
26
- And a file named "features/step_definitions/rerun_steps.rb" with:
27
- """
28
- Given('fixed now') do
29
- puts 'All fixed now'
30
- end
31
-
32
- Given('broken') do
33
- raise "I'm broken"
34
- end
35
-
36
- Given('passing') do
37
- puts "I've always been passing"
38
- end
39
- """
40
- When I run `bundle exec cucumber -p rerun`
41
- Then it should fail with:
42
- """
43
- 2 scenarios (1 failed, 1 passed)
44
- 2 steps (1 failed, 1 passed)
45
- """
46
- And the file "rerun.txt" should not contain "features/rerun_test.feature:2"
47
- And the file "rerun.txt" should contain "features/rerun_test.feature:5"
@@ -1,47 +0,0 @@
1
- Feature: REST API
2
-
3
- Scenario: Compare JSON
4
- Given I have created a new Rails app and installed cucumber-rails
5
- When I write to "app/controllers/posts_controller.rb" with:
6
- """
7
- class PostsController < ApplicationController
8
- def index
9
- render json: {'hello' => 'world'}.to_json
10
- end
11
- end
12
- """
13
- And I write to "config/routes.rb" with:
14
- """
15
- TestApp::Application.routes.draw do
16
- resources :posts
17
- end
18
- """
19
- And I write to "features/posts.feature" with:
20
- """
21
- Feature: posts
22
- Scenario: See them
23
- When the client requests GET /posts
24
- Then the response should be JSON:
25
- \"\"\"
26
- {
27
- "hello": "world"
28
- }
29
- \"\"\"
30
- """
31
- And I write to "features/step_definitions/post_steps.rb" with:
32
- """
33
- When('the client requests GET /{word}') do |path|
34
- get(path)
35
- end
36
-
37
- Then('the response should be JSON:') do |json|
38
- expect(JSON.parse(last_response.body)).to eq(JSON.parse(json))
39
- end
40
- """
41
- And I run `bundle exec rake db:migrate`
42
- And I run `bundle exec rake cucumber`
43
- Then the feature run should pass with:
44
- """
45
- 1 scenario (1 passed)
46
- 2 steps (2 passed)
47
- """
@@ -1,69 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Given('I have created a new Rails app and installed cucumber-rails, accidentally outside of the test group in my Gemfile') do
4
- rails_new
5
- install_cucumber_rails :not_in_test_group
6
- end
7
-
8
- Given('I have created a new Rails app and installed cucumber-rails') do
9
- rails_new
10
- install_cucumber_rails
11
- end
12
-
13
- Given('I have created a new Rails app with no database and installed cucumber-rails') do
14
- rails_new args: '--skip-active-record'
15
- install_cucumber_rails :no_database_cleaner, :no_factory_bot
16
- overwrite_file('features/support/env.rb', "require 'cucumber/rails'\n")
17
- end
18
-
19
- Given('I have a {string} ActiveRecord model object') do |name|
20
- run_command_and_stop("bundle exec rails g model #{name}")
21
- run_command_and_stop('bundle exec rake db:migrate RAILS_ENV=test')
22
- end
23
-
24
- Given('I remove the {string} gem from the Gemfile') do |gem_name|
25
- content = File.open(expand_path('Gemfile'), 'r').readlines
26
- new_content = []
27
-
28
- content.each do |line|
29
- next if line =~ /gem ["|']#{gem_name}["|'].*/
30
-
31
- new_content << line
32
- end
33
-
34
- overwrite_file('Gemfile', new_content.join("\r\n"))
35
- end
36
-
37
- Given('I force selenium to run Firefox in headless mode') do
38
- selenium_config = %{
39
- Capybara.register_driver :selenium do |app|
40
- http_client = Selenium::WebDriver::Remote::Http::Default.new
41
- http_client.read_timeout = 180
42
-
43
- browser_options = Selenium::WebDriver::Firefox::Options.new
44
- browser_options.args << '--headless'
45
- Capybara::Selenium::Driver.new(
46
- app,
47
- browser: :firefox,
48
- options: browser_options,
49
- http_client: http_client
50
- )
51
- end
52
-
53
- Capybara.server = :webrick
54
- }
55
-
56
- step 'I append to "features/support/env.rb" with:', selenium_config
57
- end
58
-
59
- When('I run the cukes') do
60
- run_command_and_stop('bundle exec cucumber')
61
- end
62
-
63
- # Copied from Aruba
64
- Then(/^the feature run should pass with:$/) do |string|
65
- step 'the output should not contain " failed)"'
66
- step 'the output should not contain " undefined)"'
67
- step 'the exit status should be 0'
68
- step 'the output should contain:', string
69
- end