myabc / merb_mart

DEVELOPMENT DISCONTINUED: Consider using Spree (repo: http://github.com/railsdog/spree) instead.

This URL has Read+Write access

commit  42a37524004c92b1b0288bb5403f57bd855834c0
tree    bcd59fe46604d273951f0132248abcce75aacdce
parent  4a76b9902c4077eeb41a6ad2971a6e11e5a9ed41
merb_mart / spec / spec_fixtures.rb
100644 80 lines (66 sloc) 1.766 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
Account.fixture {{
  :address => Address.gen
}}
 
Address.fixture {{
  :first_name => Random.word(:max => 50),
  :last_name => Random.word(:max => 50),
  :address1 => Random.address,
  :postal_code => "%05d" % rand(100_000) + "-%04d" % rand([0, 1_000].random),
  :company => (1..4).random.of {Random.word(:max => 25)}.join(' '),
  :telephone => Random.phone_number,
  :address2 => Random.address,
  :city => Random.word(:max => 50),
  :country => country = Country.gen,
  :state => State.gen(:country => country)
}}
 
Country.fixture {{
  :code => Random.country_code,
  :name => Random.word(:max => 100, :unique => true)
}}
 
Customer.fixture {{
  :username => Random.word(:max => 50, :unique => true)
}}
 
Item.fixture {{
 
}}
 
LineItem.fixture {{
  :quantity => rand(10),
  :unit_price => rand * rand(1_000)
}}
 
Order.fixture {{
  :order_number => rand(100_000),
  :shipping_cost => rand(10),
  :product_cost => rand(10),
  :tax => rand(10),
  :line_items => (1..10).of {LineItem.gen},
  :shipping_info => ShippingInfo.gen,
  :customer => Customer.gen
}}
 
Product.fixture {{
  :name => Random.word,
  :code => "%010d" % rand(1_000_000),
  :date_available => Time.now,
  :is_discontinued => Random.boolean
}}
 
ShippingInfo.fixture {{
  :name => Random.word
}}
 
State.fixture {{
  :country => Country.gen,
  :name => name = Random.word,
  :abbr => name[0, 10]
}}
 
Transaction.fixture {{
  :order => Order.gen,
  :account => Account.gen
}}
 
Upload.fixture {{
  :location => Tempfile.new(Random.word).path
}}
 
User.fixture {{
  :username => Random.word(:unique => true)
}}
 
Weight.fixture {{
  :min_weight => rand(10),
  :max_weight => rand(10),
  :price => rand(10)
}}