I need to generate random latitude and longitude values in my factories for testing, but using Random
class gives me duplicate values and make my tests fail, how can I generate random float values in FactoryGirl
?
EDIT: the relevant piece of code
factory :location do
lat rand(-90.0..90.0)
lng rand(-180.0..180.0)
end
Use the faker gem.
factory :address do
latitude { Faker::Address.latitude }
longitude { Faker::Address.longitude }
end
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments