fabrication 2.8.1 → 2.9.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10a5fdcebce63ed58d267558fe39d5cdb8711248
|
4
|
+
data.tar.gz: 901d7205fd0dd1a85fd6a95174c9747756064e29
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 445df3c8a9d0f206ab8b313ccf59d0c4551e63ba6892ad579212066afd494adf40a9906b2595aca1c260e7387c0ba66a6d39a75a0122d58734feacae3fb0f662
|
7
|
+
data.tar.gz: 3e2da04c11c80b739d68c91b49e870e28537b2a65921603876cc910eb0482db92612084b3199d4f278f205144b83868bc6311d6d0831eefdda06a87b47551b37
|
data/lib/fabrication.rb
CHANGED
@@ -43,7 +43,7 @@ module Fabrication
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def self.schematics
|
46
|
-
puts "DEPRECATION WARNING: Fabrication.schematics has been replaced by Fabrication.manager"
|
46
|
+
puts "DEPRECATION WARNING: Fabrication.schematics has been replaced by Fabrication.manager and will be removed in 3.0.0."
|
47
47
|
manager
|
48
48
|
end
|
49
49
|
end
|
@@ -63,10 +63,19 @@ class Fabricate
|
|
63
63
|
count.times.map { Fabricate(name, overrides, &block) }
|
64
64
|
end
|
65
65
|
|
66
|
+
def self.build_times(count, name, overrides={}, &block)
|
67
|
+
count.times.map { Fabricate.build(name, overrides, &block) }
|
68
|
+
end
|
69
|
+
|
66
70
|
def self.attributes_for(name, overrides={}, &block)
|
71
|
+
puts "DEPRECATION WARNING: Fabrication.attributes_for has been replaced by Fabrication.to_params and will be removed in 3.0.0."
|
67
72
|
Fabrication::Fabricator.to_attributes(name, overrides, &block)
|
68
73
|
end
|
69
74
|
|
75
|
+
def self.to_params(name, overrides={}, &block)
|
76
|
+
Fabrication::Fabricator.to_params(name, overrides, &block)
|
77
|
+
end
|
78
|
+
|
70
79
|
def self.build(name, overrides={}, &block)
|
71
80
|
Fabrication::Fabricator.build(name, overrides, &block).tap do |object|
|
72
81
|
Fabrication::Cucumber::Fabrications[name] = object if Fabrication::Config.register_with_steps?
|
@@ -15,6 +15,11 @@ class Fabrication::Fabricator
|
|
15
15
|
schematic(name).to_attributes(overrides, &block)
|
16
16
|
end
|
17
17
|
|
18
|
+
def self.to_params(name, overrides={}, &block)
|
19
|
+
fail_if_initializing(name)
|
20
|
+
schematic(name).to_params(overrides, &block)
|
21
|
+
end
|
22
|
+
|
18
23
|
private
|
19
24
|
|
20
25
|
def self.fail_if_initializing(name)
|
@@ -23,9 +28,7 @@ class Fabrication::Fabricator
|
|
23
28
|
|
24
29
|
def self.schematic(name)
|
25
30
|
Fabrication::Support.find_definitions if Fabrication.manager.empty?
|
26
|
-
Fabrication.manager[name]
|
27
|
-
raise Fabrication::UnknownFabricatorError.new(name) unless schematic
|
28
|
-
end
|
31
|
+
Fabrication.manager[name] || raise(Fabrication::UnknownFabricatorError.new(name))
|
29
32
|
end
|
30
33
|
|
31
34
|
end
|
@@ -33,6 +33,11 @@ class Fabrication::Generator::Base
|
|
33
33
|
callbacks.each { |callback| _instance.instance_exec(_instance, _transient_attributes, &callback) } if callbacks
|
34
34
|
end
|
35
35
|
|
36
|
+
def to_params(attributes=[])
|
37
|
+
process_attributes(attributes)
|
38
|
+
_attributes.respond_to?(:with_indifferent_access) ? _attributes.with_indifferent_access : _attributes
|
39
|
+
end
|
40
|
+
|
36
41
|
def to_hash(attributes=[], callbacks=[])
|
37
42
|
process_attributes(attributes)
|
38
43
|
Fabrication::Support.hash_class.new.tap do |hash|
|
@@ -47,24 +47,41 @@ class Fabrication::Schematic::Definition
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def build(overrides={}, &block)
|
50
|
-
Fabrication.manager.
|
51
|
-
|
52
|
-
|
50
|
+
if Fabrication.manager.to_params_stack.any?
|
51
|
+
to_params(overrides, &block)
|
52
|
+
else
|
53
|
+
begin
|
54
|
+
Fabrication.manager.build_stack << self
|
55
|
+
merge(overrides, &block).instance_eval do
|
56
|
+
generator.new(klass).build(attributes, callbacks)
|
57
|
+
end
|
58
|
+
ensure
|
59
|
+
Fabrication.manager.build_stack.pop
|
60
|
+
end
|
53
61
|
end
|
54
|
-
ensure
|
55
|
-
Fabrication.manager.build_stack.pop
|
56
62
|
end
|
57
63
|
|
58
64
|
def fabricate(overrides={}, &block)
|
59
|
-
if Fabrication.manager.build_stack.
|
65
|
+
if Fabrication.manager.build_stack.any?
|
66
|
+
build(overrides, &block)
|
67
|
+
elsif Fabrication.manager.to_params_stack.any?
|
68
|
+
to_params(overrides, &block)
|
69
|
+
else
|
60
70
|
merge(overrides, &block).instance_eval do
|
61
71
|
generator.new(klass).create(attributes, callbacks)
|
62
72
|
end
|
63
|
-
else
|
64
|
-
build(overrides, &block)
|
65
73
|
end
|
66
74
|
end
|
67
75
|
|
76
|
+
def to_params(overrides={}, &block)
|
77
|
+
Fabrication.manager.to_params_stack << self
|
78
|
+
merge(overrides, &block).instance_eval do
|
79
|
+
generator.new(klass).to_params(attributes)
|
80
|
+
end
|
81
|
+
ensure
|
82
|
+
Fabrication.manager.to_params_stack.pop
|
83
|
+
end
|
84
|
+
|
68
85
|
def to_attributes(overrides={}, &block)
|
69
86
|
merge(overrides, &block).instance_eval do
|
70
87
|
generator.new(klass).to_hash(attributes, callbacks)
|
data/lib/fabrication/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fabrication
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Elliott
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-10-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|