Move any non-Rails RSpec configurations and customizations from yourrails_helper.rb to spec_helper.rb.

Find/replace instances of require 'spec_helper' withrequire 'rails_helper' in any specs which rely on Rails.

File-type inference disabled by default

Previously we automatically inferred spec type from a file location, this
was a surprising behaviour for new users and undesirable for some veteran users
so from RSpec 3 onwards this behaviour must be explicitly opted into with:

RSpec.configure do |config|
config.infer_spec_type_from_file_location!
end

This change was made to accomplish our general goals of acting with the principle
of least surprise and making RSpec configuration more explicit. See the directory structure documentation for more details.

Rails 4.x ActiveRecord::Migration pending migration checks

If you are not using ActiveRecord you do not need to worry about these
settings.

Users of Rails 4.x can now take advantage of improved schema migration and sync
abilities. Prior to RSpec 3, users were required to manually run migrations in
both the development and test environments. Additionally, the behavior differed
depending on if the specs were run via rake or via the standalone rspec
command.

With the release of Rails 4, new APIs have been exposed onActiveRecord::Migration. This allows RSpec to take advantage of these new
standard migration checks, mirroring behavior across the board.

Rails 4.0.x

Add the following to the top of the rails_helper file after Rails has
been required:

ActiveRecord::Migration.check_pending!

This will raise an exception if there are any pending schema changes. Users
will still be required to manually keep the development and test
environments in sync.

Rails 4.1+

With this release there was an exciting new feature. Users no longer need
to keep the development and test environments in sync. To take advantage of
this add the following to the top of the rails_helper file after Rails
has been required:

ActiveRecord::Migration.maintain_test_schema!

What this does is that rather than just raising when the test schema has
pending migrations, Rails will try to load the schema. An exception will
now only be raised if there are pending migrations afterwards the schema
has been loaded.

There are a few caveates to be aware of when using this:

Migrations still need to be run manually; although now this only has to
be done in the 'development' environment

An exception will be raised If the schema has not been initialized. The
exception will provide instructions stating rake db:migrate needs to
be run.

It is possible to opt-out of checking for pending migrations. Since this is
actually a feature of Rails, the change needs to be done as part of the Rails
configuration. To do this, add the following to yourconfig/environments/test.rb file:

config.active_record.maintain_test_schema = false

New RSpec projects don't need to worry about these commands as the rails
generate rspec:install will add them automatically.

Historically, stub_model and mock_model have been difficult to maintain.
They are tightly coupled to ActiveRecord which isn't always the ORM of choice.
This maintainence coupling has lead to delays with previous releases.
Additionally, the objects generated by these methods hide importantActiveRecord behavior complexity which would otherwise be good to expose.

Some alternatives are:

Wrap calls to ActiveRecord objects in more specific domain models and
services