cucumber-rails 1.8.0 → 2.5.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.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +165 -16
  3. data/CONTRIBUTING.md +14 -2
  4. data/LICENSE +1 -1
  5. data/README.md +28 -28
  6. data/lib/cucumber/rails/action_dispatch.rb +21 -0
  7. data/lib/cucumber/rails/application.rb +11 -8
  8. data/lib/cucumber/rails/capybara/javascript_emulation.rb +27 -16
  9. data/lib/cucumber/rails/capybara/select_dates_and_times.rb +28 -13
  10. data/lib/cucumber/rails/database/deletion_strategy.rb +13 -0
  11. data/lib/cucumber/rails/database/null_strategy.rb +15 -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/database.rb +9 -58
  16. data/lib/cucumber/rails/hooks/database_cleaner.rb +9 -3
  17. data/lib/cucumber/rails/hooks/mail.rb +1 -1
  18. data/lib/cucumber/rails/world.rb +14 -3
  19. data/lib/cucumber/rails.rb +12 -13
  20. data/lib/generators/cucumber/install_generator.rb +13 -16
  21. data/lib/generators/cucumber/templates/config/cucumber.yml.erb +3 -3
  22. data/lib/generators/cucumber/templates/tasks/cucumber.rake.erb +5 -0
  23. metadata +94 -118
  24. data/.github/ISSUE_TEMPLATE.md +0 -52
  25. data/.github/PULL_REQUEST_TEMPLATE.md +0 -42
  26. data/.gitignore +0 -14
  27. data/.rspec +0 -1
  28. data/.rubocop.yml +0 -36
  29. data/.rubocop_todo.yml +0 -59
  30. data/.travis.yml +0 -60
  31. data/Appraisals +0 -35
  32. data/Gemfile +0 -5
  33. data/Rakefile +0 -53
  34. data/bin/install_geckodriver.sh +0 -19
  35. data/bin/install_webpacker.sh +0 -9
  36. data/config/.gitignore +0 -1
  37. data/config/cucumber.yml +0 -17
  38. data/cucumber-rails.gemspec +0 -44
  39. data/dev_tasks/cucumber.rake +0 -5
  40. data/dev_tasks/rspec.rake +0 -5
  41. data/dev_tasks/yard/default/layout/html/bubble_32x32.png +0 -0
  42. data/dev_tasks/yard/default/layout/html/footer.erb +0 -5
  43. data/dev_tasks/yard/default/layout/html/index.erb +0 -1
  44. data/dev_tasks/yard/default/layout/html/layout.erb +0 -25
  45. data/dev_tasks/yard/default/layout/html/logo.erb +0 -1
  46. data/dev_tasks/yard/default/layout/html/setup.rb +0 -9
  47. data/dev_tasks/yard.rake +0 -36
  48. data/features/allow_rescue.feature +0 -65
  49. data/features/annotations.feature +0 -22
  50. data/features/capybara_javascript_drivers.feature +0 -62
  51. data/features/choose_javascript_database_strategy.feature +0 -125
  52. data/features/database_cleaner.feature +0 -44
  53. data/features/disable_automatic_database_cleaning.feature +0 -49
  54. data/features/emulate_javascript.feature +0 -94
  55. data/features/install_cucumber_rails.feature +0 -14
  56. data/features/no_database.feature +0 -60
  57. data/features/raising_errors.feature +0 -16
  58. data/features/rerun_profile.feature +0 -46
  59. data/features/rest_api.feature +0 -47
  60. data/features/step_definitions/cucumber_rails_steps.rb +0 -72
  61. data/features/support/aruba.rb +0 -5
  62. data/features/support/cucumber_rails_helper.rb +0 -80
  63. data/features/support/env.rb +0 -14
  64. data/features/support/legacy_web_steps_support.rb +0 -289
  65. data/gemfiles/rails_4_2.gemfile +0 -10
  66. data/gemfiles/rails_5_0.gemfile +0 -10
  67. data/gemfiles/rails_5_1.gemfile +0 -10
  68. data/gemfiles/rails_5_2.gemfile +0 -10
  69. data/gemfiles/rails_6_0.gemfile +0 -9
  70. data/lib/cucumber/rails/action_controller.rb +0 -17
  71. data/lib/generators/cucumber/templates/support/rails_spork.rb.erb +0 -13
  72. data/spec/cucumber/rails/database_spec.rb +0 -61
  73. data/spec/generators/cucumber/install_generator_spec.rb +0 -57
  74. data/spec/spec_helper.rb +0 -16
