I'm looking at this Gem: https://github.com/stympy/faker
I use it quite a lot, and it is very good, but I don't get why all of its methods are organised into modules:
Faker::Code.isbn #=> "759021701-8"
Faker::Address.longitude #=> "-156.65548382095133"
Faker::Bitcoin.address #=> "1HUoGjmgChmnxxYhz87YytV4gVjfPaExmh"
I have to do this in my factories:
factory :person, class: Person do
name { Faker::Lorem.word }
account { Faker::Bitcoin.address }
address { Faker::Address.longitude }
favourite_book { Faker::Code.isbn }
end
Can I include all of the modules into my test suite so I just need to do this:
factory :person, class: Person do
name { word }
account { address }
address { longitude }
favourite_book { isbn }
end
I'm using rspec:
RSpec.configure do |config|
config.include FactoryGirl::Syntax::Methods
# doesn't work: config.include Faker
end
Why have they bothered separating their methods into separate methods? To make it faster? Surely this is a negligible amount unless you've got an insanely complex project? Wouldn't a better gem just let you do BetterFaker.word
, BetterFaker.address
ect? Be easier to remember :)