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
@@ -1,57 +1,70 @@
1
- # -*- encoding: utf-8 -*-
1
+ # frozen_string_literal: true
2
+
2
3
  require 'cucumber/rails/database'
3
4
 
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 }
5
10
 
6
- let(:strategy) { stub(:before_js => nil, :before_non_js => nil) }
11
+ context 'when using a valid pre-determined strategy' do
12
+ before { described_class.javascript_strategy = :truncation }
7
13
 
8
- it 'forwards events to the selected strategy' do
9
- Cucumber::Rails::Database::TruncationStrategy.stub(:new => strategy)
10
- Cucumber::Rails::Database.javascript_strategy = :truncation
14
+ it 'forwards a `before_non_js` event to the selected strategy' do
15
+ expect(strategy).to receive(:before_non_js)
16
+
17
+ described_class.before_non_js
18
+ end
11
19
 
12
- strategy.should_receive(:before_non_js).ordered
13
- Cucumber::Rails::Database.before_non_js
20
+ it 'forwards a `before_js` event to the selected strategy' do
21
+ expect(strategy).to receive(:before_js)
14
22
 
15
- strategy.should_receive(:before_js).ordered
16
- Cucumber::Rails::Database.before_js
23
+ described_class.before_js
24
+ end
17
25
  end
18
26
 
19
- it 'raises an error if you use a non-understood strategy' do
20
- expect { Cucumber::Rails::Database.javascript_strategy = :invalid }.to raise_error(Cucumber::Rails::Database::InvalidStrategy)
27
+ context 'when using an invalid pre-determined strategy' do
28
+ it 'raises an error if you use a non-understood strategy' do
29
+ expect { described_class.javascript_strategy = :invalid }
30
+ .to raise_error(Cucumber::Rails::Database::InvalidStrategy)
31
+ end
21
32
  end
22
33
 
23
- describe 'using a custom strategy' do
24
- class ValidStrategy
25
- def before_js
26
- # Anything
27
- end
34
+ context 'when using a valid custom strategy' do
35
+ before { described_class.javascript_strategy = strategy_type }
28
36
 
29
- def before_non_js
30
- # Likewise
37
+ let(:strategy_type) do
38
+ Class.new do
39
+ def before_js
40
+ # Anything
41
+ end
42
+
43
+ def before_non_js
44
+ # Likewise
45
+ end
31
46
  end
32
47
  end
33
48
 
34
- class InvalidStrategy
35
- end
49
+ it 'forwards a `before_non_js` event to the strategy' do
50
+ expect(strategy).to receive(:before_non_js)
36
51
 
37
- it 'raises an error if the strategy doens\'t support the protocol' do
38
- expect { Cucumber::Rails::Database.javascript_strategy = InvalidStrategy }.to raise_error(ArgumentError)
52
+ described_class.before_non_js
39
53
  end
40
54
 
41
- it 'accepts a custom strategy with a valid interface' do
42
- expect { Cucumber::Rails::Database.javascript_strategy = ValidStrategy }.not_to raise_error
43
- end
55
+ it 'forwards a `before_js` event to the strategy' do
56
+ expect(strategy).to receive(:before_js)
44
57
 
45
- it 'forwards events to a custom strategy' do
46
- ValidStrategy.stub(:new => strategy)
47
- Cucumber::Rails::Database.javascript_strategy = ValidStrategy
58
+ described_class.before_js
59
+ end
60
+ end
48
61
 
49
- strategy.should_receive(:before_non_js).ordered
50
- Cucumber::Rails::Database.before_non_js
62
+ context 'when using an invalid custom strategy' do
63
+ let(:invalid_strategy) { Class.new }
51
64
 
52
- strategy.should_receive(:before_js).ordered
53
- Cucumber::Rails::Database.before_js
65
+ it 'raises an error if the strategy does not have a valid interface' do
66
+ expect { described_class.javascript_strategy = invalid_strategy }
67
+ .to raise_error(ArgumentError)
54
68
  end
55
69
  end
56
-
57
70
  end
@@ -0,0 +1,55 @@
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 CHANGED
@@ -1,4 +1,16 @@
1
- require 'rubygems'
2
- require 'rspec/autorun'
1
+ # frozen_string_literal: true
3
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'
4
16
  require 'ammeter/init'