Today I Learned

A Hashrocket project

Ready to join Hashrocket? Find Openings here and apply today.

RSpec Specify

There are more ways to create a test block with RSpec than it. One is specify, and you can use it to make your tests more readable. Consider this block:

describe 'doing everything' do

  it 'in space' do
    # actions
  end

The sentence ‘it in space’ is awkward. You can replace it with ‘specify’, which brings us very close to a grammatically correct sentence. This is Ruby after all; we try to make it readable.

describe 'doing everything' do

  specify 'in space' do
    # actions
  end