|
| 1 | +RSpec 3 includes many breaking changes, but our hope is to make this the smoothest |
| 2 | +major-version gem upgrade you've ever done. To assist with that process, we've developed |
| 3 | +RSpec 2.99 in tandem with RSpec 3. Every breaking change in 3.0 has a corresponding |
| 4 | +deprecation to 2.99. Rather than just giving you a generic upgrade document that describes |
| 5 | +_all_ of the breaking changes (most of which affect very few users!), RSpec 2.99 gives you a |
| 6 | +detailed upgrade checklist tailored to your project. |
| 7 | + |
| 8 | +In addition, [Yuji Nakayama](https://twitter.com/nkym37) has created [Transpec](http://yujinakayama.me/transpec/) -- an absolutely amazing tool that can |
| 9 | +automatically upgrade most RSpec suites. We've tried it on a few projects and have been _amazed_ at how well it works. |
| 10 | + |
| 11 | +## Step-by-step Instructions |
| 12 | + |
| 13 | +1. Ensure your test suite is already green on whatever RSpec 2.x version |
| 14 | + you're already using. |
| 15 | +2. Install RSpec 2.99. |
| 16 | +3. Run your test suite and ensure it's still green. (It should be, but |
| 17 | + we may have made a mistake -- if it breaks anything, please report |
| 18 | + a bug!). Now would be a good time to commit. |
| 19 | +4. You'll notice a bunch of deprecation warnings printed off at the |
| 20 | + end of the spec run. These may be truncated since we don't to |
| 21 | + spam you with the same deprecation warning over and over again. To |
| 22 | + get the full list of deprecations, you can pipe them into a file |
| 23 | + by passing the `--deprecation-out path/to/file` option. |
| 24 | +5. If you want to understand all of what is being deprecated, it's a |
| 25 | + good idea to read through the deprecation messages. In some cases, |
| 26 | + you have choices -- such as continuing to use the `have` collection |
| 27 | + cardinality matchers via the extracted |
| 28 | + [rspec-collection_matchers](https://github.com/rspec/rspec-collection_matchers) |
| 29 | + gem, or by rewriting the expectation expression to something like |
| 30 | + `expect(list.size).to eq(3)`. |
| 31 | +6. `gem install transpec` (Note that this need not go into your |
| 32 | + `Gemfile`: you run `transpec` as a standalone executable |
| 33 | + outside the context of your bundle). |
| 34 | +7. Run transpec on your project. Check `transpec --help` or |
| 35 | + [the README](https://github.com/yujinakayama/transpec#transpec) |
| 36 | + for a full list of options. |
| 37 | +8. Run the test suite (it should still be green but it's always good to |
| 38 | + check!) and commit. |
| 39 | +9. If there are any remaining deprecation warnings (transpec doesn't |
| 40 | + quite handle all of the warnings you may get), deal with them. |
| 41 | +9. Once you've got a deprecation-free test suite running against RSpec |
| 42 | + 2.99, you're ready to upgrade to RSpec 3. Install RSpec 3. |
| 43 | +10. Run your test suite. It should still be green. If anything fails, |
| 44 | + please open a Github issue -- we consider it a bug! Note |
| 45 | + that you may still get a few additional deprecation warnings on |
| 46 | + RSpec 3 that weren't present on 2.99. This is normal -- there are |
| 47 | + a few things we couldn't easily deprecate in 2.99 and remove in 3.0, |
| 48 | + so they trigger deprecations in 3.0 with the plan to remove them in |
| 49 | + RSpec 4. |
| 50 | +11. We recommend running `transpec` a second time. There are some |
| 51 | + changes that transpec is only able to make when your project is on |
| 52 | + RSpec 3. |
| 53 | +12. Commit and enjoy using the latest RSpec release! |
0 commit comments