5 require 'can_has_fixtures'
7 # Add the dependency in a before_app_loads hook
8 Merb::BootLoader.before_app_loads { require(File.join(File.dirname(__FILE__), '..', 'lib', 'merb-E-mart')) }
10 DataMapper.setup(:default, 'sqlite3::memory:')
11 DataMapper.auto_migrate!
13 # Using Merb.root below makes sure that the correct root is set for
14 # - testing standalone, without being installed as a gem and no host application
15 # - testing from within the host application; its root will be used
16 Merb.start_environment(
19 :environment => ENV['MERB_ENV'] || 'test',
20 :merb_root => Merb.root
27 # The absolute path to the current slice
28 def current_slice_root
29 @current_slice_root ||= File.expand_path(File.join(File.dirname(__FILE__), '..'))
32 # Whether the specs are being run from a host application or standalone
41 Spec::Runner.configure do |config|
42 config.include(Merb::Test::ViewHelper)
43 config.include(Merb::Test::RouteHelper)
44 config.include(Merb::Test::ControllerHelper)
45 config.include(Merb::Test::SliceHelper)
49 :first_name => Random.word(:max => 50),
50 :last_name => Random.word(:max => 50),
51 :address1 => Random.address,
52 :postal_code => "%05d" % rand(100_000) + "-%04d" % rand([0, 1_000].random),
53 :company => (1..4).random.of {Random.word(:max => 25)}.join(' '),
54 :telephone => Random.phone_number,
55 :address2 => Random.address,
56 :city => Random.word(:max => 50),
57 :country => country = Country.gen,
58 :state => State.gen(:country => country)
62 :code => 2.of {('a'..'z').random}.to_s,
63 :name => Random.word(:max => 100, :unique => true)
67 :country => Country.gen,
68 :name => name = Random.word,
74 "#{rand(100_000)} #{word(:max => 75)} #{%w[st rd ln ave pkwy].random}"
78 "#{(100..999).random}-#{(100..999).random}-#{(0..9999).random}"