fabrication 0.9.2 → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/fabrication/generator/base.rb +1 -1
- data/lib/fabrication/schematic.rb +1 -1
- data/lib/fabrication/version.rb +1 -1
- data/spec/fabrication/generator/active_record_spec.rb +1 -1
- data/spec/fabrication/generator/mongoid_spec.rb +1 -1
- data/spec/fabrication/generator/sequel_spec.rb +1 -1
- data/spec/fabrication/schematic_spec.rb +16 -0
- data/spec/support/helper_objects.rb +8 -0
- metadata +3 -3
@@ -65,7 +65,7 @@ class Fabrication::Generator::Base
|
|
65
65
|
attr_accessor :klass, :instance
|
66
66
|
|
67
67
|
def after_generation(options)
|
68
|
-
instance.save if options[:save] && instance.respond_to?(:save)
|
68
|
+
instance.save! if options[:save] && instance.respond_to?(:save!)
|
69
69
|
end
|
70
70
|
|
71
71
|
def assign(method_name, param)
|
@@ -74,7 +74,7 @@ class Fabrication::Schematic
|
|
74
74
|
clone.tap do |schematic|
|
75
75
|
schematic.instance_eval(&block) if block_given?
|
76
76
|
overrides.each do |name, value|
|
77
|
-
schematic.append_or_update_attribute(Fabrication::Attribute.new(name, nil, value))
|
77
|
+
schematic.append_or_update_attribute(Fabrication::Attribute.new(name.to_sym, nil, value))
|
78
78
|
end
|
79
79
|
end
|
80
80
|
end
|
data/lib/fabrication/version.rb
CHANGED
@@ -22,7 +22,7 @@ describe Fabrication::Generator::ActiveRecord do
|
|
22
22
|
before { generator.send(:instance=, instance) }
|
23
23
|
|
24
24
|
it "saves with a true save flag" do
|
25
|
-
instance.should_receive(:save)
|
25
|
+
instance.should_receive(:save!)
|
26
26
|
generator.send(:after_generation, {:save => true})
|
27
27
|
end
|
28
28
|
|
@@ -19,7 +19,7 @@ describe Fabrication::Generator::Mongoid do
|
|
19
19
|
before { generator.send(:instance=, instance) }
|
20
20
|
|
21
21
|
it "saves with a true save flag" do
|
22
|
-
instance.should_receive(:save)
|
22
|
+
instance.should_receive(:save!)
|
23
23
|
generator.send(:after_generation, {:save => true})
|
24
24
|
end
|
25
25
|
|
@@ -19,7 +19,7 @@ describe Fabrication::Generator::Sequel do
|
|
19
19
|
before { generator.send(:instance=, instance) }
|
20
20
|
|
21
21
|
it "saves with a true save flag" do
|
22
|
-
instance.should_receive(:save)
|
22
|
+
instance.should_receive(:save!)
|
23
23
|
generator.send(:after_generation, {:save => true})
|
24
24
|
end
|
25
25
|
|
@@ -180,4 +180,20 @@ describe Fabrication::Schematic do
|
|
180
180
|
end
|
181
181
|
end
|
182
182
|
end
|
183
|
+
|
184
|
+
context "when overriding" do
|
185
|
+
let(:address) { Address.new }
|
186
|
+
|
187
|
+
it "symbolizes attribute keys" do
|
188
|
+
Fabricator(:address) do
|
189
|
+
city { raise 'should not be called' }
|
190
|
+
end
|
191
|
+
Fabricator(:contact) do
|
192
|
+
address
|
193
|
+
end
|
194
|
+
lambda do
|
195
|
+
Fabricate(:contact, 'address' => address)
|
196
|
+
end.should_not raise_error(RuntimeError)
|
197
|
+
end
|
198
|
+
end
|
183
199
|
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
|
+
- 3
|
9
|
+
version: 0.9.3
|
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-
|
17
|
+
date: 2010-12-01 00:00:00 -05:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|