fabrication 0.9.1 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +1 -0
- data/lib/fabrication/schematic.rb +8 -6
- data/lib/fabrication/version.rb +1 -1
- data/spec/fabrication/schematic_spec.rb +0 -10
- data/spec/fabrication_spec.rb +1 -2
- metadata +3 -3
data/README.markdown
CHANGED
@@ -28,8 +28,12 @@ class Fabrication::Schematic
|
|
28
28
|
attributes.select { |a| a.name == name }.first
|
29
29
|
end
|
30
30
|
|
31
|
-
def
|
32
|
-
attributes.
|
31
|
+
def append_or_update_attribute(attribute)
|
32
|
+
if index = attributes.index { |a| a.name == attribute.name }
|
33
|
+
attributes[index] = attribute
|
34
|
+
else
|
35
|
+
attributes << attribute
|
36
|
+
end
|
33
37
|
end
|
34
38
|
|
35
39
|
attr_writer :attributes
|
@@ -70,8 +74,7 @@ class Fabrication::Schematic
|
|
70
74
|
clone.tap do |schematic|
|
71
75
|
schematic.instance_eval(&block) if block_given?
|
72
76
|
overrides.each do |name, value|
|
73
|
-
schematic.
|
74
|
-
schematic.attributes << Fabrication::Attribute.new(name, nil, value)
|
77
|
+
schematic.append_or_update_attribute(Fabrication::Attribute.new(name, nil, value))
|
75
78
|
end
|
76
79
|
end
|
77
80
|
end
|
@@ -86,8 +89,7 @@ class Fabrication::Schematic
|
|
86
89
|
value = args.first
|
87
90
|
end
|
88
91
|
|
89
|
-
|
90
|
-
attributes.push(Fabrication::Attribute.new(method_name, params, value))
|
92
|
+
append_or_update_attribute(Fabrication::Attribute.new(method_name, params, value))
|
91
93
|
end
|
92
94
|
|
93
95
|
def on_init(&block)
|
data/lib/fabrication/version.rb
CHANGED
@@ -49,16 +49,6 @@ describe Fabrication::Schematic do
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
-
describe "#delete_attribute" do
|
53
|
-
it "deletes the requested attribute if it exists" do
|
54
|
-
schematic.delete_attribute(:name).should_not be_nil
|
55
|
-
schematic.attribute(:name).should be_nil
|
56
|
-
end
|
57
|
-
it "returns nil if it does not exist" do
|
58
|
-
schematic.delete_attribute(:not_there).should be_nil
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
52
|
describe "#attributes" do
|
63
53
|
it "always returns an empty array" do
|
64
54
|
schematic.attributes = nil
|
data/spec/fabrication_spec.rb
CHANGED
@@ -122,8 +122,7 @@ describe Fabrication do
|
|
122
122
|
context 'with the generation parameter' do
|
123
123
|
|
124
124
|
let(:person) do
|
125
|
-
Fabricate(:person) do
|
126
|
-
first_name "Paul"
|
125
|
+
Fabricate(:person, :first_name => "Paul") do
|
127
126
|
last_name { |person| "#{person.first_name}#{person.age}" }
|
128
127
|
age 50
|
129
128
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 9
|
8
|
-
-
|
9
|
-
version: 0.9.
|
8
|
+
- 2
|
9
|
+
version: 0.9.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Paul Elliott
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-11-
|
17
|
+
date: 2010-11-24 00:00:00 -05:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|