Posted 6 months ago. Visible to the public.

RSpec expects pending tests to fail

When flagging a spec that will be implemented later as pending, include a failing spec body or RSpec 3 will consider the pending test as failing.

The reasoning is: If the spec is flagged as pending but passes, it should not be pending. So these will fail:

Copy
it 'does something' do pending end it 'does something else' do pending expect(1).to eq(1) end

The first case may be unexpected, if you just wanted to write down that something should eventually happen that will be implemented later.

Instead, do not supply a spec body at all:

Copy
it 'does something'

Or, if your body contains something that you want to keep, you may add fail to cause an error. RSpec will then consider the spec pending.

Copy
it 'does something' do pending # This will be interesting. Contact Bob about details. fail end

Another way to exlude specs is using RSpec filters with xit, xdescribe or the like.

makandra has been working exclusively with Ruby on Rails since 2007. Our laser focus on a single technology has made us a leader in this space.

Owner of this card:

Avatar
Arne Hartherz
Last edit:
5 months ago
by Daniel Straßner
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Arne Hartherz to makandra dev
This website uses cookies to improve usability and analyze traffic.
Accept or learn more