fabrication 1.3.1 → 1.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/lib/fabrication.rb CHANGED
@@ -3,6 +3,7 @@ module Fabrication
3
3
  autoload :DuplicateFabricatorError, 'fabrication/errors/duplicate_fabricator_error'
4
4
  autoload :UnfabricatableError, 'fabrication/errors/unfabricatable_error'
5
5
  autoload :UnknownFabricatorError, 'fabrication/errors/unknown_fabricator_error'
6
+ autoload :MisplacedFabricateError, 'fabrication/errors/misplaced_fabricate_error'
6
7
 
7
8
  autoload :Attribute, 'fabrication/attribute'
8
9
  autoload :Config, 'fabrication/config'
@@ -32,6 +33,14 @@ module Fabrication
32
33
  Fabrication::Config.configure(&block)
33
34
  end
34
35
 
36
+ def self.initializing=(value)
37
+ @initializing = value
38
+ end
39
+
40
+ def self.initializing?
41
+ @initializing
42
+ end
43
+
35
44
  end
36
45
 
37
46
  def Fabricator(name, options={}, &block)
@@ -39,6 +48,7 @@ def Fabricator(name, options={}, &block)
39
48
  end
40
49
 
41
50
  def Fabricate(name, overrides={}, &block)
51
+ raise Fabrication::MisplacedFabricateError.new(name) if Fabrication.initializing?
42
52
  Fabrication::Fabricator.generate(name, {
43
53
  :save => true
44
54
  }, overrides, &block)
@@ -0,0 +1 @@
1
+ class Fabrication::MisplacedFabricateError < StandardError; end
@@ -23,12 +23,14 @@ class Fabrication::Support
23
23
  end
24
24
 
25
25
  def find_definitions
26
+ Fabrication.initializing = true
26
27
  path_prefix = defined?(Rails) ? Rails.root : "."
27
28
  Fabrication::Config.fabricator_dir.each do |folder|
28
29
  Dir.glob(File.join(path_prefix, folder, '**', '*.rb')).sort.each do |file|
29
30
  load file
30
31
  end
31
32
  end
33
+ Fabrication.initializing = false
32
34
  end
33
35
 
34
36
  end
@@ -1,3 +1,3 @@
1
1
  module Fabrication
2
- VERSION = '1.3.1'
2
+ VERSION = '1.3.2'
3
3
  end
@@ -1,21 +1,23 @@
1
1
  require 'rails/generators/base'
2
2
 
3
- module Fabrication::Generators
4
- class TurnipStepsGenerator < Rails::Generators::Base
5
- argument :step_dir, :type => :string, :default => "spec/acceptance/steps/"
3
+ module Fabrication
4
+ module Generators
5
+ class TurnipStepsGenerator < Rails::Generators::Base
6
+ argument :step_dir, :type => :string, :default => "spec/acceptance/steps/"
6
7
 
7
- def generate
8
- template 'fabrication_steps.rb', turnip_step_directory
9
- end
8
+ def generate
9
+ template 'fabrication_steps.rb', turnip_step_directory
10
+ end
10
11
 
11
- def self.source_root
12
- @_fabrication_source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
13
- end
12
+ def self.source_root
13
+ @_fabrication_source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
14
+ end
14
15
 
15
- private
16
+ private
16
17
 
17
- def turnip_step_directory
18
- File.join(step_dir, 'fabrication_steps.rb')
18
+ def turnip_step_directory
19
+ File.join(step_dir, 'fabrication_steps.rb')
20
+ end
19
21
  end
20
22
  end
21
23
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fabrication
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.3.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-12 00:00:00.000000000 Z
12
+ date: 2012-02-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
16
- requirement: &70150779173400 !ruby/object:Gem::Requirement
16
+ requirement: &70293264110260 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,32 +21,21 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70150779173400
25
- - !ruby/object:Gem::Dependency
26
- name: bson
27
- requirement: &70150779171840 !ruby/object:Gem::Requirement
28
- none: false
29
- requirements:
30
- - - ~>
31
- - !ruby/object:Gem::Version
32
- version: 1.3.1
33
- type: :development
34
- prerelease: false
35
- version_requirements: *70150779171840
24
+ version_requirements: *70293264110260
36
25
  - !ruby/object:Gem::Dependency
