Skip to content

Instantly share code, notes, and snippets.

@StevenXL
Last active November 4, 2015 19:23
Show Gist options
  • Select an option

  • Save StevenXL/2547df7c126ef32af4cf to your computer and use it in GitHub Desktop.

Select an option

Save StevenXL/2547df7c126ef32af4cf to your computer and use it in GitHub Desktop.
nghborly factory
FactoryGirl.define do
factory :group do
primary_number { Faker::Number.number(3) }
street_name { Faker::Address.street_name }
city_name { Faker::Address.city }
state_abbreviation { Faker::Address.state_abbr }
zipcode { Faker::Address.zip_code }
end
factory :user, aliases: [:candidate, :requester, :responder] do
user_id { Faker::Number.number(15)}
first_name { Faker::Name.first_name }
last_name { Faker::Name.last_name }
email { Faker::Internet.email }
association :group
end
factory :request do
content { Faker::Lorem.paragraph }
association :requester
association :group
trait :has_neighbor do
association :responder
end
trait :fulfilled do
is_fulfilled true
end
trait :created_one_day_ago do
created_at { 1.day.ago }
end
factory :request_with_neighbor, traits: [:has_neighbor]
factory :fulfilled_request , traits: [:has_neighbor, :fulfilled]
factory :day_old_request, traits: [:created_one_day_ago]
end
factory :vote do
association :request
association :candidate
value { [1, -1].sample }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment