fabrication 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
@@ -11,7 +11,7 @@ class Fabrication::Generator::ActiveRecord < Fabrication::Generator::Base
|
|
11
11
|
method_name = method_name.to_s
|
12
12
|
unless @options.include?(method_name.to_sym)
|
13
13
|
if block_given?
|
14
|
-
unless @instance.class.columns.map(&:name).include?(method_name)
|
14
|
+
unless args.include?(:force) || @instance.class.columns.map(&:name).include?(method_name)
|
15
15
|
# copy the original getter
|
16
16
|
@instance.instance_variable_set("@__#{method_name}_original", @instance.method(method_name).clone)
|
17
17
|
|
data/lib/fabrication/version.rb
CHANGED
data/spec/fabrication_spec.rb
CHANGED
@@ -10,6 +10,11 @@ describe Fabrication do
|
|
10
10
|
before do
|
11
11
|
Fabricator(:company) do
|
12
12
|
name { Faker::Company.name }
|
13
|
+
divisions(:force) { [Fabricate(:division)] }
|
14
|
+
end
|
15
|
+
|
16
|
+
Fabricator(:division) do
|
17
|
+
name "Awesome Division"
|
13
18
|
end
|
14
19
|
end
|
15
20
|
|
@@ -18,7 +23,14 @@ describe Fabrication do
|
|
18
23
|
it 'generates field blocks immediately' do
|
19
24
|
company.name.should be
|
20
25
|
end
|
21
|
-
|
26
|
+
|
27
|
+
it 'generates associations immediately when forced' do
|
28
|
+
Division.find_all_by_company_id(company.id).count.should == 1
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'overrides associations' do
|
32
|
+
Fabricate(:company, :divisions => []).divisions.should == []
|
33
|
+
end
|
22
34
|
end
|
23
35
|
|
24
36
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fabrication
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Paul Elliott
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-06-
|
18
|
+
date: 2010-06-16 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|