37
26
  name: bson_ext
38
- requirement: &70150779170120 !ruby/object:Gem::Requirement
27
+ requirement: &70293264109540 !ruby/object:Gem::Requirement
39
28
  none: false
40
29
  requirements:
41
- - - ~>
30
+ - - ! '>='
42
31
  - !ruby/object:Gem::Version
43
- version: 1.3.1
32
+ version: '0'
44
33
  type: :development
45
34
  prerelease: false
46
- version_requirements: *70150779170120
35
+ version_requirements: *70293264109540
47
36
  - !ruby/object:Gem::Dependency
48
37
  name: cucumber
49
- requirement: &70150782983740 !ruby/object:Gem::Requirement
38
+ requirement: &70293264108380 !ruby/object:Gem::Requirement
50
39
  none: false
51
40
  requirements:
52
41
  - - ! '>='
@@ -54,10 +43,10 @@ dependencies:
54
43
  version: '0'
55
44
  type: :development
56
45
  prerelease: false
57
- version_requirements: *70150782983740
46
+ version_requirements: *70293264108380
58
47
  - !ruby/object:Gem::Dependency
59
48
  name: turnip
60
- requirement: &70150782979740 !ruby/object:Gem::Requirement
49
+ requirement: &70293264107760 !ruby/object:Gem::Requirement
61
50
  none: false
62
51
  requirements:
63
52
  - - ! '>='
@@ -65,10 +54,10 @@ dependencies:
65
54
  version: '0.3'
66
55
  type: :development
67
56
  prerelease: false
68
- version_requirements: *70150782979740
57
+ version_requirements: *70293264107760
69
58
  - !ruby/object:Gem::Dependency
70
59
  name: ffaker
71
- requirement: &70150782976360 !ruby/object:Gem::Requirement
60
+ requirement: &70293264107080 !ruby/object:Gem::Requirement
72
61
  none: false
73
62
  requirements:
74
63
  - - ! '>='
@@ -76,10 +65,10 @@ dependencies:
76
65
  version: '0'
77
66
  type: :development
78
67
  prerelease: false
79
- version_requirements: *70150782976360
68
+ version_requirements: *70293264107080
80
69
  - !ruby/object:Gem::Dependency
81
70
  name: fuubar
82
- requirement: &70150779183100 !ruby/object:Gem::Requirement
71
+ requirement: &70293264106400 !ruby/object:Gem::Requirement
83
72
  none: false
84
73
  requirements:
85
74
  - - ! '>='
@@ -87,10 +76,10 @@ dependencies:
87
76
  version: '0'
88
77
  type: :development
89
78
  prerelease: false
90
- version_requirements: *70150779183100
79
+ version_requirements: *70293264106400
91
80
  - !ruby/object:Gem::Dependency
92
81
  name: fuubar-cucumber
93
- requirement: &70150779180820 !ruby/object:Gem::Requirement
82
+ requirement: &70293264105560 !ruby/object:Gem::Requirement
94
83
  none: false
95
84
  requirements:
96
85
  - - ! '>='
@@ -98,32 +87,21 @@ dependencies:
98
87
  version: '0'
99
88
  type: :development
100
89
  prerelease: false
101
- version_requirements: *70150779180820
102
- - !ruby/object:Gem::Dependency
103
- name: mongo
104
- requirement: &70150779178300 !ruby/object:Gem::Requirement
105
- none: false
106
- requirements:
107
- - - ~>
108
- - !ruby/object:Gem::Version
109
- version: 1.3.1
110
- type: :development
111
- prerelease: false
112
- version_requirements: *70150779178300
90
+ version_requirements: *70293264105560
113
91
  - !ruby/object:Gem::Dependency
