cucumber-rails 2.0.0 → 2.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.
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,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Aruba.configure do |config|
4
- config.exit_timeout = 120
5
- end
@@ -1,76 +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
- private
50
-
51
- def rails6?
52
- `bundle exec rails -v`.start_with?('Rails 6')
53
- end
54
-
55
- def add_conditional_gems(options)
56
- if options.include?(:not_in_test_group)
57
- gem 'cucumber-rails', path: File.expand_path('.').to_s
58
- else
59
- gem 'cucumber-rails', group: :test, require: false, path: File.expand_path('.').to_s
60
- end
61
-
62
- if rails6?
63
- gem 'sqlite3', '~> 1.4'
64
- else
65
- gem 'sqlite3', '~> 1.3.13'
66
- end
67
-
68
- if RUBY_VERSION < '2.4.0'
69
- gem 'capybara', '< 3.16.0', group: :test
70
- else
71
- gem 'capybara', group: :test
72
- end
73
- end
74
- end
75
-
76
- World(CucumberRailsHelper)
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
4
-
5
- require 'rspec/expectations'
6
- require 'aruba/cucumber'
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- After do |scenario|
4
- if scenario.failed?
5
- puts last_command_stopped.stdout
6
- puts last_command_stopped.stderr
7
- end
8
- end
@@ -1,10 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "capybara", "< 3.16.0", platform: :mri_23
6
- gem "nokogiri", "< 1.9.1", platform: :mri_23
7
- gem "railties", "~> 4.2.11"
8
- gem "sqlite3", "~> 1.3.13"
9
-
10
- gemspec path: "../"
@@ -1,10 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "capybara", "< 3.16.0", platform: :mri_23
6
- gem "nokogiri", "< 1.9.1", platform: :mri_23
7
- gem "railties", "~> 5.0.7"
8
- gem "sqlite3", "~> 1.3.13"
9
-
10
- gemspec path: "../"
@@ -1,10 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "capybara", "< 3.16.0", platform: :mri_23
6
- gem "nokogiri", "< 1.9.1", platform: :mri_23
7
- gem "railties", "~> 5.1.7"
8
- gem "sqlite3", "~> 1.3.13"
9
-
10
- gemspec path: "../"
@@ -1,10 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "capybara", "< 3.16.0", platform: :mri_23
6
- gem "nokogiri", "< 1.9.1", platform: :mri_23
7
- gem "railties", "~> 5.2.0"
8
- gem "sqlite3", "~> 1.3.13"
9
-
10
- gemspec path: "../"
@@ -1,9 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "railties", "~> 6.0.0"
6
- gem "rails", "~> 6.0.0"
7
- gem "sqlite3", "~> 1.4"
8
-
9
- gemspec path: "../"
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- ActionController::Base.class_eval do
4
- cattr_accessor :allow_rescue
5
- end
6
-
7
- module ActionDispatch
8
- class ShowExceptions
9
- alias __cucumber_orig_call__ call
10
-
11
- def call(env)
12
- env['action_dispatch.show_exceptions'] = !!ActionController::Base.allow_rescue
13
- env['action_dispatch.show_detailed_exceptions'] = !ActionController::Base.allow_rescue
14
- __cucumber_orig_call__(env)
15
- end
16
- end
17
- end
@@ -1,13 +0,0 @@
1
- <%= embed_file('support/edit_warning.txt') %>
2
- require 'rubygems'
3
- require 'spork'
4
-
5
- Spork.prefork do
6
- <%= embed_template('support/_rails_prefork.rb.erb', ' ') %>
7
-
8
- <%= embed_file("support/capybara.rb", ' ') %>
9
- end
10
-
11
- Spork.each_run do
12
- <%= embed_template('support/_rails_each_run.rb.erb', ' ') %>
13
- end
@@ -1,61 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'cucumber/rails/database'
4
-
5
- describe Cucumber::Rails::Database do
6
- before { allow(strategy_type).to receive(:new).and_return(strategy) }
7
-
8
- let(:strategy) { instance_double(strategy_type, before_js: nil, before_non_js: nil) }
9
- let(:strategy_type) { Cucumber::Rails::Database::TruncationStrategy }
10
-
11
- it 'forwards events to the selected strategy' do
12
- described_class.javascript_strategy = :truncation
13
-
14
- expect(strategy).to receive(:before_non_js)
15
- described_class.before_non_js
16
-
17
- expect(strategy).to receive(:before_js)
18
- described_class.before_js
19
- end
20
-
21
- it 'raises an error if you use a non-understood strategy' do
22
- expect { described_class.javascript_strategy = :invalid }
23
- .to raise_error(Cucumber::Rails::Database::InvalidStrategy)
24
- end
25
-
26
- context 'using a custom strategy' do
27
- let(:strategy_type) { ValidStrategy }
28
-
29
- class ValidStrategy
30
- def before_js
31
- # Anything
32
- end
33
-
34
- def before_non_js
35
- # Likewise
36
- end
37
- end
38
-
39
- class InvalidStrategy; end
40
-
41
- it 'raises an error if the strategy does not have a valid interface' do
42
- expect { described_class.javascript_strategy = InvalidStrategy }
43
- .to raise_error(ArgumentError)
44
- end
45
-
46
- it 'accepts the strategy if it has a valid interface' do
47
- expect { described_class.javascript_strategy = ValidStrategy }
48
- .not_to raise_error
49
- end
50
-
51
- it 'forwards events to the strategy' do
52
- described_class.javascript_strategy = ValidStrategy
53
-
54
- expect(strategy).to receive(:before_non_js)
55
- described_class.before_non_js
56
-
57
- expect(strategy).to receive(:before_js)
58
- described_class.before_js
59
- end
60
- end
61
- end
@@ -1,55 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Generators are not automatically loaded by Rails
4
- require 'generators/cucumber/install_generator'
5
-
6
- describe Cucumber::InstallGenerator do
7
- # Tell the generator where to put its output (what it thinks of as Rails.root)
8
- destination File.expand_path('../../../../tmp', __dir__)
9
-
10
- before { prepare_destination }
11
-
12
- let(:auto_generated_message) do
13
- '# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.'
14
- end
15
-
16
- context 'without arguments' do
17
- before { run_generator }
18
-
19
- describe 'config/cucumber.yml' do
20
- subject { file('config/cucumber.yml') }
21
-
22
- it { is_expected.to exist }
23
- it { is_expected.to contain 'default: <%= std_opts %> features' }
24
- end
25
-
26
- describe 'features/step_definitions folder' do
27
- subject { file('features/step_definitions') }
28
-
29
- it { is_expected.to exist }
30
- end
31
-
32
- describe 'features/support/env.rb' do
33
- subject { file('features/support/env.rb') }
34
-
35
- it { is_expected.to exist }
36
- it { is_expected.to contain auto_generated_message }
37
- it { is_expected.to contain "require 'cucumber/rails'" }
38
- end
39
-
40
- describe 'lib/tasks/cucumber.rake' do
41
- subject { file('lib/tasks/cucumber.rake') }
42
-
43
- it { is_expected.to exist }
44
- it { is_expected.to contain auto_generated_message }
45
- it { is_expected.to contain "task cucumber: 'cucumber:ok'" }
46
- end
47
-
48
- describe 'script/cucumber' do
49
- subject { file('script/cucumber') }
50
-
51
- it { is_expected.to exist }
52
- it { is_expected.to contain 'load Cucumber::BINARY' }
53
- end
54
- end
55
- end
data/spec/spec_helper.rb DELETED
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rspec/rails/fixture_support'
4
- require 'rails/all'
5
-
6
- ActiveRecord::Base.establish_connection adapter: 'sqlite3', database: ':memory:'
7
-
8
- module CucumberRails
9
- class Application < ::Rails::Application
10
- config.secret_key_base = 'ASecretString'
11
- end
12
- end
13
-
14
- require 'rspec/support/spec'
15
- require 'rspec/rails'
16
- require 'ammeter/init'