Skip to content

Rebase master to 4-0-dev and fix build #2160

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

Merged
merged 18 commits into from
Aug 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 21 additions & 18 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,20 @@ before_script:

script: "script/run_build 2>&1"

# In order to install old Rubies, we need to use old Ubuntu distibution.
dist: trusty

matrix:
include:
# Rails 6 builds
- rvm: jruby-head
env:
- RAILS_VERSION=6-0-stable
- RAILS_VERSION='~>6.0'
- JRUBY_OPT=--dev
- rvm: 2.6.3
env: RAILS_VERSION=6-0-stable
- rvm: 2.5.3
env: RAILS_VERSION=6-0-stable
env: RAILS_VERSION='~>6.0'
- rvm: 2.5.5
env: RAILS_VERSION='~>6.0'

# Rails 5.2 builds >= 2.2.2
- rvm: jruby-head
Expand All @@ -51,43 +54,43 @@ matrix:
- JRUBY_OPT=--dev
- rvm: 2.6.3
env: RAILS_VERSION='~> 5.2.0'
- rvm: 2.5.3
- rvm: 2.5.5
env: RAILS_VERSION='~> 5.2.0'
- rvm: 2.4.4
- rvm: 2.4.6
env: RAILS_VERSION='~> 5.2.0'
- rvm: 2.3.7
- rvm: 2.3.8
env: RAILS_VERSION='~> 5.2.0'

# Rails 5.1 Builds >= 2.2.2
- rvm: 2.6.3
env: RAILS_VERSION='~> 5.1.0'
- rvm: 2.5.3
- rvm: 2.5.5
env: RAILS_VERSION='~> 5.1.0'
- rvm: 2.4.4
- rvm: 2.4.6
env: RAILS_VERSION='~> 5.1.0'
- rvm: 2.3.7
- rvm: 2.3.8
env: RAILS_VERSION='~> 5.1.0'

# Rails 5.0 Builds >= 2.2.2
- rvm: 2.6.3
env: RAILS_VERSION='~> 5.0.0'
- rvm: 2.5.3
- rvm: 2.5.5
env: RAILS_VERSION='~> 5.0.0'
- rvm: 2.4.4
- rvm: 2.4.6
env: RAILS_VERSION='~> 5.0.0'
- rvm: 2.3.7
- rvm: 2.3.8
env: RAILS_VERSION='~> 5.0.0'

# Rails 4.2 Builds >= 1.9.3
- rvm: 2.5.3
- rvm: 2.5.5
env: RAILS_VERSION='~> 4.2.0'
- rvm: 2.4.4
- rvm: 2.4.6
env: RAILS_VERSION='~> 4.2.0'
- rvm: 2.4.4
- rvm: 2.4.6
env: RAILS_VERSION=4-2-stable
- rvm: 2.3.7
- rvm: 2.3.8
env: RAILS_VERSION='~> 4.2.0'
- rvm: 2.3.7
- rvm: 2.3.8
env: RAILS_VERSION=4-2-stable

