cucumber-rails 1.6.0 → 1.7.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.
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License
2
2
 
3
- Copyright (c) 2008,2009,2010,2011,2012,2013 Aslak Hellesøy and the Cucumber Team.
3
+ Copyright (c) 2008-2019 Aslak Hellesøy and the Cucumber Team.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -3,20 +3,22 @@
3
3
  [![Gem Version](https://badge.fury.io/rb/cucumber-rails.svg)](http://badge.fury.io/rb/cucumber-rails)
4
4
  [![Build Status](https://secure.travis-ci.org/cucumber/cucumber-rails.svg?branch=master)](http://travis-ci.org/cucumber/cucumber-rails)
5
5
  [![Code Climate](https://codeclimate.com/github/cucumber/cucumber-rails.svg)](https://codeclimate.com/github/cucumber/cucumber-rails)
6
- [![Dependency Status](https://gemnasium.com/Kosmas/cucumber-rails.svg)](https://gemnasium.com/Kosmas/cucumber-rails)
7
6
  [![Open Source Helpers](https://www.codetriage.com/cucumber/cucumber-rails/badges/users.svg)](https://www.codetriage.com/cucumber/cucumber-rails)
8
7
 
9
- Cucumber-Rails brings Cucumber to Rails 4.x and 5.x. For Rails 3.x support, use version 1.4.5. For Rails 2.3.x support, see the [rails-2.3.x branch](https://github.com/cucumber/cucumber-rails/tree/rails-2.3.x).
8
+ Cucumber-Rails brings Cucumber to Rails 4.2 and Rails 5.x. This gem is also compatible with Rails 6.0+
9
+ but this is currently in a beta phase, so there may be issues.
10
10
 
11
11
  ## Installation
12
12
 
13
13
  Before you can use the generator, add the gem to your project's Gemfile as follows:
14
14
 
15
- group :test do
16
- gem 'cucumber-rails', require: false
17
- # database_cleaner is not required, but highly recommended
18
- gem 'database_cleaner'
19
- end
15
+ ```ruby
16
+ group :test do
17
+ gem 'cucumber-rails', require: false
18
+ # database_cleaner is not required, but highly recommended
19
+ gem 'database_cleaner'
20
+ end
21
+ ```
20
22
 
21
23
  Then install it by running:
22
24
 
@@ -44,9 +46,11 @@ Without Rake:
44
46
 
45
47
  By default, cucumber-rails runs `DatabaseCleaner.start` and `DatabaseCleaner.clean` before and after your scenarios. You can disable this behaviour like so:
46
48
 
47
- # features/support/env.rb
48
- # ...
49
- Cucumber::Rails::Database.autorun_database_cleaner = false
49
+ ```ruby
50
+ # features/support/env.rb
51
+ # ...
52
+ Cucumber::Rails::Database.autorun_database_cleaner = false
53
+ ```
50
54
 
51
55
  ## Upgrading from a previous version
52
56
 
@@ -67,10 +71,12 @@ If you know how to fix the bug yourself, make a second commit (after committing
67
71
 
68
72
  ### Setting up your environment
69
73
 
70
- We strongly recommend that you use `rvm` or `rbenv` and ruby `2.2.0`. When you have that, cd into your cucumber-rails repository and:
74
+ Make sure you have a supported ruby installed, cd into your cucumber-rails repository and:
71
75
 
72
76
  gem install bundler
73
77
  bundle install
78
+ bin/install_geckodriver.sh
79
+ bin/install_webpacker.sh
74
80
 
75
81
  ### Running all tests
76
82
 
@@ -87,7 +93,7 @@ In order to test against multiple versions of key dependencies, the [Appraisal](
87
93
 
88
94
  To run the suite against a named gemfile, use the following:
89
95
 
90
- [bundle exec] appraisal rails_4_1 rake test
96
+ [bundle exec] appraisal rails_4_2 rake test
91
97
 
92
98
  To remove and rebuild the different gemfiles (for example, to update a rails version or its dependencies), use the following:
93
99
 
@@ -105,9 +111,11 @@ To support the multiple-gemfile testing, when adding a new dependency the follow
105
111
 
106
112
  1. If it's a runtime dependency of the gem, add it to the gemspec
107
113
  2. If it's a primary development dependency, add it to the gemspec
108
- 3. If it's a dependency of a generated rails app in a test, add it to the Gemfile (for local test runs) and each appraisal section (if necessary).
114
+ 3. If it's a dependency of a generated rails app in a test, add it to [the helper] that modifies that Gemfile.
109
115
 
110
- For example, rspec is a primary development dependency, so it lives in the gemspec. By contrast, coffee-rails is a dependency of apps generated with rails 3.1 and 3.2, so lives in the main Gemfile and the rails 3.1 and 3.2 appraisal sections.
116
+ For example, rspec is a primary development dependency, so it lives in the gemspec.
117
+
118
+ [the helper]: https://github.com/cucumber/cucumber-rails/blob/5e37c530560ae1c1a79521c38a54bae0be94242b/features/step_definitions/cucumber_rails_steps.rb#L15
111
119
 
112
120
  ### NOTE
113
121
 
@@ -0,0 +1,19 @@
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.23.0/geckodriver-v0.23.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
@@ -0,0 +1,9 @@
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
@@ -12,9 +12,6 @@ opts = [
12
12
  "--format rerun -o #{rerun_file}"
13
13
  ]
14
14
  rails_version = `bundle exec rails --version`.match(/[\d.]+$/).to_s
15
- if Gem::Version.new(rails_version) < Gem::Version.new('4.2')
16
- opts << "--tags 'not @requires-rails-version-42'"
17
- end
18
15
  optlist = opts.join(' ')
19
16
  %>
20
17
  default: <%= path %> <%= optlist %> --tags 'not @broken'
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = 'cucumber-rails'
6
- s.version = '1.6.0'
6
+ s.version = '1.7.0'
7
7
  s.authors = ["Aslak Hellesøy", "Dennis Blöte", "Rob Holland"]
8
8
  s.description = "Cucumber Generator and Runtime for Rails"
9
9
  s.summary = "#{s.name}-#{s.version}"
@@ -12,25 +12,24 @@ Gem::Specification.new do |s|
12
12
 
13
13
  s.license = 'MIT'
14
14
 
15
- s.add_runtime_dependency('capybara', ['>= 1.1.2', '< 4'])
15
+ s.required_ruby_version = '>= 2.2'
16
+
17
+ s.add_runtime_dependency('capybara', ['>= 2.3.0', '< 4'])
16
18
  s.add_runtime_dependency('cucumber', ['>= 3.0.2', '< 4'])
17
19
  s.add_runtime_dependency('nokogiri', '~> 1.8')
18
- s.add_runtime_dependency('railties', ['>= 4', '< 6'])
20
+ s.add_runtime_dependency('railties', ['>= 4.2', '< 7'])
19
21
  s.add_runtime_dependency('mime-types', ['>= 1.17', '< 4'])
20
22
 
21
23
  # Main development dependencies
22
24
  s.add_development_dependency('ammeter', ['>= 1.0.0', '!= 1.1.3'])
23
25
  s.add_development_dependency('appraisal', '>= 0.5.1')
24
26
  s.add_development_dependency('aruba', '~> 0.14.2')
25
- s.add_development_dependency('builder', ['>= 3.1.0', '< 4'])
26
27
  s.add_development_dependency('bundler', '>= 1.3.5')
27
- s.add_development_dependency('selenium-webdriver', '>= 3.4.1')
28
- s.add_development_dependency('database_cleaner', '>= 1.0.0')
29
- s.add_development_dependency('factory_bot', '>= 3.2')
30
- s.add_development_dependency('rake', '>= 0.9.2.2')
31
- s.add_development_dependency('rspec', '~> 3.0')
32
- s.add_development_dependency('rails')
33
- s.add_development_dependency('sqlite3')
28
+ s.add_development_dependency('rubocop', '~> 0.66.0')
29
+ s.add_development_dependency('rake', '>= 10.3')
30
+ s.add_development_dependency('rspec', '~> 3.5')
31
+ s.add_development_dependency('rails', ['>= 4.2', '< 7'])
32
+ s.add_development_dependency('sqlite3', '~> 1.3.13')
34
33
 
35
34
  # For Documentation:
36
35
  s.add_development_dependency('rdiscount', '>= 2.0.7')
@@ -41,6 +40,5 @@ Gem::Specification.new do |s|
41
40
  s.rubygems_version = ">= 1.6.1"
42
41
  s.files = `git ls-files`.split("\n")
43
42
  s.test_files = `git ls-files -- {spec,features}/*`.split("\n")
44
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
45
43
  s.require_path = "lib"
46
44
  end
@@ -1,7 +1,7 @@
1
1
  Feature: Allow Cucumber to rescue exceptions
2
2
 
3
3
  Background: A controller that raises an exception
4
- Given I have created a new Rails app "rails-3-app" and installed cucumber-rails
4
+ Given I have created a new Rails app "rails-app" and installed cucumber-rails
5
5
  And I write to "app/controllers/posts_controller.rb" with:
6
6
  """
7
7
  class PostsController < ApplicationController
@@ -12,7 +12,7 @@ Feature: Allow Cucumber to rescue exceptions
12
12
  """
13
13
  And I write to "config/routes.rb" with:
14
14
  """
15
- Rails3App::Application.routes.draw do
15
+ RailsApp::Application.routes.draw do
16
16
  resources :posts
17
17
  end
18
18
  """
@@ -23,20 +23,24 @@ Feature: Allow Cucumber to rescue exceptions
23
23
  Feature: posts
24
24
  @allow-rescue
25
25
  Scenario: See posts
26
- When I look at the posts
26
+ When I look at the posts
27
+ Then I should see the public error page
27
28
  """
28
29
  And I write to "features/step_definitions/posts_steps.rb" with:
29
30
  """
30
31
  When /^I look at the posts$/ do
31
32
  visit '/posts'
32
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
33
37
  """
34
38
  And I run `bundle exec rake db:migrate`
35
39
  And I run `bundle exec cucumber`
36
40
  Then the feature run should pass with:
37
41
  """
38
42
  1 scenario (1 passed)
39
- 1 step (1 passed)
43
+ 2 steps (2 passed)
40
44
  """
41
45
 
42
46
  Scenario: Don't allow rescue
@@ -1,4 +1,3 @@
1
- @requires-rails-version-42
2
1
  Feature: Annotations
3
2
 
4
3
  I order to track my development progress
@@ -23,7 +23,7 @@ Feature: Emulate Javascript
23
23
  """
24
24
  FactoryBot.define do
25
25
  factory :widget do
26
- name 'testwidget'
26
+ name { 'testwidget' }
27
27
  end
28
28
  end
29
29
  """
@@ -80,7 +80,7 @@ Feature: Emulate Javascript
80
80
  """
81
81
  FactoryBot.define do
82
82
  factory :widget do
83
- name 'testwidget'
83
+ name { 'testwidget' }
84
84
  end
85
85
  end
86
86
  """
@@ -1,7 +1,7 @@
1
1
  Feature: Rails
2
2
  In order to take over the world
3
3
  Cucumber-Rails should work on major versions
4
- of Rails 3 or 4 and Ruby, with Capybara, Spork and DatabaseCleaner
4
+ of Rails and Ruby, with Capybara, Spork and DatabaseCleaner
5
5
 
6
6
  Scenario: Install Cucumber-Rails
7
7
  Given I have created a new Rails app and installed cucumber-rails
@@ -1,7 +1,7 @@
1
1
  Feature: REST API
2
2
 
3
3
  Scenario: Compare JSON
4
- Given I have created a new Rails app "rails-3-app" and installed cucumber-rails
4
+ Given I have created a new Rails app "rails-app" and installed cucumber-rails
5
5
  And I write to "app/controllers/posts_controller.rb" with:
6
6
  """
7
7
  class PostsController < ApplicationController
@@ -12,7 +12,7 @@ Feature: REST API
12
12
  """
13
13
  And I write to "config/routes.rb" with:
14
14
  """
15
- Rails3App::Application.routes.draw do
15
+ RailsApp::Application.routes.draw do
16
16
  resources :posts
17
17
  end
18
18
  """
@@ -8,8 +8,6 @@ module CucumberRailsHelper
8
8
  delete_environment_variable 'RUBYOPT'
9
9
  delete_environment_variable 'BUNDLE_BIN_PATH'
10
10
  delete_environment_variable 'BUNDLE_GEMFILE'
11
-
12
- run_simple 'bundle install'
13
11
  end
14
12
 
15
13
  def install_cucumber_rails(*options)
@@ -18,28 +16,45 @@ module CucumberRailsHelper
18
16
  else
19
17
  gem 'cucumber-rails' , group: :test, require: false, path: "#{File.expand_path('.')}"
20
18
  end
21
- # From Rails 5.1 some gems are already part of the Gemfile
22
- if Gem.loaded_specs['rails'].version < Gem::Version.new('5.1.0')
19
+
20
+ gem 'sqlite3', '~> 1.3.13'
21
+ if RUBY_VERSION < '2.4.0'
22
+ gem 'capybara', '< 3.16.0', group: :test
23
+ else
23
24
  gem 'capybara', group: :test
24
- gem 'selenium-webdriver', group: :test
25
25
  end
26
+ gem 'selenium-webdriver', '~> 3.11', group: :test
26
27
 
27
- gem 'geckodriver-helper', group: :test
28
- gem 'rspec-rails', group: :test
29
- gem 'database_cleaner', group: :test unless options.include?(:no_database_cleaner)
30
- gem 'factory_bot', group: :test unless options.include?(:no_factory_bot)
31
- # Newer versions of rake remove a method used by RSpec older versions
32
- # See https://stackoverflow.com/questions/35893584/nomethoderror-undefined-method-last-comment-after-upgrading-to-rake-11#35893625
33
- if Gem::Version.new(RSpec::Support::Version::STRING) < Gem::Version.new('3.4.4')
34
- gem 'rake', '< 11.0'
35
- run_simple 'bundle update rake --local'
28
+ gem 'rspec-expectations', '~> 3.7', group: :test
29
+ gem 'database_cleaner', '>= 1.1', group: :test unless options.include?(:no_database_cleaner)
30
+ gem 'factory_bot', '>= 3.2', group: :test unless options.include?(:no_factory_bot)
31
+ run_simple 'bundle install'
32
+
33
+ if `bundle exec rails -v`.split("\n").last.strip =~ /\ARails 6\./
34
+ run_simple 'bundle exec rails webpacker:install'
36
35
  end
36
+
37
37
  run_simple 'bundle exec rails generate cucumber:install'
38
38
  end
39
39
 
40
- def gem(name, options)
41
- line = %{gem "#{name}", #{options.inspect}\n}
42
- append_to_file('Gemfile', line)
40
+ def gem(name, *args)
41
+ options = args.last.is_a?(Hash) ? args.pop : {}
42
+
43
+ parts = ["'#{name}'"]
44
+ parts << args.map(&:inspect) if args.any?
45
+ parts << options.inspect[1..-2] if options.any?
46
+
47
+ line = "gem #{parts.join(', ')}\n"
48
+
49
+ gem_regexp = /gem ["']#{name}["'].*$/
50
+ gemfile_content = File.read(expand_path('Gemfile'))
51
+
52
+ if gemfile_content =~ gem_regexp
53
+ gemfile_content.gsub!(gem_regexp, line)
54
+ overwrite_file('Gemfile', gemfile_content)
55
+ else
56
+ append_to_file('Gemfile', line)
57
+ end
43
58
  end
44
59
 
45
60
  def prepare_aruba_report
@@ -98,10 +113,15 @@ end
98
113
  Given /^I force selenium to run Firefox in headless mode$/ do
99
114
  selenium_config = %{
100
115
  Capybara.register_driver :selenium do |app|
116
+ http_client = Selenium::WebDriver::Remote::Http::Default.new
117
+ http_client.read_timeout = 180
118
+
101
119
  browser_options = ::Selenium::WebDriver::Firefox::Options.new()
102
120
  browser_options.args << '--headless'
103
- Capybara::Selenium::Driver.new(app, browser: :firefox, options: browser_options)
121
+ Capybara::Selenium::Driver.new(app, browser: :firefox, options: browser_options, http_client: http_client)
104
122
  end
123
+
124
+ Capybara.server = :webrick
105
125
  }
106
126
 
107
127
  step 'I append to "features/support/env.rb" with:', selenium_config
@@ -120,11 +140,7 @@ Then /^the feature run should pass with:$/ do |string|
120
140
  end
121
141
 
122
142
  Given("I remove the {string} gem from the Gemfile") do |gem_name|
123
- run 'pwd'
124
- app_path = last_command_started.output.strip
125
- gemfile_path = File.join(app_path, 'Gemfile')
126
-
127
- content = File.open(gemfile_path, 'r').readlines
143
+ content = File.open(expand_path('Gemfile'), 'r').readlines
128
144
  new_content = []
129
145
 
130
146
  content.each do |line|
@@ -133,5 +149,5 @@ Given("I remove the {string} gem from the Gemfile") do |gem_name|
133
149
  new_content << line
134
150
  end
135
151
 
136
- overwrite_file(gemfile_path, new_content.join("\r\n"))
137
- end
152
+ overwrite_file('Gemfile', new_content.join("\r\n"))
153
+ end
@@ -2,18 +2,9 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "rails", "~> 4.2.1"
6
5
  gem "railties", "~> 4.2.1"
7
- gem "capybara", "~> 2.0"
8
- gem "selenium-webdriver", "~> 3.4.1"
9
- gem "geckodriver-helper", "~> 0.0.5"
10
- gem "rspec-rails", "~> 3.1.0"
11
- gem "sass-rails", "~> 5.0"
12
- gem "coffee-rails", "~> 4.1.0"
13
- gem "jquery-rails"
14
- gem "uglifier", "~> 2.1.0"
15
- gem "sqlite3", "~> 1.3.7"
16
- gem "database_cleaner", "~> 1.0.1"
17
- gem "rake", "< 11.0"
6
+ gem "i18n", "< 1.5.1", platform: :mri_22
7
+ gem "capybara", "< 3.16.0", platform: [:mri_23, :mri_22]
8
+ gem "nokogiri", "< 1.9.1", platform: [:mri_23, :mri_22]
18
9
 
19
10
  gemspec path: "../"
@@ -2,17 +2,9 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "rails", "~> 5.0.0"
6
5
  gem "railties", "~> 5.0.0"
7
- gem "capybara", "~> 2.7.1"
8
- gem "selenium-webdriver", "~> 3.9.0"
9
- gem "geckodriver-helper", "~> 0.0.5"
10
- gem "rspec-rails", "~> 3.5.0"
11
- gem "sass-rails", "~> 5.0"
12
- gem "coffee-rails", "~> 4.2.0"
13
- gem "jquery-rails"
14
- gem "uglifier", "~> 2.7.2"
15
- gem "sqlite3", "~> 1.3.7"
16
- gem "database_cleaner", ">= 1.1.0"
6
+ gem "i18n", "< 1.5.1", platform: :mri_22
7
+ gem "capybara", "< 3.16.0", platform: [:mri_23, :mri_22]
8
+ gem "nokogiri", "< 1.9.1", platform: [:mri_23, :mri_22]
17
9
 
18
10
  gemspec path: "../"
@@ -2,16 +2,9 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "rails", "~> 5.1.0"
6
5
  gem "railties", "~> 5.1.0"
7
- gem "capybara", "~> 2.7.1"
8
- gem "selenium-webdriver", "~> 3.9.0"
9
- gem "geckodriver-helper", "~> 0.0.5"
10
- gem "rspec-rails", "~> 3.5.0"
11
- gem "sass-rails", "~> 5.0"
12
- gem "coffee-rails", "~> 4.2.0"
13
- gem "uglifier", "~> 3.2.0"
14
- gem "sqlite3", "~> 1.3.13"
15
- gem "database_cleaner", ">= 1.1.0"
6
+ gem "i18n", "< 1.5.1", platform: :mri_22
7
+ gem "capybara", "< 3.16.0", platform: [:mri_23, :mri_22]
8
+ gem "nokogiri", "< 1.9.1", platform: [:mri_23, :mri_22]
16
9
 
17
10
  gemspec path: "../"