Skip to content

3.6.0 release post #105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
May 5, 2017
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 118 additions & 0 deletions source/blog/2017-04-27-rspec-3-6-has-been-released.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
---
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget to update the date in the filename!

title: RSpec 3.6 has been released!
author: Sam Phippen, TODO: other editors
---

RSpec 3.6 has just been released! Given our commitment to
[semantic versioning](http://semver.org/), this should be an easy
upgrade for anyone already using RSpec 3, but if we did introduce
any regressions, please let us know, and we'll get a patch release
out with a fix ASAP.

RSpec continues to be a community-driven project with contributors
from all over the world. This release includes over XXX commits and YYY
merged pull requests from over 50 different contributors!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's funny that you have the contributor count filled in but not the commits and PRs! Usually I fill this in after generating the stats as it is based on that.


Thank you to everyone who helped make this release happen!

## Notable Changes

### Core: Errors outside examples now handled and formatted well

In previous versions of RSpec, we allowed errors encountered while loading spec
files or running `:suite` hooks to crash the ruby interpreter, giving you its
default full-stacktrace output. In RSpec 3.6, we now handle all errors that
occur outside examples, and format them nicely including a filtered backtrace
and a code snippet for the site of the error. For example, an error in a
`before(:suite)` hook is now formatted like this:

<img width="479" alt="screen shot 2017-04-27 at 9 59 12 pm"
src="https://cloud.githubusercontent.com/assets/49391/25514870/cb9db6c8-2b94-11e7-952f-f26fd783512b.png">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better to add the image to this repository instead of hotlinking to github's CDN? Ultimately, the site is hosted on github, of course, but there's something nice about keeping the image under source control, too...


Thanks to Jon Rowe for assisting with this feature.

### Core: `config.fail_if_no_examples`

As it currently stands RSpec will exit with code `0` indicating success if no
examples are defined. This configuration option makes it possible to cause RSpec
to exit with code `1` indicating failure. This is useful in CI environments, it
helps detect when you've misconfigured RSpec to look for specs in the wrong
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"it helps detect" reads like it's the start of a new sentence. If you want to keep it as one sentence, I think it helps to add a connecting word like "as":

This is useful in CI environments, as it helps detect...

place or with the wrong pattern. When this occurs we consider finding no specs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When this occurs

What is the "this" here? Do you mean when RSpec is misconfigured to look for example in the wrong place? Or when the user has configured it with config.fail_if_no_examples = true? Both are needed for the rest of the statement to be true but this sentence doesn't really explain that.

to being an error, as opposed to always passing.

~~~ ruby
RSpec.configure do |config|
config.fail_if_no_examples = true
end
~~~

A special thanks to Ewa Czechowska for getting this in to core.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before moving on to the expectations changes, there's one more notable core changes, IMO: color is automatically enabled if RSpec is outputting to a TTY, so there's no longer a need to set --color to opt-in to this behavior. If you really want color (even if the output isn't a TTY), you can pass --force-color, or --no-color to disable color output. Can you add a section on that?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

### Core: Output coloring is set automatically if RSpec is outputting to a tty.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for spelling "color" the American way :).


In past versions of RSpec, you were required to specify `--color` if you wanted
output coloring, regardless of whether you were outputting to a terminal, a
file, a CI system, or some other output location. Now, RSpec will automatically
color output if it detects it is running in a TTY. You can still force coloring
with `--color`, or if you are running in a TTY and explicitly do not want color,
you can specify `--no-color` to disable this behavior.

For existing RSpec projects, that were initialized with either `bundle exec
rspec --init` or `bundle exec rails g rspec:install` you can find this setting
in your `.rspec` file if you'd like to change it.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need this paragraph. The existing setting (--color) is a no-op in 3.6 as the behavior it enables is the default now. So the setting is effectively ignored, and the user can set --force-color or --no-color in whatever fashion they want, without regard for where --color may have been set previously.


We thank Josh Justice for adding this behavior to RSpec.

### Expectations: Scoped aliased and negative matchers

TODO: is anyone more familiar with this feature who could full this out?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically, the idea is that you can now call alias_matcher or define_negated_matcher in an example group to limit the scope of the newly defined matchers to just that group, rather than them being defined globally for use from all groups.


### Mocks: `without_partial_double_verification`

When we released RSpec 3.0 we added [verifying doubles](http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#verifying-doubles).
Verifying doubles allow you to ensure that stubs and mocks that you create with
RSpec correctly emulate the interfaces on the objects in your tests.
`without_partial_double_verification` allows you to turn off the verifying
double behaviour for the duration of the execution of a block. For example:

~~~ ruby
class Widget
def call(takes_an_arg)
end
end

RSpec.describe Widget do
it 'can be stub with a mismatched arg count' do
without_partial_double_verification {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why curlies here instead of do/end?

w = Widget.new
allow(w).to receive(:call).with(1, 2).and_return(3)
w.call(1, 2)
}
end
end
~~~

Here, this test would fail if the `without_partial_double_verification` call was
not made, because we are stubbing the `call` method on the `Widget` object with
an argument count that is different to the implementation. This can be useful in
situations where methods aren't already defined on the object, like in Rails,
when methods on `ActiveRecord` objects are defined after database interactions.
With this feature, we can test interfaces to those objects while retaining
database isolation.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed for AR objects? I didn't think it helped then. (And in fact, I thought @JonRowe implemented some stuff for ActiveRecord models to make their dynamic nature cause no problems for verified doubles). Isn't the situation where this is needed helper specs or view specs or something? @JonRowe can you help here so we can accurately explain when this API is useful?


A special thanks to Jon Rowe for adding this feature.

### Rails: Support for Rails 5.1:

RSpec 3.6.0 comes with full support for Rails 5.1. There are no major changes to
the rails 5.1 API and so this upgrade should be fully smooth. Simply bumping to
the latest version of RSpec will bring the support to your app with no other
changes required on your part.

Rails [system tests](http://weblog.rubyonrails.org/2017/4/27/Rails-5-1-final/) are not yet supported,
but we plan to add support for them in the near future.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are system tests any different from feature specs w/ capybara?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only in that they're "blessed" and use a specific non-forked process server (run with puma) that allows for transactional testing.



## Stats:

TODO when ready to release
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To generate this, run rake "version_stats[v3.5.0...v3.6.0]" in rspec-dev once you've tagged all the repos with v3.6.0.

Also, we usually include a Docs section and a Release Notes section in these blog posts (take a look at the 3.5 or 3.4 posts for an example).

For the release notes, we have an rspec-dev task (release_notes) to assist. That said, it would be good to combine the release notes from all 3.6 betas here, which I don't think it does. Maybe you can combine those by hand as I did for the 3.5 blog post?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