@@ -1,94 +0,0 @@
1
- Feature: Emulate Javascript
2
-
3
- Scenario: See a widget
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/f.feature" with:
8
- """
9
- @javascript
10
- Feature: Widget inventory
11
- Scenario: Delete a widget
12
- Given there is a widget named "wrench"
13
- When I go to the widgets page
14
- Then I should see "wrench"
15
- """
16
- And I write to "features/step_definitions/s.rb" with:
17
- """
18
- Given('there is a widget named {string}') do |name|
19
- FactoryBot.create(:widget, name: name)
20
- end
21
- """
22
- And I write to "features/support/factories.rb" with:
23
- """
24
- FactoryBot.define do
25
- factory :widget do
26
- name { 'testwidget' }
27
- end
28
- end
29
- """
30
- And I run `bundle exec rake db:migrate`
31
- And I run `bundle exec rake cucumber`
32
- Then the feature run should pass with:
33
- """
34
- 1 scenario (1 passed)
35
- 3 steps (3 passed)
36
- """
37
-
38
- Scenario: Pass on the CSRF token
39
- Given I have created a new Rails app and installed cucumber-rails
40
- When I run `rails generate scaffold widget name:string`
41
- And I run `sed -i -e 's/forgery_protection *= false/forgery_protection = true/' config/environments/test.rb`
42
- And I run `rails generate controller session establish`
43
- And I write to "app/controllers/session_controller.rb" with:
44
- """
45
- class SessionController < ApplicationController
46
- def establish
47
- session[:verified] = true
48
- end
49
- end
50
- """
51
- And I write to "app/controllers/application_controller.rb" with:
52
- """
53
- class ApplicationController < ActionController::Base
54
- protect_from_forgery
55
-
56
- before_action except: :establish do
57
- render text: 'denied', status: :forbidden and return false unless session[:verified]
58
- end
59
- end
60
- """
61
- And I write to "features/f.feature" with:
62
- """
63
- Feature: Widget inventory
64
- Scenario: Delete a widget
65
- Given there is a widget named "wrench"
66
- When I go to the session establish page
67
- And I go to the widgets page
68
- Then I should see "wrench"
69
- When I follow "Destroy"
70
- Then I should not see "denied"
71
- And I should be on the widgets page
72
- And I should not see "wrench"
73
- """
74
- And I write to "features/step_definitions/s.rb" with:
75
- """
76
- Given('there is a widget named {string}') do |name|
77
- FactoryBot.create(:widget, name: name)
78
- end
79
- """
80
- And I write to "features/support/factories.rb" with:
81
- """
82
- FactoryBot.define do
83
- factory :widget do
84
- name { 'testwidget' }
85
- end
86
- end
87
- """
88
- And I run `bundle exec rake db:migrate`
89
- And I run `bundle exec rake cucumber`
90
- Then the feature run should pass with:
91
- """
92
- 1 scenario (1 passed)
93
- 8 steps (8 passed)
94
- """
@@ -1,14 +0,0 @@
1
- Feature: Rails
2
- In order to take over the world
3
- Cucumber-Rails should work on major versions
4
- of Rails and Ruby, with Capybara, Spork 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,60 +0,0 @@
1
- Feature: No Database
2
- Allow Cucumber to work with a Rails app without a database
3
-
4
- Scenario: No ActiveRecord and DatabaseCleaner
5
- Given I have created a new Rails app with no database and installed cucumber-rails
6
- # Turn off ActiveRecord
7
- When I write to "config/application.rb" with:
8
- """
9
- require File.expand_path('../boot', __FILE__)
10
-
11
- require 'action_controller/railtie'
12
- require 'action_mailer/railtie'
13
- require 'rails/test_unit/railtie'
14
-
15
- Bundler.require(:default, Rails.env) if defined?(Bundler)
16
-
17
- module TestApp
18
- class Application < Rails::Application
19
- config.encoding = 'utf-8'
20
- config.filter_parameters += [:password]
21
- end
22
- end
23
- """
24
- And I overwrite "features/support/env.rb" with:
25
- """
26
- require 'cucumber/rails'
27
- """
28
- And I remove the 'database_cleaner' gem from the Gemfile
29
- And I remove the 'sqlite' gem from the Gemfile
30
- And I write to "app/controllers/posts_controller.rb" with:
31
- """
32
- class PostsController < ApplicationController
33
- def index
34
- raise 'There is an error in index'
35
- end
36
- end
37
- """
38
- And I write to "config/routes.rb" with:
39
- """
40
- TestApp::Application.routes.draw do
41
- resources :posts
42
- end
43
- """
44
- And I write to "features/posts.feature" with:
45
- """
46
- Feature: posts
47
- Scenario: See them
48
- When I view the posts
49
- """
50
- And I write to "features/step_definitions/posts_steps.rb" with:
51
- """
52
- When('I view the posts') do
53
- visit '/posts'
54
- end
55
- """
56
- And I run `bundle exec rake cucumber`
57
- Then it should fail with:
58
- """
59
- There is an error in index
60
- """
@@ -1,16 +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/tests.feature" with:
6
- """
7
- Feature: Tests
8
- Scenario: Tests
9
- When I go to the products page
10
- """
11
- And I run `bundle exec cucumber`
12
- Then it should fail with:
13
- """
14
- 1 scenario (1 failed)
15
- 1 step (1 failed)
16
- """
@@ -1,46 +0,0 @@
1
- Feature: Rerun profile
2
- In order to concentrate on failing features
3
- As a Rails developer working with Cucumber
4
- I want to rerun only failing features
5
-
6
- Scenario: Rerun
7
- Given I have created a new Rails app and installed cucumber-rails
8
- And a file named "rerun.txt" with:
9
- """
10
- features/rerun_test.feature:2
11
- features/rerun_test.feature:5
12
- """
13
- And a file named "features/rerun_test.feature" with:
14
- """
15
- Feature: Rerun test
16
- Scenario: failing before
17
- Given fixed now
18
-
19
- Scenario: still failing
20
- Given broken
21
-
22
- Scenario: always passing
23
- Given passing
24
- """
25
- And a file named "features/step_definitions/rerun_steps.rb" with:
26
- """
27
- Given('fixed now') do
28
- puts 'All fixed now'
29
- end
30
-
31
- Given('broken') do
32
- raise "I'm broken"
33
- end
34
-
35
- Given('passing') do
36
- puts "I've always been passing"
37
- end
38
- """
39
- When I run `bundle exec cucumber -p rerun`
40
- Then it should fail with:
41
- """
42
- 2 scenarios (1 failed, 1 passed)
43
- 2 steps (1 failed, 1 passed)
44
- """
45
- And the file "rerun.txt" should not contain "features/rerun_test.feature:2"
46
- 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/rest_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,72 +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
- create_web_steps
7
- end
8
-
9
- Given('I have created a new Rails app and installed cucumber-rails') do
10
- rails_new
11
- install_cucumber_rails
12
- create_web_steps
13
- end
14
-
15
- Given('I have created a new Rails app with no database and installed cucumber-rails') do
16
- rails_new args: '--skip-active-record'
17
- install_cucumber_rails :no_database_cleaner, :no_factory_bot
18
- overwrite_file('features/support/env.rb', "require 'cucumber/rails'\n")
19
- create_web_steps
20
- end
21
-
22
- Given('I have a {string} ActiveRecord model object') do |name|
23
- run_command_and_stop("bundle exec rails g model #{name}")
24
- run_command_and_stop('bundle exec rake db:migrate RAILS_ENV=test')
25
- end
26
-
27
- Given('I force selenium to run Firefox in headless mode') do
28
- selenium_config = %{
29
- Capybara.register_driver :selenium do |app|
30
- http_client = Selenium::WebDriver::Remote::Http::Default.new
31
- http_client.read_timeout = 180
32
-
33
- browser_options = Selenium::WebDriver::Firefox::Options.new
34
- browser_options.args << '--headless'
35
- Capybara::Selenium::Driver.new(
36
- app,
37
- browser: :firefox,
38
- options: browser_options,
39
- http_client: http_client
40
- )
41
- end
42
-
43
- Capybara.server = :webrick
44
- }
45
-
46
- step 'I append to "features/support/env.rb" with:', selenium_config
47
- end
48
-
49
- When('I run the cukes') do
50
- run_command_and_stop('bundle exec cucumber')
51
- end
52
-
53
- # Copied from Aruba
54
- Then(/^the feature run should pass with:$/) do |string|
55
- step 'the output should not contain " failed)"'
56
- step 'the output should not contain " undefined)"'
57
- step 'the exit status should be 0'
58
- step 'the output should contain:', string
59
- end
60
-
61
- Given('I remove the {string} gem from the Gemfile') do |gem_name|
62
- content = File.open(expand_path('Gemfile'), 'r').readlines
63
- new_content = []
64
-
65
- content.each do |line|
66
- next if line =~ /gem ["|']#{gem_name}["|'].*/
67
-
68
- new_content << line
69
- end
70
-
71
- overwrite_file('Gemfile', new_content.join("\r\n"))
72
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Aruba.configure do |config|
4
- config.exit_timeout = 120
5
- end
@@ -1,80 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module CucumberRailsHelper
4
- def rails_new(options = {})
5
- options[:name] ||= 'test_app'
6
- command_result =
7
- run_command "bundle exec rails new #{options[:name]} --skip-bundle --skip-test-unit --skip-spring --skip-bootsnap #{options[:args]}"
8
- expect(command_result).to have_output(/README/)
9
- expect(last_command_started).to be_successfully_executed
10
- cd options[:name]
11
- delete_environment_variable 'RUBYOPT'
12
- delete_environment_variable 'BUNDLE_BIN_PATH'
13
- delete_environment_variable 'BUNDLE_GEMFILE'
14
- end
15
-
16
- def install_cucumber_rails(*options)
17
- add_conditional_gems(options)
18
-
19
- gem 'selenium-webdriver', '~> 3.11', group: :test
20
- gem 'rspec-expectations', '~> 3.7', group: :test
21
- gem 'database_cleaner', '>= 1.1', group: :test unless options.include?(:no_database_cleaner)
22
- gem 'factory_bot', '>= 3.2', group: :test unless options.include?(:no_factory_bot)
23
-
24
- run_command_and_stop 'bundle install'
25
- run_command_and_stop 'bundle exec rails webpacker:install' if rails6?
26
- run_command_and_stop 'bundle exec rails generate cucumber:install'
27
- end
28
-
29
- def gem(name, *args)
30
- options = args.last.is_a?(Hash) ? args.pop : {}
31
-
32
- parts = ["'#{name}'"]
33
- parts << args.map(&:inspect) if args.any?
34
- parts << options.inspect[1..-2] if options.any?
35
-
36
- line = "gem #{parts.join(', ')}\n"
37
-
38
- gem_regexp = /gem ["']#{name}["'].*$/
39
- gemfile_content = File.read(expand_path('Gemfile'))
40
-
41
- if gemfile_content =~ gem_regexp
42
- gemfile_content.gsub!(gem_regexp, line)
43
- overwrite_file('Gemfile', gemfile_content)
44
- else
45
- append_to_file('Gemfile', line)
46
- end
47
- end
48
-
49
- def fixture(path)
50
- File.expand_path(File.dirname(__FILE__) + "./../support/fixtures/#{path}")
51
- end
52
-
53
- private
54
-
55
- def rails6?
56
- `bundle exec rails -v`.start_with?('Rails 6')
57
- end
58
-
59
- def add_conditional_gems(options)
60
- if options.include?(:not_in_test_group)
61
- gem 'cucumber-rails', path: File.expand_path('.').to_s
62
- else
63
- gem 'cucumber-rails', group: :test, require: false, path: File.expand_path('.').to_s
64
- end
65
-
66
- if rails6?
67
- gem 'sqlite3', '~> 1.4'
68
- else
69
- gem 'sqlite3', '~> 1.3.13'
70
- end
71
-
72
- if RUBY_VERSION < '2.4.0'
73
- gem 'capybara', '< 3.16.0', group: :test
74
- else
75
- gem 'capybara', group: :test
76
- end
77
- end
78
- end
79
-
80
- World(CucumberRailsHelper)
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
4
- require 'rubygems'
5
- require 'bundler/setup'
6
- require 'rspec/expectations'
7
- require 'aruba/cucumber'
8
-
9
- After do |scenario|
10
- if scenario.failed?
11
- puts last_command_stopped.stdout
12
- puts last_command_stopped.stderr
13
- end
14
- end