fabrication 0.9.2 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Fabrication
2
- VERSION = '0.9.2'
2
+ VERSION = '0.9.3'
3
3
  end
@@ -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
@@ -18,3 +18,11 @@ class City
18
18
  self.state = state
19
19
  end
20
20
  end
21
+
22
+ class Address
23
+ attr_accessor :city, :state
24
+ end
25
+
26
+ class Contact
27
+ attr_accessor :name, :address
28
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 9
8
- - 2
9
- version: 0.9.2
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-11-24 00:00:00 -05:00
17
+ date: 2010-12-01 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency