Turn your tests into specs****


Controllers

Serializers

Params

Jobs

Commands

Sidekiq

Services

RSpec

Models

Tips and tricks

🏠 HOME








VCR


Guard


Factory Girl

Tips and Tricks

How to Add a Serialized Hash Attribute to a Factory_Girl Definition

To include a hash as an attribute of a factory, use a double brackets or pass it as explicit method argument (inside parenthesis):

factory :account do
  config { { version: 2 } }
  # or
  config({ version: 2 })
end

<aside> <img src="/icons/playback-previous_lightgray.svg" alt="/icons/playback-previous_lightgray.svg" width="40px" />

</aside>

<aside> <img src="/icons/playback-previous_lightgray.svg" alt="/icons/playback-previous_lightgray.svg" width="40px" />

Sidekiq

</aside>

<aside> <img src="/icons/playback-next_lightgray.svg" alt="/icons/playback-next_lightgray.svg" width="40px" /> Tips and tricks

</aside>