Skip to content

Instantly share code, notes, and snippets.

@rossta
Created April 8, 2021 10:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rossta/fdb40f2d6c781b569d2bcc53e672d1cb to your computer and use it in GitHub Desktop.
Save rossta/fdb40f2d6c781b569d2bcc53e672d1cb to your computer and use it in GitHub Desktop.
FactoryBot factory for a Hash class (i.e., not an ActiveRecord model)
FactoryBot.define :stripe_customer, class: Hash do
skip_create
initialize_with { new(attributes) }
id { "cus_#{SecureRandom.hex(7)}" }
object { "customer" }
address { nil }
balance { 0 }
created { 1.day.ago.to_i }
currency { "usd" }
email { |n| "customer-#{n}@example.com" }
name { Faker::Name.name }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment