Last Updated: February 25, 2016
·
583
· otobrglez

Simplify specs with matchers and methods

You want your specs to be short and sweet. Sometimes some libs provide custom matchers and helpers that can make your "testing life" easy.

let(:user) { FactoryGirl.build :user }
let(:other_user) { FactoryGirl.create :other_user }

After extending your RSpec.configure block with some methods.

RSpec.configure do
  config.include FactoryGirl::Syntax::Methods
  ...
end

You can just write.

let(:user) { build :user }
let(:other_user) { create :other_user }