Skip to content

Instantly share code, notes, and snippets.

@igkuz
Created March 9, 2019 16:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save igkuz/1ffec2719147713658eeb8044c258b5b to your computer and use it in GitHub Desktop.
Save igkuz/1ffec2719147713658eeb8044c258b5b to your computer and use it in GitHub Desktop.
Define factories with rom-factory
let(:factories) do
ROM::Factory.configure do |config|
config.rom = MAIN_CONTAINER
end
end
before do
factories.define(:post) do |f|
f.url { fake(:internet, :url, 'example.com') }
f.se_post false
f.stats {}
f.association(:company)
end
factories.define(:company) do |f|
f.sequence(:name) {|n| "Company Name #{n}"}
f.domain { "https://#{fake(:internet, :domain_name)}" }
f.state "running"
end
factories.define(with_post: :company) do |f|
f.association(:posts, count: 1)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment