I am trying to upgrade my test suite to RSpec 3. After reading the documentation of how to do it I followed all the steps... I have upgraded to 2.99.2 and ran the transpec gem(awesome!) I am left with one deprecation... this:
`require 'rspec-expectations'` is deprecated. Use `require'rspec/expectations'` instead. Called from     /Users/kierancormack/.rbenv/versions/1.9.3-p484/lib/ruby/gems/1.9.1/gems/bundler-1.8.3/lib/bundler/runtime.rb:76:in `require'.
I don't understand what i am supposed to do. I have changed my Gemfile to look like this but it just throws an error. I have required it in my spec_helper.rb but i just can't seem to make it disappear!
Anyone have any suggestions of how to deal with this deprecation?
Thanks
                        
RSpec 2.x provided an
rspec/expectationsfile which simply delegates torequire 'rspec/expectations'. However, the general convention in the ruby community is for dashes in gem names to correspond to a/in the top-level file name -- so most ruby programmers would know that gemx-yshould be required usingx/y. As part of our 3.0 spring cleaning we removed therspec-expectationsfile as it's an unneeded layer of indirection. So, you need to requirerspec/expectationsinstead ofrspec-expectations.In your case, the stack trace makes it look like the
requireis happening inside Bundler. When you useBundler.requireit tries to require a file matching the gem name for each gem in theGemfile. There are good reasons to avoidBundler.requirebut if you're going to use it, the fix here is to add:require => "rspec/expectations"to thegem 'rspec-expectations'line in yourGemfile.Actually, if you're using
rspec-core(on its own, or viarspec-rails), you don't need to requirerspec/expectationsat all;rspec-corewill load it at the appropriate time for you, so you can use:require => falseto prevent bundler from trying to require it.In fact, we can take this a step forward:
rspec-coreandrspec-railsboth depend uponrspec-expectationsso you generally don't need to putrspec-expectationsin yourGemfileat all unless you are doing something special (e.g. trying to use a fork or HEAD from github) or you are using it on its own w/orspec-coreorrspec-rails. So unless you have a specific reason to listrspec-expectationsin yourGemfile, I recommend you remove it.