fabrication 2.5.1 → 2.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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|
@@ -1,3 +1,3 @@
1
1
  module Fabrication
2
- VERSION = '2.5.1'
2
+ VERSION = '2.5.2'
3
3
  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: 2.5.1
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-05 00:00:00.000000000 Z
12
+ date: 2012-12-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord