fun with merb -i and dm-sweatshop

# in spec/fixtures.rb
# of course these are just examples of what the content could look like
User.fix {{
  :login => /\w+/.gen,
  :password => (password = /\w{12}/.gen),
  :password_confirmation => password
}}

GeoPoint.fix {{
  :lat => BigDecimal.new((rand * 180 -  90).to_s),
  :lng => BigDecimal.new((rand * 360 - 180).to_s),
}}

Location.fix {{
  :geo_point => unique { GeoPoint.gen },
  :name => /\w+/.gen,
  :short_description => /\w+/.gen,
  :long_description => /\w+/.gen,
  :address => /\w+/.gen
}}

20.times { Location.gen }

# in config/init.rb
Merb::BootLoader.after_app_loads do

  # This will get executed after your app's classes have been loaded.

  if Merb.env == "development"
    # allows for easy playin around in merb -i
    # dm-sweatshop will provide enough data for that
    require Merb.root / "spec" / "spec_fixtures"
  end

end


Leave a Reply

Formatting: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>