cucumber-rails 2.0.0 → 2.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +147 -18
  3. data/CONTRIBUTING.md +14 -2
  4. data/LICENSE +1 -1
  5. data/README.md +5 -24
  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 +40 -11
  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 +2 -2
  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 +96 -102
  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 -4
  28. data/.rubocop.yml +0 -33
  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 -20
  50. data/features/capybara_javascript_drivers.feature +0 -82
  51. data/features/choose_javascript_database_strategy.feature +0 -125
  52. data/features/configuration.feature +0 -48
  53. data/features/database_cleaner.feature +0 -44
  54. data/features/disable_automatic_database_cleaning.feature +0 -49
  55. data/features/emulate_javascript.feature +0 -109
  56. data/features/install_cucumber_rails.feature +0 -14
  57. data/features/no_database.feature +0 -61
  58. data/features/raising_errors.feature +0 -22
  59. data/features/rerun_profile.feature +0 -47
  60. data/features/rest_api.feature +0 -47
  61. data/features/step_definitions/cucumber_rails_steps.rb +0 -69
  62. data/features/support/aruba.rb +0 -5
  63. data/features/support/cucumber_rails_helper.rb +0 -76
  64. data/features/support/env.rb +0 -6
  65. data/features/support/hooks.rb +0 -8
  66. data/gemfiles/rails_4_2.gemfile +0 -10
  67. data/gemfiles/rails_5_0.gemfile +0 -10
  68. data/gemfiles/rails_5_1.gemfile +0 -10
  69. data/gemfiles/rails_5_2.gemfile +0 -10
  70. data/gemfiles/rails_6_0.gemfile +0 -9
  71. data/lib/cucumber/rails/action_controller.rb +0 -17
  72. data/lib/generators/cucumber/templates/support/rails_spork.rb.erb +0 -13
  73. data/spec/cucumber/rails/database_spec.rb +0 -61
  74. data/spec/generators/cucumber/install_generator_spec.rb +0 -55
  75. data/spec/spec_helper.rb +0 -16
@@ -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
@@ -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'