rspec-rails 3 deprecation warnings scripts and fixes

Upon upgrading to rspec 2.99.0, I began to receive deprecation warnings for several things that had issues, and to do a few updates:

Because the project was using its syntax and stub_model I needed to add that functionality back into rspec in the :test group of my Gemfile:

  # Support for its syntax
  gem 'rspec-its', '~> 1.0.1’

  # Support for stubbing model in view specs:
  gem 'rspec-activemodel-mocks', '~> 1.0.1'

On top of that I had to do substitutions for be_true, be_false, and_return with block syntax, and change pending to skip for a few pending tests.

I was able to run the following find + sed commands for each of these (note that the .original part is Mac-specific):

find . -name '*.rb' -exec sed -i .original 's/be_true/be_truthy/g' {} +
find . -name '*.rb' -exec sed -i .original 's/be_false/be_falsey/g' {} +
find . -name '*.rb' -exec sed -i .original 's/and_return[ ]*{[ ]*[ ]*}/and_return(\1)/g' {} +
find . -name '*.rb' -exec sed -i .original 's/^pending /skip /g' {} +

I haven't completely foolproofed the last two regexes, so I'd make sure to have your work committed for each set of substitutions (and to make sure rspec still passes your tests, of course.)

And the cleanup:

find . -name '*original' -exec rm {} +

Lastly, to quiet the remaining deprecation warnings that I had, I added this to my spec_helper.rb:

Rspec.configure do |config|
# other config code
#
  config.mock_with :rspec do |mocks|
    mocks.yield_receiver_to_any_instance_implementation_blocks = true
  end

  config.infer_spec_type_from_file_location!
  config.raise_errors_for_deprecations!
#
# other config code
end

This configuration, as I understand it, will be standard with 3.0:

  mocks.yield_receiver_to_any_instance_implementation_blocks = true

This setting is required for 2.99 because you will unconditionally get a deprecation warning even if you set the type...

 
  config.infer_spec_type_from_file_location!

And I wanted to raise an error for any other deprecation warnings:

  config.raise_errors_for_deprecations!

After all the dust had settled from 2.99, I upgraded rspec-rails to 3.0.0 and did a bundle update:

  gem 'rspec-rails', '~> 3.0.0' # Test framework

I've unearthed a few deprecation warnings about :should syntax, which I expect to update later.

One misleading deprecation warning:

Requiring `rspec/autorun` when running RSpec via the `rspec` command is deprecated. Called from /Users/tpowell/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activesupport-4.1.1/lib/active_support/dependencies.rb:247:in `require'.

...was actually due to having require 'rspec/autorun' in my spec_helper.rb