fabrication 2.5.1 → 2.5.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/fabrication.rb +0 -1
- data/lib/fabrication/fabricator.rb +9 -0
- data/lib/fabrication/version.rb +1 -1
- metadata +2 -2
data/lib/fabrication.rb
CHANGED
@@ -48,7 +48,6 @@ def Fabricator(name, options={}, &block)
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def Fabricate(name, overrides={}, &block)
|
51
|
-
raise Fabrication::MisplacedFabricateError.new(name) if Fabrication.schematics.initializing?
|
52
51
|
Fabrication::Fabricator.fabricate(name, overrides, &block).tap do |object|
|
53
52
|
Fabrication::Cucumber::Fabrications[name] = object if Fabrication::Config.register_with_steps?
|
54
53
|
end
|
@@ -1,19 +1,28 @@
|
|
1
1
|
class Fabrication::Fabricator
|
2
2
|
|
3
3
|
def self.build(name, overrides={}, &block)
|
4
|
+
fail_if_initializing(name)
|
4
5
|
schematic(name).build(overrides, &block)
|
5
6
|
end
|
6
7
|
|
7
8
|
def self.fabricate(name, overrides={}, &block)
|
9
|
+
fail_if_initializing(name)
|
8
10
|
schematic(name).fabricate(overrides, &block)
|
9
11
|
end
|
10
12
|
|
11
13
|
def self.to_attributes(name, overrides={}, &block)
|
14
|
+
fail_if_initializing(name)
|
12
15
|
schematic(name).to_attributes(overrides, &block)
|
13
16
|
end
|
14
17
|
|
15
18
|
private
|
16
19
|
|
20
|
+
def self.fail_if_initializing(name)
|
21
|
+
raise Fabrication::MisplacedFabricateError.new(
|
22
|
+
"You tried to fabricate `#{name}` while Fabricators were still loading. Check your fabricator files and make sure you didn't accidentally type `Fabricate` instead of `Fabricator` in there somewhere."
|
23
|
+
) if Fabrication.schematics.initializing?
|
24
|
+
end
|
25
|
+
|
17
26
|
def self.schematic(name)
|
18
27
|
Fabrication::Support.find_definitions if Fabrication.schematics.empty?
|
19
28
|
Fabrication.schematics[name].tap do |schematic|
|
data/lib/fabrication/version.rb
CHANGED
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: 2.5.
|
4
|
+
version: 2.5.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-12-
|
12
|
+
date: 2012-12-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|