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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +165 -16
- data/CONTRIBUTING.md +14 -2
- data/LICENSE +1 -1
- data/README.md +28 -28
- data/lib/cucumber/rails/action_dispatch.rb +21 -0
- data/lib/cucumber/rails/application.rb +11 -8
- data/lib/cucumber/rails/capybara/javascript_emulation.rb +27 -16
- data/lib/cucumber/rails/capybara/select_dates_and_times.rb +28 -13
- data/lib/cucumber/rails/database/deletion_strategy.rb +13 -0
- data/lib/cucumber/rails/database/null_strategy.rb +15 -0
- data/lib/cucumber/rails/database/shared_connection_strategy.rb +27 -0
- data/lib/cucumber/rails/database/strategy.rb +35 -0
- data/lib/cucumber/rails/database/truncation_strategy.rb +13 -0
- data/lib/cucumber/rails/database.rb +9 -58
- data/lib/cucumber/rails/hooks/database_cleaner.rb +9 -3
- data/lib/cucumber/rails/hooks/mail.rb +1 -1
- data/lib/cucumber/rails/world.rb +14 -3
- data/lib/cucumber/rails.rb +12 -13
- data/lib/generators/cucumber/install_generator.rb +13 -16
- data/lib/generators/cucumber/templates/config/cucumber.yml.erb +3 -3
- data/lib/generators/cucumber/templates/tasks/cucumber.rake.erb +5 -0
- metadata +94 -118
- data/.github/ISSUE_TEMPLATE.md +0 -52
- data/.github/PULL_REQUEST_TEMPLATE.md +0 -42
- data/.gitignore +0 -14
- data/.rspec +0 -1
- data/.rubocop.yml +0 -36
- data/.rubocop_todo.yml +0 -59
- data/.travis.yml +0 -60
- data/Appraisals +0 -35
- data/Gemfile +0 -5
- data/Rakefile +0 -53
- data/bin/install_geckodriver.sh +0 -19
- data/bin/install_webpacker.sh +0 -9
- data/config/.gitignore +0 -1
- data/config/cucumber.yml +0 -17
- data/cucumber-rails.gemspec +0 -44
- data/dev_tasks/cucumber.rake +0 -5
- data/dev_tasks/rspec.rake +0 -5
- data/dev_tasks/yard/default/layout/html/bubble_32x32.png +0 -0
- data/dev_tasks/yard/default/layout/html/footer.erb +0 -5
- data/dev_tasks/yard/default/layout/html/index.erb +0 -1
- data/dev_tasks/yard/default/layout/html/layout.erb +0 -25
- data/dev_tasks/yard/default/layout/html/logo.erb +0 -1
- data/dev_tasks/yard/default/layout/html/setup.rb +0 -9
- data/dev_tasks/yard.rake +0 -36
- data/features/allow_rescue.feature +0 -65
- data/features/annotations.feature +0 -22
- data/features/capybara_javascript_drivers.feature +0 -62
- data/features/choose_javascript_database_strategy.feature +0 -125
- data/features/database_cleaner.feature +0 -44
- data/features/disable_automatic_database_cleaning.feature +0 -49
- data/features/emulate_javascript.feature +0 -94
- data/features/install_cucumber_rails.feature +0 -14
- data/features/no_database.feature +0 -60
- data/features/raising_errors.feature +0 -16
- data/features/rerun_profile.feature +0 -46
- data/features/rest_api.feature +0 -47
- data/features/step_definitions/cucumber_rails_steps.rb +0 -72
- data/features/support/aruba.rb +0 -5
- data/features/support/cucumber_rails_helper.rb +0 -80
- data/features/support/env.rb +0 -14
- data/features/support/legacy_web_steps_support.rb +0 -289
- data/gemfiles/rails_4_2.gemfile +0 -10
- data/gemfiles/rails_5_0.gemfile +0 -10
- data/gemfiles/rails_5_1.gemfile +0 -10
- data/gemfiles/rails_5_2.gemfile +0 -10
- data/gemfiles/rails_6_0.gemfile +0 -9
- data/lib/cucumber/rails/action_controller.rb +0 -17
- data/lib/generators/cucumber/templates/support/rails_spork.rb.erb +0 -13
- data/spec/cucumber/rails/database_spec.rb +0 -61
- data/spec/generators/cucumber/install_generator_spec.rb +0 -57
- data/spec/spec_helper.rb +0 -16
data/Appraisals
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
appraise 'rails_4_2' do
|
|
4
|
-
gem 'capybara', '< 3.16.0', platform: :mri_23
|
|
5
|
-
gem 'nokogiri', '< 1.9.1', platform: :mri_23
|
|
6
|
-
gem 'railties', '~> 4.2.11'
|
|
7
|
-
gem 'sqlite3', '~> 1.3.13'
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
appraise 'rails_5_0' do
|
|
11
|
-
gem 'capybara', '< 3.16.0', platform: :mri_23
|
|
12
|
-
gem 'nokogiri', '< 1.9.1', platform: :mri_23
|
|
13
|
-
gem 'railties', '~> 5.0.7'
|
|
14
|
-
gem 'sqlite3', '~> 1.3.13'
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
appraise 'rails_5_1' do
|
|
18
|
-
gem 'capybara', '< 3.16.0', platform: :mri_23
|
|
19
|
-
gem 'nokogiri', '< 1.9.1', platform: :mri_23
|
|
20
|
-
gem 'railties', '~> 5.1.0'
|
|
21
|
-
gem 'sqlite3', '~> 1.3.13'
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
appraise 'rails_5_2' do
|
|
25
|
-
gem 'capybara', '< 3.16.0', platform: :mri_23
|
|
26
|
-
gem 'nokogiri', '< 1.9.1', platform: :mri_23
|
|
27
|
-
gem 'railties', '~> 5.2.3'
|
|
28
|
-
gem 'sqlite3', '~> 1.3.13'
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
appraise 'rails_6_0' do
|
|
32
|
-
gem 'railties', '~> 6.0.0.rc2'
|
|
33
|
-
gem 'rails', '~> 6.0.0.rc2'
|
|
34
|
-
gem 'sqlite3', '~> 1.4'
|
|
35
|
-
end
|
data/Gemfile
DELETED
data/Rakefile
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
CUCUMBER_RAILS_VERSION =
|
|
4
|
-
Gem::Specification.load(File.dirname(__FILE__) + '/cucumber-rails.gemspec').version.version
|
|
5
|
-
require 'rubygems'
|
|
6
|
-
require 'bundler'
|
|
7
|
-
require 'bundler/setup'
|
|
8
|
-
require 'appraisal'
|
|
9
|
-
require 'rdoc' # https://github.com/lsegal/yard/commit/b861dcc2d7f7e1fbbed7b552ac2e4f7caf68bafa
|
|
10
|
-
require 'rake/clean'
|
|
11
|
-
require 'pathname'
|
|
12
|
-
Bundler::GemHelper.install_tasks
|
|
13
|
-
|
|
14
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/lib')
|
|
15
|
-
Dir["#{File.dirname(__FILE__)}/dev_tasks/*.rake"].sort.each { |ext| load ext }
|
|
16
|
-
|
|
17
|
-
CLEAN.include('doc', 'tmp')
|
|
18
|
-
|
|
19
|
-
task default: :test
|
|
20
|
-
|
|
21
|
-
task test: %i[spec cucumber]
|
|
22
|
-
|
|
23
|
-
namespace :test do
|
|
24
|
-
desc 'Run tests against all gemfiles'
|
|
25
|
-
task :all do
|
|
26
|
-
Rake::Task['appraisal'].invoke('test')
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
desc 'Run tests against specified gemfile, e.g. rake test:gemfile[rails_3_0]'
|
|
30
|
-
task :gemfile, :name do |_task, args|
|
|
31
|
-
unless args.name && Pathname.new("gemfiles/#{args.name}.gemfile").exist?
|
|
32
|
-
raise ArgumentError "You must provide the name of an existing Appraisal gemfile,
|
|
33
|
-
e.g. 'rake test:gemfile[rails_4_2]'"
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
Rake::Task["appraisal:#{args.name}"].invoke('test')
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
namespace :gemfiles do
|
|
41
|
-
desc 'Install dependencies for all gemfiles'
|
|
42
|
-
task :install do
|
|
43
|
-
ENV['BUNDLE_GEMFILE'] = 'Gemfile.appraisal'
|
|
44
|
-
Rake::Task['appraisal:install'].invoke
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
task :clean do
|
|
48
|
-
FileUtils.rm_rf('gemfiles/*')
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
desc 'Rebuild generated gemfiles and install dependencies'
|
|
52
|
-
task rebuild: %i[clean install]
|
|
53
|
-
end
|
data/bin/install_geckodriver.sh
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
set -xeuo pipefail
|
|
4
|
-
|
|
5
|
-
curl --silent \
|
|
6
|
-
--show-error \
|
|
7
|
-
--location \
|
|
8
|
-
--fail \
|
|
9
|
-
--retry 3 \
|
|
10
|
-
--output /tmp/geckodriver_linux64.tar.gz \
|
|
11
|
-
https://github.com/mozilla/geckodriver/releases/download/v0.24.0/geckodriver-v0.24.0-linux64.tar.gz
|
|
12
|
-
|
|
13
|
-
sudo tar -C /usr/local/bin -xvzf /tmp/geckodriver_linux64.tar.gz geckodriver
|
|
14
|
-
|
|
15
|
-
rm /tmp/geckodriver_linux64.tar.gz
|
|
16
|
-
|
|
17
|
-
geckodriver --version
|
|
18
|
-
|
|
19
|
-
set +x
|
data/bin/install_webpacker.sh
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
set -xeuo pipefail
|
|
4
|
-
|
|
5
|
-
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
|
|
6
|
-
echo 'deb https://dl.yarnpkg.com/debian/ stable main' | sudo tee /etc/apt/sources.list.d/yarn.list
|
|
7
|
-
sudo apt update && sudo apt install --yes yarn
|
|
8
|
-
|
|
9
|
-
set +x
|
data/config/.gitignore
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
aruba-rvm.yml
|
data/config/cucumber.yml
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
<%
|
|
2
|
-
rerun_file = '.cucumber.rerun'
|
|
3
|
-
failing_scenarios = IO.read(rerun_file) rescue ''
|
|
4
|
-
path = if failing_scenarios.empty?
|
|
5
|
-
'features'
|
|
6
|
-
else
|
|
7
|
-
puts "Running failed scenarios"
|
|
8
|
-
failing_scenarios.gsub /\s/, ' '
|
|
9
|
-
end
|
|
10
|
-
opts = [
|
|
11
|
-
"--format #{path == 'features' ? 'progress' : 'pretty'}",
|
|
12
|
-
"--format rerun -o #{rerun_file}"
|
|
13
|
-
]
|
|
14
|
-
rails_version = `bundle exec rails --version`.match(/[\d.]+$/).to_s
|
|
15
|
-
optlist = opts.join(' ')
|
|
16
|
-
%>
|
|
17
|
-
default: <%= path %> <%= optlist %> --tags 'not @broken'
|
data/cucumber-rails.gemspec
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
$LOAD_PATH.unshift File.expand_path('lib', __dir__)
|
|
4
|
-
|
|
5
|
-
Gem::Specification.new do |s|
|
|
6
|
-
s.name = 'cucumber-rails'
|
|
7
|
-
s.version = '1.8.0'
|
|
8
|
-
s.authors = ['Aslak Hellesøy', 'Dennis Blöte', 'Rob Holland']
|
|
9
|
-
s.description = 'Cucumber Generator and Runtime for Rails'
|
|
10
|
-
s.summary = "#{s.name}-#{s.version}"
|
|
11
|
-
s.email = 'cukes@googlegroups.com'
|
|
12
|
-
s.homepage = 'http://cukes.info'
|
|
13
|
-
|
|
14
|
-
s.license = 'MIT'
|
|
15
|
-
|
|
16
|
-
s.add_runtime_dependency('capybara', ['>= 2.12', '< 4'])
|
|
17
|
-
s.add_runtime_dependency('cucumber', ['>= 3.0.2', '< 4'])
|
|
18
|
-
s.add_runtime_dependency('mime-types', ['>= 2.0', '< 4'])
|
|
19
|
-
s.add_runtime_dependency('nokogiri', '~> 1.8')
|
|
20
|
-
s.add_runtime_dependency('railties', ['>= 4.2', '< 7'])
|
|
21
|
-
|
|
22
|
-
# Main development dependencies
|
|
23
|
-
s.add_development_dependency('ammeter', '>= 1.1.4')
|
|
24
|
-
s.add_development_dependency('appraisal', '~> 2.2')
|
|
25
|
-
s.add_development_dependency('aruba', '~> 0.14.4')
|
|
26
|
-
s.add_development_dependency('bundler', '>= 1.17')
|
|
27
|
-
s.add_development_dependency('rails', ['>= 4.2', '< 7'])
|
|
28
|
-
s.add_development_dependency('rake', '>= 12.0')
|
|
29
|
-
s.add_development_dependency('rspec', '~> 3.6')
|
|
30
|
-
s.add_development_dependency('rubocop', '~> 0.72.0')
|
|
31
|
-
s.add_development_dependency('rubocop-performance', '~> 1.4.0')
|
|
32
|
-
s.add_development_dependency('rubocop-rspec', '~> 1.33.0')
|
|
33
|
-
s.add_development_dependency('sqlite3', '~> 1.3')
|
|
34
|
-
|
|
35
|
-
# For Documentation:
|
|
36
|
-
s.add_development_dependency('rdoc', '>= 6.0')
|
|
37
|
-
s.add_development_dependency('yard', '~> 0.9.10')
|
|
38
|
-
|
|
39
|
-
s.required_ruby_version = '>= 2.3.0'
|
|
40
|
-
s.rubygems_version = '>= 1.6.1'
|
|
41
|
-
s.files = `git ls-files`.split("\n")
|
|
42
|
-
s.test_files = `git ls-files -- {spec,features}/*`.split("\n")
|
|
43
|
-
s.require_path = 'lib'
|
|
44
|
-
end
|
data/dev_tasks/cucumber.rake
DELETED
data/dev_tasks/rspec.rake
DELETED
|
Binary file
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<%= yieldall %>
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
2
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
3
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
4
|
-
<head>
|
|
5
|
-
<%= erb(:headers) %>
|
|
6
|
-
</head>
|
|
7
|
-
<body>
|
|
8
|
-
<script type="text/javascript" charset="utf-8">
|
|
9
|
-
if (window.top.frames.main) document.body.className = 'frames';
|
|
10
|
-
</script>
|
|
11
|
-
|
|
12
|
-
<div id="header">
|
|
13
|
-
<%= erb(:logo) %>
|
|
14
|
-
<%= erb(:breadcrumb) %>
|
|
15
|
-
<%= erb(:search) %>
|
|
16
|
-
<div class="clear"></div>
|
|
17
|
-
</div>
|
|
18
|
-
|
|
19
|
-
<iframe id="search_frame"></iframe>
|
|
20
|
-
|
|
21
|
-
<div id="content"><%= yieldall %></div>
|
|
22
|
-
|
|
23
|
-
<%= erb(:footer) %>
|
|
24
|
-
</body>
|
|
25
|
-
</html>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<h3><img src="<%= url_for('images/bubble_32x32.png') %>"></img> Cucumber-Rails <%= CUCUMBER_RAILS_VERSION %></h3>
|
data/dev_tasks/yard.rake
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'yard'
|
|
4
|
-
require 'yard/rake/yardoc_task'
|
|
5
|
-
|
|
6
|
-
SITE_DIR = File.expand_path(File.dirname(__FILE__) + '/../cucumber.github.com')
|
|
7
|
-
API_DIR = File.join(SITE_DIR, 'api', 'cucumber-rails', 'ruby', 'yardoc')
|
|
8
|
-
|
|
9
|
-
namespace :api do
|
|
10
|
-
file :dir do
|
|
11
|
-
raise "You need to git clone git@github.com:cucumber/cucumber.github.com.git #{SITE_DIR}" unless File.directory?(SITE_DIR)
|
|
12
|
-
|
|
13
|
-
sh('git pull origin master')
|
|
14
|
-
mkdir_p API_DIR
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
template_path = File.expand_path(File.join(File.dirname(__FILE__), 'yard'))
|
|
18
|
-
YARD::Templates::Engine.register_template_path(template_path)
|
|
19
|
-
YARD::Rake::YardocTask.new(:yard) do |yard|
|
|
20
|
-
dir = API_DIR
|
|
21
|
-
mkdir_p dir
|
|
22
|
-
yard.options = ['--out', dir]
|
|
23
|
-
end
|
|
24
|
-
task yard: :dir
|
|
25
|
-
|
|
26
|
-
task :release do
|
|
27
|
-
Dir.chdir(SITE_DIR) do
|
|
28
|
-
sh('git add .')
|
|
29
|
-
sh("git commit -m 'Update API docs for cucumber-rails v#{cucumber-rails::VERSION}'")
|
|
30
|
-
sh('git push origin master')
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
desc "Generate YARD docs for Cucumber-Rails' API"
|
|
35
|
-
task doc: %i[yard release]
|
|
36
|
-
end
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
Feature: Allow Cucumber to rescue exceptions
|
|
2
|
-
|
|
3
|
-
Background: A controller that raises an exception
|
|
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
|
-
raise 'There is an error in index'
|
|
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
|
-
|
|
20
|
-
Scenario: Allow rescue
|
|
21
|
-
When I write to "features/posts.feature" with:
|
|
22
|
-
"""
|
|
23
|
-
Feature: posts
|
|
24
|
-
@allow-rescue
|
|
25
|
-
Scenario: See posts
|
|
26
|
-
When I look at the posts
|
|
27
|
-
Then I should see the public error page
|
|
28
|
-
"""
|
|
29
|
-
And I write to "features/step_definitions/posts_steps.rb" with:
|
|
30
|
-
"""
|
|
31
|
-
When('I look at the posts') do
|
|
32
|
-
visit '/posts'
|
|
33
|
-
end
|
|
34
|
-
Then('I should see the public error page') do
|
|
35
|
-
expect(page).to have_content "We're sorry, but something went wrong."
|
|
36
|
-
end
|
|
37
|
-
"""
|
|
38
|
-
And I run `bundle exec rake db:migrate`
|
|
39
|
-
And I run `bundle exec cucumber`
|
|
40
|
-
Then the feature run should pass with:
|
|
41
|
-
"""
|
|
42
|
-
1 scenario (1 passed)
|
|
43
|
-
2 steps (2 passed)
|
|
44
|
-
"""
|
|
45
|
-
|
|
46
|
-
Scenario: Don't allow rescue
|
|
47
|
-
When I write to "features/posts.feature" with:
|
|
48
|
-
"""
|
|
49
|
-
Feature: posts
|
|
50
|
-
Scenario: See them
|
|
51
|
-
When I look at the posts
|
|
52
|
-
"""
|
|
53
|
-
And I write to "features/step_definitions/posts_steps.rb" with:
|
|
54
|
-
"""
|
|
55
|
-
When('I look at the posts') do
|
|
56
|
-
visit '/posts'
|
|
57
|
-
end
|
|
58
|
-
"""
|
|
59
|
-
And I run `bundle exec rake db:migrate`
|
|
60
|
-
And I run `bundle exec cucumber`
|
|
61
|
-
Then it should fail with:
|
|
62
|
-
"""
|
|
63
|
-
1 scenario (1 failed)
|
|
64
|
-
1 step (1 failed)
|
|
65
|
-
"""
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
Feature: Annotations
|
|
2
|
-
|
|
3
|
-
I order to track my development progress
|
|
4
|
-
As a developer
|
|
5
|
-
I should be able to list annotations in my features
|
|
6
|
-
|
|
7
|
-
Background:
|
|
8
|
-
Given I have created a new Rails app with no database and installed cucumber-rails
|
|
9
|
-
When I write to "features/tests.feature" with:
|
|
10
|
-
"""
|
|
11
|
-
Feature: Tests
|
|
12
|
-
Scenario: Tests
|
|
13
|
-
# TODO: When I go to the products page
|
|
14
|
-
"""
|
|
15
|
-
|
|
16
|
-
Scenario: See annotations in .feature file
|
|
17
|
-
When I run `bundle exec rake notes`
|
|
18
|
-
Then it should pass with:
|
|
19
|
-
"""
|
|
20
|
-
features/tests.feature:
|
|
21
|
-
* [ 3] [TODO] When I go to the products page
|
|
22
|
-
"""
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
@focus
|
|
2
|
-
Feature: Capybara Javascript Drivers
|
|
3
|
-
|
|
4
|
-
Background: A simple calendar app
|
|
5
|
-
Given I have created a new Rails app and installed cucumber-rails
|
|
6
|
-
And I force selenium to run Firefox in headless mode
|
|
7
|
-
When I run `bundle exec rails g scaffold appointment name:string when:datetime`
|
|
8
|
-
And I write to "features/step_definitions/date_time_steps.rb" with:
|
|
9
|
-
"""
|
|
10
|
-
When('I select {string} as the {string} date and time') do |datetime, selector|
|
|
11
|
-
select_datetime(datetime, from: selector)
|
|
12
|
-
end
|
|
13
|
-
"""
|
|
14
|
-
|
|
15
|
-
Scenario: Use a particular driver
|
|
16
|
-
When I write to "features/create_appointment.feature" with:
|
|
17
|
-
"""
|
|
18
|
-
@javascript
|
|
19
|
-
Feature: Create appointments
|
|
20
|
-
Scenario: Visit the Constitution on May 17
|
|
21
|
-
Given I am on the new appointment page
|
|
22
|
-
And I fill in "Norway's constitution" for "Name"
|
|
23
|
-
And I select "2015-02-20 15:10:00 UTC" as the "When" date and time
|
|
24
|
-
And I press "Create Appointment"
|
|
25
|
-
Then I should see "Norway's constitution"
|
|
26
|
-
And I should see "2015-02-20 15:10:00 UTC"
|
|
27
|
-
"""
|
|
28
|
-
And I run `bundle exec rake db:migrate`
|
|
29
|
-
And I run `bundle exec rake cucumber`
|
|
30
|
-
Then the feature run should pass with:
|
|
31
|
-
"""
|
|
32
|
-
1 scenario (1 passed)
|
|
33
|
-
6 steps (6 passed)
|
|
34
|
-
"""
|
|
35
|
-
|
|
36
|
-
Scenario: Mixed DB access
|
|
37
|
-
When I write to "features/create_appointment.feature" with:
|
|
38
|
-
"""
|
|
39
|
-
@javascript
|
|
40
|
-
Feature: Create appointments
|
|
41
|
-
Scenario: Visit the Constitution on May 17
|
|
42
|
-
Given a random appointment
|
|
43
|
-
And I am viewing a random appointment
|
|
44
|
-
Then I should see "Random appointment"
|
|
45
|
-
"""
|
|
46
|
-
And I write to "features/step_definitions/custom_steps.rb" with:
|
|
47
|
-
"""
|
|
48
|
-
Given('a random appointment') do
|
|
49
|
-
@appointment = Appointment.create!(name: 'Random appointment', when: DateTime.now)
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
Given('I am viewing a random appointment') do
|
|
53
|
-
visit appointment_path(@appointment)
|
|
54
|
-
end
|
|
55
|
-
"""
|
|
56
|
-
And I run `bundle exec rake db:migrate`
|
|
57
|
-
And I run `bundle exec rake cucumber`
|
|
58
|
-
Then the feature run should pass with:
|
|
59
|
-
"""
|
|
60
|
-
1 scenario (1 passed)
|
|
61
|
-
3 steps (3 passed)
|
|
62
|
-
"""
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
Feature: Choose javascript database strategy
|
|
2
|
-
|
|
3
|
-
Whilst running a scenario with the @javascript tag, Capybara will fire up a web server
|
|
4
|
-
in the same process in a separate thread to your cukes. By default, this means ActiveRecord will give it a
|
|
5
|
-
separate database connection, which in turn means data you put into your database from
|
|
6
|
-
Cucumber step definitions (e.g. using FactoryBot) won't be visible to the web server
|
|
7
|
-
until the database transaction is committed.
|
|
8
|
-
|
|
9
|
-
So if you use a transaction strategy for cleaning up your database at the end of a scenario,
|
|
10
|
-
it won't work for javascript scenarios by default.
|
|
11
|
-
|
|
12
|
-
There are two ways around this. One is to switch to a truncation strategy for javascript
|
|
13
|
-
scenarios. This is slower, but more reliable.
|
|
14
|
-
|
|
15
|
-
The alternative is to patch ActiveRecord to share a single database connection between
|
|
16
|
-
threads. This means you still get the speed benefits of using a transaction to roll back
|
|
17
|
-
your database, but you run the risk of the two threads stomping on one another as they
|
|
18
|
-
talk to the database.
|
|
19
|
-
|
|
20
|
-
Right now, the default behavior is to use truncation, but you can override this by telling
|
|
21
|
-
cucumber-rails which strategy to use for javascript scenarios.
|
|
22
|
-
|
|
23
|
-
The deletion strategy can be quicker for situations where truncation causes locks which
|
|
24
|
-
has been reported by some Oracle users.
|
|
25
|
-
|
|
26
|
-
Background:
|
|
27
|
-
Given I have created a new Rails app and installed cucumber-rails
|
|
28
|
-
And I have a "Widget" ActiveRecord model object
|
|
29
|
-
When I write to "features/step_definitions/widget_steps.rb" with:
|
|
30
|
-
"""
|
|
31
|
-
When('I create {int} widgets') do |number|
|
|
32
|
-
number.times { Widget.create! }
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
Then('I should have {int} widgets') do |number|
|
|
36
|
-
expect(Widget.count).to eq(number)
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
Then('the DatabaseCleaner strategy should be {word}') do |strategy_name|
|
|
40
|
-
expect(DatabaseCleaner.connections.first.strategy.to_s).to match(/#{strategy_name}/i)
|
|
41
|
-
end
|
|
42
|
-
"""
|
|
43
|
-
|
|
44
|
-
Scenario: Set the strategy to truncation and run a javascript scenario.
|
|
45
|
-
When I append to "features/env.rb" with:
|
|
46
|
-
"""
|
|
47
|
-
DatabaseCleaner.strategy = :transaction
|
|
48
|
-
Cucumber::Rails::Database.javascript_strategy = :truncation
|
|
49
|
-
"""
|
|
50
|
-
And I write to "features/widgets.feature" with:
|
|
51
|
-
"""
|
|
52
|
-
Feature:
|
|
53
|
-
Background:
|
|
54
|
-
When I create 2 widgets
|
|
55
|
-
|
|
56
|
-
@javascript
|
|
57
|
-
Scenario:
|
|
58
|
-
When I create 3 widgets
|
|
59
|
-
Then the DatabaseCleaner strategy should be truncation
|
|
60
|
-
And I should have 5 widgets
|
|
61
|
-
|
|
62
|
-
@javascript
|
|
63
|
-
Scenario:
|
|
64
|
-
Then the DatabaseCleaner strategy should be truncation
|
|
65
|
-
And I should have 2 widgets
|
|
66
|
-
|
|
67
|
-
Scenario:
|
|
68
|
-
Then the DatabaseCleaner strategy should be transaction
|
|
69
|
-
And I should have 2 widgets
|
|
70
|
-
"""
|
|
71
|
-
And I run the cukes
|
|
72
|
-
Then the feature run should pass with:
|
|
73
|
-
"""
|
|
74
|
-
3 scenarios (3 passed)
|
|
75
|
-
10 steps (10 passed)
|
|
76
|
-
"""
|
|
77
|
-
|
|
78
|
-
Scenario: Set the strategy to deletion and run a javascript scenario.
|
|
79
|
-
When I append to "features/env.rb" with:
|
|
80
|
-
"""
|
|
81
|
-
Cucumber::Rails::Database.javascript_strategy = :deletion
|
|
82
|
-
"""
|
|
83
|
-
And I write to "features/widgets.feature" with:
|
|
84
|
-
"""
|
|
85
|
-
@javascript
|
|
86
|
-
Feature:
|
|
87
|
-
Background:
|
|
88
|
-
When I create 2 widgets
|
|
89
|
-
|
|
90
|
-
Scenario:
|
|
91
|
-
When I create 3 widgets
|
|
92
|
-
Then I should have 5 widgets
|
|
93
|
-
|
|
94
|
-
Scenario:
|
|
95
|
-
Then I should have 2 widgets
|
|
96
|
-
"""
|
|
97
|
-
And I run the cukes
|
|
98
|
-
Then the feature run should pass with:
|
|
99
|
-
"""
|
|
100
|
-
2 scenarios (2 passed)
|
|
101
|
-
5 steps (5 passed)
|
|
102
|
-
"""
|
|
103
|
-
|
|
104
|
-
Scenario: Set the strategy to truncation with an except option and run a javascript scenario.
|
|
105
|
-
When I append to "features/env.rb" with:
|
|
106
|
-
"""
|
|
107
|
-
Cucumber::Rails::Database.javascript_strategy = :truncation, { except: %w[widgets] }
|
|
108
|
-
"""
|
|
109
|
-
And I write to "features/widgets.feature" with:
|
|
110
|
-
"""
|
|
111
|
-
@javascript
|
|
112
|
-
Feature:
|
|
113
|
-
Scenario:
|
|
114
|
-
When I create 3 widgets
|
|
115
|
-
Then I should have 3 widgets
|
|
116
|
-
|
|
117
|
-
Scenario:
|
|
118
|
-
Then I should have 3 widgets
|
|
119
|
-
"""
|
|
120
|
-
And I run the cukes
|
|
121
|
-
Then the feature run should pass with:
|
|
122
|
-
"""
|
|
123
|
-
2 scenarios (2 passed)
|
|
124
|
-
3 steps (3 passed)
|
|
125
|
-
"""
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
Feature: DatabaseCleaner
|
|
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: some widgets
|
|
9
|
-
Given I have 2 widgets
|
|
10
|
-
|
|
11
|
-
Scenario: Add 3
|
|
12
|
-
When I create 3 more widgets
|
|
13
|
-
Then I should have 5 widgets
|
|
14
|
-
|
|
15
|
-
Scenario: Add 7
|
|
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
|
-
"""
|