Jeroen van Baarsen

March 23, 2015
Upcoming changes in Rails 5.0

This post was originally posted on buildtoship.com by me.

RailsConf is around the corner, that means a new major Rails version is also waiting to be released! In this article, I want to talk about some of the noticeable changes that are confirmed to be in the new version. I will also talk about some changes that are not yet merged but have a high chance of being merged.

No more typing rake commands

In Rails 5 all the current rake commands will be accessible via the rails command. When you want to run a migration, you will type rake db:migrate in Rails 4. In Rails 5 this will become rails db:migrate.

The reason for this change is that currently it’s not very logical which command has to go through rake and which command should go through rails. When you’re working with rails for a longer time it becomes second nature, but only because you remember it. For a newcomer, this is a big problem and makes learning rails confusing.

Status: Proposed https://github.com/rails/rails/issues/18878

Restart your app with a rake command

You can now restart all of your apps with the command rake restart

Status: Merged https://github.com/rails/rails/pull/19169

Deprecation of assigns() and assert_template in controller tests

In Rails 5.0 the test helpers assigns() and assert_template will be deprecated. This does not mean you can’t use them anymore. But you have to keep in mind that they will probably be removed in a later version of rails.

The reasoning about this deprecation is that testing for instance variables and what template is being called in a controller is a bad idea, those are internals of that controller and the controller tests should not care about what ivars are being set. The controller test should be concerned about what cookies are being set, what the HTTP code was and maybe what mutations have happened in the database.

But now you might be thinking: How can I test if the correct values are being set? Well, probably your app will return a status code 500 when certain important ivars are not set. So when you test for correct HTTP status code, you’re covered!

DHH even speaks about the possibility to remove controller test altogether and use Integration tests instead. source

Status: Proposed https://github.com/rails/rails/pull/19058

Ruby 2.2.1 support only

Rails will only support Ruby 2.2.1 and up. Since it wants to be able to leverage all the speed improvements in the newer ruby versions.

They skipped version 2.2.0 since it has a segfault bug source.

Status: Merged https://github.com/rails/rails/pull/19257

Much much more

Rails 5 will contain much more performance boosts and other great new features. When more information is available, we will blog about them again! If you want to be kept up to date, you can follow us on Twitter or sign up for our newsletter below.

If you have any questions, contact me on Twitter @jvanbaarsen or email me at hi@jvanbaarsen.com