Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Rails 5.2 & Capybara 3 support. #378

Merged
merged 32 commits into from Apr 20, 2018
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
416c543
Relax railites to allow version 5.2.
gobijan Apr 12, 2018
3bbb2a2
Add gemfile for rails 5.2.
gobijan Apr 12, 2018
238c391
Update 5.2 gemspec dependencies to latest available ones. Allow railt…
gobijan Apr 12, 2018
6100eb4
Make travis use latest ruby releases.
gobijan Apr 12, 2018
10084a9
Remove Ruby 2.2 from tests => EOL.
gobijan Apr 12, 2018
685413c
Bump version to 1.6 (because removing EOL Ruby 2.2)
gobijan Apr 12, 2018
dc6a590
Add rails 5.2 to appraisals.
gobijan Apr 12, 2018
937d44c
Bump geckodriver-helper version to 0.0.5
Apr 17, 2018
1ef3b51
Relax railites to allow version 5.2.
gobijan Apr 12, 2018
0775efb
Add gemfile for rails 5.2.
gobijan Apr 12, 2018
8362a27
Update 5.2 gemspec dependencies to latest available ones. Allow railt…
gobijan Apr 12, 2018
a6b99ea
Make travis use latest ruby releases.
gobijan Apr 12, 2018
bd504a6
Remove Ruby 2.2 from tests => EOL.
gobijan Apr 12, 2018
4cd9f63
Bump version to 1.6 (because removing EOL Ruby 2.2)
gobijan Apr 12, 2018
3b88c6b
Add rails 5.2 to appraisals.
gobijan Apr 12, 2018
e942fd1
factory_girl -> factory_bot
Apr 17, 2018
4502e05
Fix other occurrences of factory_girl
Apr 18, 2018
8b47a03
Merge branch 'master' into master
gobijan Apr 18, 2018
cfcd0ea
Merge pull request #1 from radar/master
gobijan Apr 18, 2018
286f37f
Make click_with_javascript_emulation take any args
Apr 19, 2018
f11ad2d
install the latest version of firefox
Apr 19, 2018
6f83768
Report geckodriver version before running tests
Apr 19, 2018
c1a6626
Fixed bootsnap issues on Rails 5.2
xtrasimplicity Apr 19, 2018
32ba8db
Merge pull request #6 from xtrasimplicity/BugFix/FixingBootsnapIssues
gobijan Apr 20, 2018
8300612
Merge pull request #5 from radar/use-latest-firefox
gobijan Apr 20, 2018
4763fde
Merge pull request #4 from radar/click-with-js-emulation-args
gobijan Apr 20, 2018
8fb4040
Switched back to new hash key assignment syntax.
xtrasimplicity Apr 20, 2018
1a85e85
Re-added support for Ruby 2.2
xtrasimplicity Apr 20, 2018
dee9b75
Switched aruba dependency back to "strict" versioning ('~>' rather th…
xtrasimplicity Apr 20, 2018
eab831a
CI: force failed `geckodriver -V` commands to retry once.
xtrasimplicity Apr 20, 2018
9731f9b
Revert CI: force failed `geckodriver -V` commands to retry once. (eab…
xtrasimplicity Apr 20, 2018
c480e62
Fixed RSpec versioning
xtrasimplicity Apr 20, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 12 additions & 8 deletions .travis.yml
@@ -1,16 +1,20 @@
rvm:
- 2.2.9
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest keeping this, as cucumber-rails still is using Ruby 2.2. If Rails 5.2 requires higher, then I suggest excluding it below in .travis.yml.

- 2.3.6
- 2.4.3
- 2.5.0
- 2.3.7
- 2.4.4
- 2.5.1
- ruby-head

addons:
firefox: latest

# whitelist
branches:
only:
- master

gemfile:
- gemfiles/rails_5_2.gemfile
- gemfiles/rails_5_1.gemfile
- gemfiles/rails_5_0.gemfile
- gemfiles/rails_4_2.gemfile
Expand All @@ -20,15 +24,14 @@ gemfile:
matrix:
fast_finish: true
exclude:
- rvm: 2.4.3
- rvm: 2.4.4
gemfile: gemfiles/rails_4_0.gemfile
- rvm: 2.4.3
- rvm: 2.4.4
gemfile: gemfiles/rails_4_1.gemfile
- rvm: 2.5.0
- rvm: 2.5.1
gemfile: gemfiles/rails_4_0.gemfile
- rvm: 2.5.0
- rvm: 2.5.1
gemfile: gemfiles/rails_4_1.gemfile

- rvm: ruby-head
gemfile: gemfiles/rails_4_0.gemfile
- rvm: ruby-head
Expand All @@ -37,3 +40,4 @@ matrix:
- rvm: ruby-head

before_install: gem update --remote bundler
before_script: geckodriver -V
24 changes: 19 additions & 5 deletions Appraisals
Expand Up @@ -4,7 +4,7 @@ appraise "rails_4_0" do
gem "railties", "~> 4.0.0"
gem "capybara", "~> 2.0"
gem "selenium-webdriver", "~> 3.4.1"
gem "geckodriver-helper", "~> 0.0.4"
gem "geckodriver-helper", "~> 0.0.5"
gem "turn", "~> 0.9.6"
gem "test-unit", '~> 3.1.5'
gem "rspec-rails", "~> 3.1.0"
Expand All @@ -23,7 +23,7 @@ appraise "rails_4_1" do
gem "railties", "~> 4.1.0"
gem "capybara", "~> 2.0"
gem "selenium-webdriver", "~> 3.4.1"
gem "geckodriver-helper", "~> 0.0.4"
gem "geckodriver-helper", "~> 0.0.5"
gem "rspec-rails", "~> 3.1.0"
gem "sass-rails", "~> 4.0.0"
gem "coffee-rails", "~> 4.0.0"
Expand All @@ -39,7 +39,7 @@ appraise "rails_4_2" do
gem "railties", "~> 4.2.1"
gem "capybara", "~> 2.0"
gem "selenium-webdriver", "~> 3.4.1"
gem "geckodriver-helper", "~> 0.0.4"
gem "geckodriver-helper", "~> 0.0.5"
gem "rspec-rails", "~> 3.1.0"
gem "sass-rails", "~> 5.0"
gem "coffee-rails", "~> 4.1.0"
Expand All @@ -55,7 +55,7 @@ appraise "rails_5_0" do
gem "railties", "~> 5.0.0"
gem "capybara", "~> 2.7.1"
gem "selenium-webdriver", "~> 3.9.0"
gem "geckodriver-helper", "~> 0.0.4"
gem "geckodriver-helper", "~> 0.0.5"
gem "rspec-rails", "~> 3.5.0"
gem "sass-rails", "~> 5.0"
gem "coffee-rails", "~> 4.2.0"
Expand All @@ -71,7 +71,7 @@ appraise "rails_5_1" do
gem "railties", "~> 5.1.0"
gem "capybara", "~> 2.7.1"
gem "selenium-webdriver", "~> 3.9.0"
gem "geckodriver-helper", "~> 0.0.4"
gem "geckodriver-helper", "~> 0.0.5"
gem "rspec-rails", "~> 3.5.0"
gem "sass-rails", "~> 5.0"
gem "coffee-rails", "~> 4.2.0"
Expand All @@ -80,3 +80,17 @@ appraise "rails_5_1" do
# Rails 5 requires database cleaner 1.1
gem "database_cleaner", ">= 1.1.0"
end

appraise "rails_5_2" do
gem "rails", "~> 5.2"
gem "railties", "~> 5.2"
gem "capybara", "~> 3"
gem "selenium-webdriver", "~> 3.11"
gem "geckodriver-helper", "~> 0.0.5"
gem "rspec-rails", "~> 3.7"
gem "sass-rails", "~> 5.0"
gem "coffee-rails", "~> 4.2.0"
gem "uglifier", "~> 4.1"
gem "sqlite3", "~> 1.3.13"
gem "database_cleaner", ">= 1.1"
end
12 changes: 6 additions & 6 deletions cucumber-rails.gemspec
Expand Up @@ -3,7 +3,7 @@ $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)

Gem::Specification.new do |s|
s.name = 'cucumber-rails'
s.version = '1.5.0'
s.version = '1.6.0'
s.authors = ["Aslak Hellesøy", "Dennis Blöte", "Rob Holland"]
s.description = "Cucumber Generator and Runtime for Rails"
s.summary = "#{s.name}-#{s.version}"
Expand All @@ -12,10 +12,10 @@ Gem::Specification.new do |s|

s.license = 'MIT'

s.add_runtime_dependency('capybara', ['>= 1.1.2', '< 3'])
s.add_runtime_dependency('capybara', ['>= 1.1.2', '< 4'])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also resolves @Kosmas' request here: #375 (comment) 👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

s.add_runtime_dependency('cucumber', ['>= 3.0.2', '< 4'])
s.add_runtime_dependency('nokogiri', '~> 1.5')
s.add_runtime_dependency('railties', ['>= 4', '< 5.2'])
s.add_runtime_dependency('nokogiri', '~> 1.8')
s.add_runtime_dependency('railties', ['>= 4', '< 6'])
s.add_runtime_dependency('mime-types', ['>= 1.17', '< 4'])

# Main development dependencies
Expand All @@ -26,9 +26,9 @@ Gem::Specification.new do |s|
s.add_development_dependency('bundler', '>= 1.3.5')
s.add_development_dependency('selenium-webdriver', '>= 3.4.1')
s.add_development_dependency('database_cleaner', '>= 1.0.0')
s.add_development_dependency('factory_girl', '>= 3.2')
s.add_development_dependency('factory_bot', '>= 3.2')
s.add_development_dependency('rake', '>= 0.9.2.2')
s.add_development_dependency('rspec', '~> 3.0')
s.add_development_dependency('rspec', '~> 3')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will allow RSpec 4, which is probably not what you want.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should become ~> 3.0 again to avoid allowing rspec 4 automatically when it arrives.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woops. I'll fix that now - thanks @mvz!

s.add_development_dependency('rails')
s.add_development_dependency('sqlite3')

Expand Down
2 changes: 1 addition & 1 deletion features/choose_javascript_database_strategy.feature
Expand Up @@ -3,7 +3,7 @@ Feature: Choose javascript database strategy
When running a scenario with the @javascript tag, Capybara will fire up a web server
in the same process in a separate thread to your cukes. By default, this means ActiveRecord will give it a
separate database connection, which in turn means data you put into your database from
Cucumber step definitions (e.g. using FactoryGirl) won't be visible to the web server
Cucumber step definitions (e.g. using FactoryBot) won't be visible to the web server
until the database transaction is committed.

So if you use a transaction strategy for cleaning up your database at the end of a scenario,
Expand Down
10 changes: 5 additions & 5 deletions features/emulate_javascript.feature
Expand Up @@ -16,12 +16,12 @@ Feature: Emulate Javascript
And I write to "features/step_definitions/s.rb" with:
"""
Given /^there is a widget named "([^"]*)"$/ do |name|
FactoryGirl.create(:widget, name: name)
FactoryBot.create(:widget, name: name)
end
"""
And I write to "features/support/factories.rb" with:
"""
FactoryGirl.define do
FactoryBot.define do
factory :widget do
name 'testwidget'
end
Expand Down Expand Up @@ -73,12 +73,12 @@ Feature: Emulate Javascript
And I write to "features/step_definitions/s.rb" with:
"""
Given /^there is a widget named "([^"]*)"$/ do |name|
FactoryGirl.create(:widget, name: name)
FactoryBot.create(:widget, name: name)
end
"""
And I write to "features/support/factories.rb" with:
"""
FactoryGirl.define do
FactoryBot.define do
factory :widget do
name 'testwidget'
end
Expand All @@ -91,4 +91,4 @@ Feature: Emulate Javascript
1 scenario (1 passed)
8 steps (8 passed)
"""

15 changes: 2 additions & 13 deletions features/no_database.feature
Expand Up @@ -26,19 +26,8 @@ Feature: No Database
"""
require 'cucumber/rails'
"""
# Remove DatabaseCleaner and SQLite
And I write to "Gemfile" with:
"""
source 'http://rubygems.org'
gem 'rails'
gem "cucumber-rails", group: :test, path: "../../.."
gem "capybara", group: :test
gem "rspec-rails", group: :test
if RUBY_VERSION >= '2.0.0'
gem 'sass-rails'
gem 'uglifier'
end
"""
And I remove the 'database_cleaner' gem from the Gemfile
And I remove the 'sqlite' gem from the Gemfile
And I write to "app/controllers/posts_controller.rb" with:
"""
class PostsController < ApplicationController
Expand Down
24 changes: 20 additions & 4 deletions features/step_definitions/cucumber_rails_steps.rb
Expand Up @@ -27,7 +27,7 @@ def install_cucumber_rails(*options)
gem 'geckodriver-helper', group: :test
gem 'rspec-rails', group: :test
gem 'database_cleaner', group: :test unless options.include?(:no_database_cleaner)
gem 'factory_girl', group: :test unless options.include?(:no_factory_girl)
gem 'factory_bot', group: :test unless options.include?(:no_factory_bot)
# Newer versions of rake remove a method used by RSpec older versions
# See https://stackoverflow.com/questions/35893584/nomethoderror-undefined-method-last-comment-after-upgrading-to-rake-11#35893625
if Gem::Version.new(RSpec::Support::Version::STRING) < Gem::Version.new('3.4.4')
Expand Down Expand Up @@ -78,14 +78,14 @@ def fixture(path)

