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.
- data/.gitignore +3 -2
- data/Gemfile +8 -0
- data/MIT-LICENSE +2 -1
- data/README.markdown +39 -271
- data/Rakefile +22 -14
- data/lib/generators/machinist/install/USAGE +2 -0
- data/lib/generators/machinist/install/install_generator.rb +48 -0
- data/lib/generators/machinist/install/templates/blueprints.rb +9 -0
- data/lib/generators/machinist/install/templates/machinist.rb.erb +10 -0
- data/lib/generators/machinist/model/model_generator.rb +13 -0
- data/lib/machinist.rb +11 -105
- data/lib/machinist/active_record.rb +8 -93
- data/lib/machinist/active_record/blueprint.rb +41 -0
- data/lib/machinist/active_record/lathe.rb +24 -0
- data/lib/machinist/blueprint.rb +89 -0
- data/lib/machinist/exceptions.rb +32 -0
- data/lib/machinist/lathe.rb +69 -0
- data/lib/machinist/machinable.rb +97 -0
- data/lib/machinist/shop.rb +52 -0
- data/lib/machinist/warehouse.rb +36 -0
- data/spec/active_record_spec.rb +100 -169
- data/spec/blueprint_spec.rb +74 -0
- data/spec/exceptions_spec.rb +20 -0
- data/spec/inheritance_spec.rb +104 -0
- data/spec/machinable_spec.rb +101 -0
- data/spec/shop_spec.rb +94 -0
- data/spec/spec_helper.rb +4 -6
- data/spec/support/active_record_environment.rb +65 -0
- data/spec/warehouse_spec.rb +24 -0
- metadata +52 -40
- data/.autotest +0 -7
- data/FAQ.markdown +0 -18
- data/VERSION +0 -1
- data/init.rb +0 -2
- data/lib/machinist/blueprints.rb +0 -25
- data/lib/machinist/data_mapper.rb +0 -83
- data/lib/machinist/object.rb +0 -30
- data/lib/machinist/sequel.rb +0 -62
- data/lib/sham.rb +0 -77
- data/machinist.gemspec +0 -72
- data/spec/data_mapper_spec.rb +0 -134
- data/spec/db/.gitignore +0 -1
- data/spec/db/schema.rb +0 -20
- data/spec/log/.gitignore +0 -1
- data/spec/machinist_spec.rb +0 -190
- data/spec/sequel_spec.rb +0 -146
- 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
|