114
92
  name: mongoid
115
- requirement: &70150779191660 !ruby/object:Gem::Requirement
93
+ requirement: &70293264104580 !ruby/object:Gem::Requirement
116
94
  none: false
117
95
  requirements:
118
- - - =
96
+ - - ! '>='
119
97
  - !ruby/object:Gem::Version
120
- version: 2.1.4
98
+ version: '0'
121
99
  type: :development
122
100
  prerelease: false
123
- version_requirements: *70150779191660
101
+ version_requirements: *70293264104580
124
102
  - !ruby/object:Gem::Dependency
125
103
  name: pry
126
- requirement: &70150779190740 !ruby/object:Gem::Requirement
104
+ requirement: &70293264102800 !ruby/object:Gem::Requirement
127
105
  none: false
128
106
  requirements:
129
107
  - - ! '>='
@@ -131,10 +109,10 @@ dependencies:
131
109
  version: '0'
132
110
  type: :development
133
111
  prerelease: false
134
- version_requirements: *70150779190740
112
+ version_requirements: *70293264102800
135
113
  - !ruby/object:Gem::Dependency
136
114
  name: rake
137
- requirement: &70150779189540 !ruby/object:Gem::Requirement
115
+ requirement: &70293264101080 !ruby/object:Gem::Requirement
138
116
  none: false
139
117
  requirements:
140
118
  - - ! '>='
@@ -142,10 +120,10 @@ dependencies:
142
120
  version: '0'
143
121
  type: :development
144
122
  prerelease: false
145
- version_requirements: *70150779189540
123
+ version_requirements: *70293264101080
146
124
  - !ruby/object:Gem::Dependency
147
125
  name: rspec
148
- requirement: &70150779188220 !ruby/object:Gem::Requirement
126
+ requirement: &70293264099340 !ruby/object:Gem::Requirement
149
127
  none: false
150
128
  requirements:
151
129
  - - ! '>='
@@ -153,10 +131,10 @@ dependencies:
153
131
  version: '0'
154
132
  type: :development
155
133
  prerelease: false
156
- version_requirements: *70150779188220
134
+ version_requirements: *70293264099340
157
135
  - !ruby/object:Gem::Dependency
158
136
  name: sequel
159
- requirement: &70150779187060 !ruby/object:Gem::Requirement
137
+ requirement: &70293264098720 !ruby/object:Gem::Requirement
160
138
  none: false
161
139
  requirements:
162
140
  - - ! '>='
@@ -164,10 +142,10 @@ dependencies:
164
142
  version: '0'
165
143
  type: :development
166
144
  prerelease: false
167
- version_requirements: *70150779187060
145
+ version_requirements: *70293264098720
168
146
  - !ruby/object:Gem::Dependency
169
147
  name: sqlite3
170
- requirement: &70150779185820 !ruby/object:Gem::Requirement
148
+ requirement: &70293264097860 !ruby/object:Gem::Requirement
171
149
  none: false
172
150
  requirements:
173
151
  - - ! '>='
@@ -175,7 +153,7 @@ dependencies:
175
153
  version: '0'
176
154
  type: :development
177
155
  prerelease: false
178
- version_requirements: *70150779185820
156
+ version_requirements: *70293264097860
179
157
  description: Fabrication is an object generation framework for ActiveRecord, Mongoid,
180
158
  and Sequel. It has a sensible syntax and lazily generates ActiveRecord associations!
181
159
  email:
@@ -188,6 +166,7 @@ files:
188
166
  - lib/fabrication/config.rb
189
167
  - lib/fabrication/cucumber/step_fabricator.rb
190
168
  - lib/fabrication/errors/duplicate_fabricator_error.rb
169
+ - lib/fabrication/errors/misplaced_fabricate_error.rb
191
170
  - lib/fabrication/errors/unfabricatable_error.rb
192
171
  - lib/fabrication/errors/unknown_fabricator_error.rb
193
172
  - lib/fabrication/fabricator.rb