Given /^I have created a new Rails app with no database and installed cucumber-rails$/ do
rails_new args: '--skip-active-record'
install_cucumber_rails :no_database_cleaner, :no_factory_girl
install_cucumber_rails :no_database_cleaner, :no_factory_bot
overwrite_file('features/support/env.rb', "require 'cucumber/rails'\n")
create_web_steps
end

Given /^I have created a new Rails app "(.*?)" with no database and installed cucumber\-rails$/ do |app_name|
rails_new name: app_name, args: '--skip-active-record'
install_cucumber_rails :no_database_cleaner, :no_factory_girl
install_cucumber_rails :no_database_cleaner, :no_factory_bot
overwrite_file('features/support/env.rb', "require 'cucumber/rails'\n")
create_web_steps
end
Expand All @@ -100,7 +100,6 @@ def fixture(path)
Capybara.register_driver :selenium do |app|
browser_options = ::Selenium::WebDriver::Firefox::Options.new()
browser_options.args << '--headless'

Capybara::Selenium::Driver.new(app, browser: :firefox, options: browser_options)
end
}
Expand All @@ -119,3 +118,20 @@ def fixture(path)
step 'the exit status should be 0'
step 'the output should contain:', string
end

Given("I remove the {string} gem from the Gemfile") do |gem_name|
run 'pwd'
app_path = last_command_started.output.strip
gemfile_path = File.join(app_path, 'Gemfile')