fast_finish: true
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Enhancements
making it easier to match on `ActiveJob` delivered emails. (Joel Lubrano, #2047)
* Add generator for system specs on Rails 5.1 and above. (Andrzej Sliwa, #1933)
* Add generator for generator specs. (@ConSou, #2085)
* Add option to generate routes when generating controller specs. (David Revelo, #2134)

### 3.8.2 / 2019-01-13
[Full Changelog](http://github.com/rspec/rspec-rails/compare/v3.8.1...v3.8.2)
Expand Down
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ end

if MAJOR >= 6
gem 'sqlite3', '~> 1.4', platforms: [:ruby]
gem 'selenium-webdriver', '~> 3.5', :require => false
else
gem 'sqlite3', '~> 1.3.6', platforms: [:ruby]
end
Expand All @@ -56,7 +57,7 @@ end

gem "rubyzip", '~> 1.2'

gem 'rubocop'
gem 'rubocop', "~> 0.74"

custom_gemfile = File.expand_path("../Gemfile-custom", __FILE__)
eval_gemfile custom_gemfile if File.exist?(custom_gemfile)
Expand Down
7 changes: 6 additions & 1 deletion Gemfile-rails-dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,10 @@ else
if version >= '5-1-stable' && RUBY_VERSION >= "2.3"
gem "puma"
end
gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]

if ENV['RAILS_VERSION'].gsub(/[^\d\.]/,'').to_f >= 6.0
gem "activerecord-jdbcsqlite3-adapter", "~> 60.0.rc1", platforms: [:jruby]
else
gem 'activerecord-jdbcsqlite3-adapter', platforms: [:jruby]
end
end
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Use **[`rspec-rails` 1.x][]** for Rails 2.x.

[Build Status]: https://secure.travis-ci.org/rspec/rspec-rails.svg?branch=master
[travis-ci]: https://travis-ci.org/rspec/rspec-rails
[Code Climate]: https://img.shields.io/codeclimate/github/rspec/rspec-rails.svg
[Code Climate]: https://codeclimate.com/github/rspec/rspec-rails.svg
[code-climate]: https://codeclimate.com/github/rspec/rspec-rails
[Gem Version]: https://badge.fury.io/rb/rspec-rails.svg
[gem-version]: https://badge.fury.io/rb/rspec-rails
Expand Down
3 changes: 2 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file was generated on 2019-04-01T20:23:57+02:00 from the rspec-dev repo.
# This file was generated on 2019-07-24T15:33:53+02:00 from the rspec-dev repo.
# DO NOT modify it by hand as your changes will get lost the next time it is generated.

version: "{build}"
Expand Down Expand Up @@ -39,3 +39,4 @@ environment:
- ruby_version: 23-x64
- ruby_version: 24-x64
- ruby_version: 25-x64
- ruby_version: 26-x64
6 changes: 5 additions & 1 deletion example_app_generator/generate_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@
if RUBY_VERSION < "2.4"
gsub_file "Gemfile", /.*capybara.*/, "gem 'capybara', '~> 3.15.0'"
end
gsub_file "Gemfile", /.*chromedriver-helper.*/, "gem 'webdrivers'"
if Rails::VERSION::STRING >= "5.2.0" && RUBY_VERSION < '2.3.0'
gsub_file "Gemfile", /.*chromedriver-helper.*/, "gem 'webdrivers', '< 4.0.0'"
else
gsub_file "Gemfile", /.*chromedriver-helper.*/, "gem 'webdrivers'"
end
end

if Rails::VERSION::STRING >= '5.2.0' && Rails::VERSION::STRING < '6'
Expand Down
22 changes: 11 additions & 11 deletions features/Transactions.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ simply tell RSpec to tell Rails not to manage transactions:
config.use_transactional_fixtures = false
end

### Data created in `before(:each)` are rolled back
### Data created in `before(:example)` are rolled back

Any data you create in a `before(:each)` hook will be rolled back at the end of
Any data you create in a `before(:example)` hook will be rolled back at the end of
the example. This is a good thing because it means that each example is
isolated from state that would otherwise be left around by the examples that
already ran. For example:

describe Widget do
before(:each) do
before(:example) do
@widget = Widget.create
end

Expand All @@ -48,34 +48,34 @@ The `@widget` is recreated in each of the two examples above, so each example
has a different object, _and_ the underlying data is rolled back so the data
backing the `@widget` in each example is new.

### Data created in `before(:all)` are _not_ rolled back
### Data created in `before(:context)` are _not_ rolled back

`before(:all)` hooks are invoked before the transaction is opened. You can use
`before(:context)` hooks are invoked before the transaction is opened. You can use
this to speed things up by creating data once before any example in a group is
run, however, this introduces a number of complications and you should only do
this if you have a firm grasp of the implications. Here are a couple of
guidelines:

1. Be sure to clean up any data in an `after(:all)` hook:
1. Be sure to clean up any data in an `after(:context)` hook:

before(:all) do
before(:context) do
@widget = Widget.create!
end

after(:all) do
after(:context) do
@widget.destroy
end

If you don't do that, you'll leave data lying around that will eventually
interfere with other examples.

2. Reload the object in a `before(:each)` hook.
2. Reload the object in a `before(:example)` hook.

before(:all) do
before(:context) do
@widget = Widget.create!
end

before(:each) do
before(:example) do
@widget.reload
end

Expand Down
118 changes: 118 additions & 0 deletions rfcs/versioning-strategy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# RFC: RSpec Rails new versioning strategy

Hi Folks,

This RFC captures a proposal for RSpec Rails' new versioning strategy. Specifically, this represents two things:
* A change in representation of what we use SemVer for, in RSpec Rails
* A departure from RSpec Rails having the same versioning as RSpec's other gems (-core, -mocks, -expectations, and, internally, -support).

## Need

Currently, the RSpec Rails [build matrix](https://travis-ci.org/rspec/rspec-rails)
has 63 entries. This permutes rubies since 1.8.7 and Rails versions since 3.0.
As of right now the full build takes over an hour to run, and this makes cycling
for PRs and quick iterative development very difficult.

RSpec Rails's code itself also is damaged by this. Everything from the Gemfile
setup[1](https://github.com/rspec/rspec-rails/blob/1d2935861c89246236b46f77de753cda5ea67d61/Gemfile)
[2](https://github.com/rspec/rspec-rails/blob/1d2935861c89246236b46f77de753cda5ea67d61/Gemfile-rails-dependencies)
[3](https://github.com/rspec/rspec-rails/blob/1d2935861c89246236b46f77de753cda5ea67d61/Gemfile-rspec-dependencies),
to the [library code](https://github.com/rspec/rspec-rails/blob/1d2935861c89246236b46f77de753cda5ea67d61/lib/rspec/rails/configuration.rb#L128-L143),
to the [test setup](https://github.com/rspec/rspec-rails/blob/1d2935861c89246236b46f77de753cda5ea67d61/Rakefile#L29-L53),
to the [tests themselves](https://github.com/rspec/rspec-rails/blob/1d2935861c89246236b46f77de753cda5ea67d61/spec/rspec/rails/example/job_example_group_spec.rb)
contain conditional execution based on which Rails version is currently loaded.
This makes ongoing maintenance difficult, as it requires that RSpec Rails'
maintainers be conscious of every Rails version that might be loaded.
Acknowledging that, patches still sometimes break people's suites, due to the
number of permutations of gems that can be loaded.

Our need is therefore best characterised by cost of maintenance. Having to
maintain several versions of Rails and Ruby costs us a lot. It makes our
development slower, and forces us to write against Rails versions that most
people no longer use. I want RSpec Rails development to be fast, and
lightweight, much like it was when I joined the RSpec project.

## Approach

The approach to fix this is an adjustment of versioning strategy. RSpec Rails
will still continue to maintain a SemVer strategy, that is:

* Breaking changes in Majors
* New features in Minors
* Bug Fixes in Patchlevels

For the purposes of this versioning strategy, we consider removing a Rails or
Ruby version to be a breaking change. We consider adding a Ruby or Rails version
to be a Minor, along with normal feature releases.

The intent, however, is to change the cycle of these releases to align with
Rails. Specifically, a Rails release cycle typically looks like:

* Release a Major X.0, (X-2).0 is no longer supported, all but the most recent
(X--1) series are unsupported, introduces deprecation warnings for many
features
* Release a Minor X.1, deprecation warnings from X.0 are now errors
* Release a Minor X.2, new features are added, some further deprecation warnings
from X.1 may now be broken.

As such, RSpec Rails's new versioning strategy will be:

* Release a major with any Rails Major, removing support for any newly
unsupported versions of Rails, and adding support for the new major.
* Release a minor with any Rails Minor, adding support for the new features
* Additionally, release minors for any new RSpec features
* Release patchlevels frequently, as bugfixes occur.

As to the transition to this strategy: it is my intent to move to this strategy
along with releasing support for Rails 5.2 for RSpec Rails, so relatively soon,
dropping support for anything below Rails 4.2, and any Rubies below 2.2. This
means that RSpec Rails 4.0.0 will be released within a handful of months from
this RFC being accepted.

I do expect this to mean that the major version of RSpec Rails will increment
relatively quickly with comparison to the rest of RSpec. I do not think that is
necessarily a bad thing, it does not mean that the library is unstable as such,
but rather that we are tracking our dependencies accurately.

Traditionally, RSpec Rails has been versioned at the same version number as
RSpec. This will represent a departure from that. In order to maintain
compatibility, RSpec Rails will continue to support the RSpec 3 series, and will
probably add support for RSpec 4 without breaking changes. To do this, I intend
to move off RSpec Rails using any private APIs from RSpec.

## Benefits

Execution of this strategy will greatly increase our ability to maintain RSpec,
and release against modern Rails versions. While RSpec has been very stable and
essentially continuously expanded Rails version support for the last few years,
this has now become unsustainable and we want to take this tradeoff to best
serve the needs of the community.

## Competition

### Do nothing

If we do this, it will become deeply unsustainable for us to maintain RSpec
Rails in the future. We have too many Rails versions today, and we expect the
rate of Rails releases to increase as time goes on. As such, it is our intent to
start dropping Rails versions inline with Rails, in order to continue to improve
the RSpec Rails gem.

### Keep inline versioning with RSpec

RSpec has a materially different versioning need to Rails. Specifically, RSpec
as of today is a mostly entirely stable library. It's development needs are
largely as feature proposals occur, or as bugs are found. RSpec has no external
forces pushing versioning pressure on it (other than say, ruby and bundler,
which are themselves, relatively stable). This is not true of RSpec Rails, which
is popular, and there is a general expectation that RSpec will work with Rails
applications, as of right now, we typically lag behind a Rails release by weeks
when a Rails version gets released.

## Conclusions

It is my intent to ship this change relatively soon, inline with Rails 5.2
support in the next few months. I really do think this represents the best
future tradeoff for RSpec. If you strongly believe that dropping support for
Rails versions lower than 4.2 will affect your needs, please do let us know so
that we can consider the full weight of your use case.
2 changes: 1 addition & 1 deletion script/clone_all_rspec_repos
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# This file was generated on 2019-04-01T20:23:57+02:00 from the rspec-dev repo.
# This file was generated on 2019-07-24T15:33:53+02:00 from the rspec-dev repo.
# DO NOT modify it by hand as your changes will get lost the next time it is generated.

set -e
Expand Down
6 changes: 2 additions & 4 deletions script/downgrade_bundler_on_old_rails
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ if ruby -e "exit(ENV['RAILS_VERSION'].scan(/\d+\.\d+.\d+/)[0].to_f < 5)"; then

gem uninstall -aIx bundler || echo "Warning error occured removing bundler via gem"

# this only works on Ruby 2.3 which is luckily the version we need to fix
if is_ruby_23; then
rvm @global do gem uninstall -aIx bundler
fi
# Delete all bundler version because we do not support Bundler 2+ below Rails 4
rvm @global do gem uninstall -aIx bundler || true

gem install bundler -v '1.17.3'
fi
2 changes: 1 addition & 1 deletion script/functions.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file was generated on 2019-04-01T20:23:57+02:00 from the rspec-dev repo.
# This file was generated on 2019-07-24T15:33:53+02:00 from the rspec-dev repo.
# DO NOT modify it by hand as your changes will get lost the next time it is generated.

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
Expand Down
2 changes: 1 addition & 1 deletion script/predicate_functions.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file was generated on 2019-04-01T20:23:57+02:00 from the rspec-dev repo.
# This file was generated on 2019-07-24T15:33:53+02:00 from the rspec-dev repo.
# DO NOT modify it by hand as your changes will get lost the next time it is generated.

function is_mri {
Expand Down
2 changes: 1 addition & 1 deletion script/run_build
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# This file was generated on 2019-04-01T20:23:57+02:00 from the rspec-dev repo.
# This file was generated on 2019-07-24T15:33:53+02:00 from the rspec-dev repo.
# DO NOT modify it by hand as your changes will get lost the next time it is generated.

set -e
Expand Down
2 changes: 1 addition & 1 deletion script/travis_functions.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file was generated on 2019-04-01T20:23:57+02:00 from the rspec-dev repo.
# This file was generated on 2019-07-24T15:33:53+02:00 from the rspec-dev repo.
# DO NOT modify it by hand as your changes will get lost the next time it is generated.

# Taken from:
Expand Down
2 changes: 1 addition & 1 deletion script/update_rubygems_and_install_bundler
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
# This file was generated on 2019-04-01T20:23:57+02:00 from the rspec-dev repo.
# This file was generated on 2019-07-24T15:33:53+02:00 from the rspec-dev repo.
# DO NOT modify it by hand as your changes will get lost the next time it is generated.

set -e
Expand Down