machinist 1.0.6 → 2.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. data/.gitignore +3 -2
  2. data/Gemfile +8 -0
  3. data/MIT-LICENSE +2 -1
  4. data/README.markdown +39 -271
  5. data/Rakefile +22 -14
  6. data/lib/generators/machinist/install/USAGE +2 -0
  7. data/lib/generators/machinist/install/install_generator.rb +48 -0
  8. data/lib/generators/machinist/install/templates/blueprints.rb +9 -0
  9. data/lib/generators/machinist/install/templates/machinist.rb.erb +10 -0
  10. data/lib/generators/machinist/model/model_generator.rb +13 -0
  11. data/lib/machinist.rb +11 -105
  12. data/lib/machinist/active_record.rb +8 -93
  13. data/lib/machinist/active_record/blueprint.rb +41 -0
  14. data/lib/machinist/active_record/lathe.rb +24 -0
  15. data/lib/machinist/blueprint.rb +89 -0
  16. data/lib/machinist/exceptions.rb +32 -0
  17. data/lib/machinist/lathe.rb +69 -0
  18. data/lib/machinist/machinable.rb +97 -0
  19. data/lib/machinist/shop.rb +52 -0
  20. data/lib/machinist/warehouse.rb +36 -0
  21. data/spec/active_record_spec.rb +100 -169
  22. data/spec/blueprint_spec.rb +74 -0
  23. data/spec/exceptions_spec.rb +20 -0
  24. data/spec/inheritance_spec.rb +104 -0
  25. data/spec/machinable_spec.rb +101 -0
  26. data/spec/shop_spec.rb +94 -0
  27. data/spec/spec_helper.rb +4 -6
  28. data/spec/support/active_record_environment.rb +65 -0
  29. data/spec/warehouse_spec.rb +24 -0
  30. metadata +52 -40
  31. data/.autotest +0 -7
  32. data/FAQ.markdown +0 -18
  33. data/VERSION +0 -1
  34. data/init.rb +0 -2
  35. data/lib/machinist/blueprints.rb +0 -25
  36. data/lib/machinist/data_mapper.rb +0 -83
  37. data/lib/machinist/object.rb +0 -30
  38. data/lib/machinist/sequel.rb +0 -62
  39. data/lib/sham.rb +0 -77
  40. data/machinist.gemspec +0 -72
  41. data/spec/data_mapper_spec.rb +0 -134
  42. data/spec/db/.gitignore +0 -1
  43. data/spec/db/schema.rb +0 -20
  44. data/spec/log/.gitignore +0 -1
  45. data/spec/machinist_spec.rb +0 -190
  46. data/spec/sequel_spec.rb +0 -146
  47. data/spec/sham_spec.rb +0 -95
data/spec/sham_spec.rb DELETED
@@ -1,95 +0,0 @@
1
- require File.dirname(__FILE__) + '/spec_helper'
2
- require 'sham'
3
-
4
- describe Sham do
5
- it "should ensure generated values are unique" do
6
- Sham.clear
7
- Sham.half_index {|index| index/2 }
8
- values = (1..10).map { Sham.half_index }
9
- values.should == (0..9).to_a
10
- end
11
-
12
- it "should generate non-unique values when asked" do
13
- Sham.clear
14
- Sham.coin_toss(:unique => false) {|index| index % 2 == 1 ? 'heads' : 'tails' }
15
- values = (1..4).map { Sham.coin_toss }
16
- values.should == ['heads', 'tails', 'heads', 'tails']
17
- end
18
-
19
- it "should generate more than a dozen values" do
20
- Sham.clear
21
- Sham.index {|index| index }
22
- values = (1..25).map { Sham.index }
23
- values.should == (1..25).to_a
24
- end
25
-
26
- it "should generate the same sequence of values after a reset" do
27
- Sham.clear
28
- Sham.random { rand }
29
- values1 = (1..10).map { Sham.random }
30
- Sham.reset
31
- values2 = (1..10).map { Sham.random }
32
- values2.should == values1
33
- end
34
-
35
- it "should alias reset with reset(:before_all)" do
36
- Sham.clear
37
- Sham.random { rand }
38
- values1 = (1..10).map { Sham.random }
39
- Sham.reset(:before_all)
40
- values2 = (1..10).map { Sham.random }
41
- values2.should == values1
42
- end
43
-
44
- it "should generate the same sequence of values after each reset(:before_each)" do
45
- Sham.clear
46
- Sham.random { rand }
47
- values1 = (1..10).map { Sham.random }
48
- Sham.reset(:before_each)
49
- values2 = (1..10).map { Sham.random }
50
- Sham.reset(:before_each)
51
- values3 = (1..10).map { Sham.random }
52
- values2.should_not == values1
53
- values3.should == values2
54
- end
55
-
56
- it "should generate a different sequence of values after reset(:before_all) followed by reset(:before_each)" do
57
- Sham.clear
58
- Sham.random { rand }
59
- (1..10).map { Sham.random }
60
- Sham.reset(:before_each)
61
- values1 = (1..10).map { Sham.random }
62
- Sham.reset(:before_all)
63
- (1..5).map { Sham.random }
64
- Sham.reset(:before_each)
65
- values2 = (1..10).map { Sham.random }
66
- values2.should_not == values1
67
- end
68
-
69
- it "should die when it runs out of unique values" do
70
- Sham.clear
71
- Sham.limited {|index| index%10 }
72
- lambda {
73
- (1..100).map { Sham.limited }
74
- }.should raise_error(RuntimeError)
75
- end
76
-
77
- it "should allow over-riding the name method" do
78
- Sham.clear
79
- Sham.name {|index| index }
80
- Sham.name.should == 1
81
- end
82
-
83
- describe "define method" do
84
- it "should repeat messages in its block to Sham" do
85
- block = Proc.new {}
86
- Sham.should_receive(:name).with(&block).once.ordered
87
- Sham.should_receive(:slug).with(:arg, &block).once.ordered
88
- Sham.define do
89
- name &block
90
- slug :arg, &block
91
- end
92
- end
93
- end
94
-
95
- end