content = File.open(gemfile_path, 'r').readlines
new_content = []

content.each do |line|
next if line =~ /gem ["|']#{gem_name}["|'].*/

new_content << line
end

overwrite_file(gemfile_path, new_content.join("\r\n"))
end
2 changes: 1 addition & 1 deletion gemfiles/rails_4_0.gemfile
Expand Up @@ -7,7 +7,7 @@ gem "rails", "~> 4.0.0"
gem "railties", "~> 4.0.0"
gem "capybara", "~> 2.0"
gem "selenium-webdriver", "~> 3.4.1"
gem "geckodriver-helper", "~> 0.0.4"
gem "geckodriver-helper", "~> 0.0.5"
gem "turn", "~> 0.9.6"
gem "test-unit", "~> 3.1.5"
gem "rspec-rails", "~> 3.1.0"
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rails_4_1.gemfile
Expand Up @@ -7,7 +7,7 @@ gem "rails", "~> 4.1.0"
gem "railties", "~> 4.1.0"
gem "capybara", "~> 2.0"
gem "selenium-webdriver", "~> 3.4.1"
gem "geckodriver-helper", "~> 0.0.4"
gem "geckodriver-helper", "~> 0.0.5"
gem "rspec-rails", "~> 3.1.0"
gem "sass-rails", "~> 4.0.0"
gem "coffee-rails", "~> 4.0.0"
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rails_4_2.gemfile
Expand Up @@ -6,7 +6,7 @@ gem "rails", "~> 4.2.1"
gem "railties", "~> 4.2.1"
gem "capybara", "~> 2.0"
gem "selenium-webdriver", "~> 3.4.1"
gem "geckodriver-helper", "~> 0.0.4"
gem "geckodriver-helper", "~> 0.0.5"
gem "rspec-rails", "~> 3.1.0"
gem "sass-rails", "~> 5.0"
gem "coffee-rails", "~> 4.1.0"
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rails_5_0.gemfile
Expand Up @@ -6,7 +6,7 @@ gem "rails", "~> 5.0.0"
gem "railties", "~> 5.0.0"
gem "capybara", "~> 2.7.1"
gem "selenium-webdriver", "~> 3.9.0"
gem "geckodriver-helper", "~> 0.0.4"
gem "geckodriver-helper", "~> 0.0.5"
gem "rspec-rails", "~> 3.5.0"
gem "sass-rails", "~> 5.0"
gem "coffee-rails", "~> 4.2.0"
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rails_5_1.gemfile
Expand Up @@ -6,7 +6,7 @@ gem "rails", "~> 5.1.0"
gem "railties", "~> 5.1.0"
gem "capybara", "~> 2.7.1"
gem "selenium-webdriver", "~> 3.9.0"
gem "geckodriver-helper", "~> 0.0.4"
gem "geckodriver-helper", "~> 0.0.5"
gem "rspec-rails", "~> 3.5.0"
gem "sass-rails", "~> 5.0"
gem "coffee-rails", "~> 4.2.0"
Expand Down
17 changes: 17 additions & 0 deletions gemfiles/rails_5_2.gemfile
@@ -0,0 +1,17 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "rails", "~> 5.2"
gem "railties", "~> 5.2"
gem "capybara", "~> 3.0"
gem "selenium-webdriver", "~> 3.11"
gem "geckodriver-helper", "~> 0.0.5"
gem "rspec-rails", "~> 3.7"
gem "sass-rails", "~> 5.0"
gem "coffee-rails", "~> 4.2"
gem "uglifier", "~> 4.1"
gem "sqlite3", "~> 1.3.13"
gem "database_cleaner", ">= 1.6.2"

gemspec path: "../"
2 changes: 1 addition & 1 deletion lib/cucumber/rails/capybara/javascript_emulation.rb
Expand Up @@ -9,7 +9,7 @@ def self.included(base)
end
end

def click_with_javascript_emulation
def click_with_javascript_emulation(*)
if link_with_non_get_http_method?
::Capybara::RackTest::Form.new(driver, js_form(element_node.document, self[:href], emulated_method)).submit(self)
else
Expand Down