factory_girl 3.4.1 → 3.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/GETTING_STARTED.md +38 -0
- data/Gemfile.lock +1 -1
- data/NEWS +4 -0
- data/gemfiles/3.0.gemfile.lock +1 -1
- data/gemfiles/3.1.gemfile.lock +1 -1
- data/gemfiles/3.2.gemfile.lock +1 -1
- data/lib/factory_girl/declaration_list.rb +1 -1
- data/lib/factory_girl/version.rb +1 -1
- data/spec/acceptance/traits_spec.rb +24 -0
- data/spec/factory_girl/declaration_list_spec.rb +0 -4
- metadata +2 -2
data/GETTING_STARTED.md
CHANGED
|
@@ -18,6 +18,44 @@ gem "factory_girl", "~> 3.0"
|
|
|
18
18
|
|
|
19
19
|
Once your Gemfile is updated, you'll want to update your bundle.
|
|
20
20
|
|
|
21
|
+
Using Without Bundler
|
|
22
|
+
---------------------
|
|
23
|
+
|
|
24
|
+
If you're not using Bundler, be sure to have the gem installed and call:
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
require 'factory_girl'
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Once required, assuming you have a directory structure of `spec/factories` or
|
|
31
|
+
`test/factories`, all you'll need to do is run
|
|
32
|
+
|
|
33
|
+
```ruby
|
|
34
|
+
FactoryGirl.find_definitions
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
If you're using a separate directory structure for your factories, you can
|
|
38
|
+
change the definition file paths before trying to find definitions:
|
|
39
|
+
|
|
40
|
+
```ruby
|
|
41
|
+
FactoryGirl.definition_file_paths = %w(custom_factories_directory)
|
|
42
|
+
FactoryGirl.find_definitions
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
If you don't have a separate directory of factories and would like to define
|
|
46
|
+
them inline, that's possible as well:
|
|
47
|
+
|
|
48
|
+
```ruby
|
|
49
|
+
require 'factory_girl'
|
|
50
|
+
|
|
51
|
+
FactoryGirl.define do
|
|
52
|
+
factory :user do
|
|
53
|
+
name 'John Doe'
|
|
54
|
+
date_of_birth { 21.years.ago }
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
```
|
|
58
|
+
|
|
21
59
|
Defining factories
|
|
22
60
|
------------------
|
|
23
61
|
|
data/Gemfile.lock
CHANGED
data/NEWS
CHANGED
data/gemfiles/3.0.gemfile.lock
CHANGED
data/gemfiles/3.1.gemfile.lock
CHANGED
data/gemfiles/3.2.gemfile.lock
CHANGED
data/lib/factory_girl/version.rb
CHANGED
|
@@ -645,3 +645,27 @@ describe "nested implicit traits" do
|
|
|
645
645
|
it_should_behave_like "assigning data from traits"
|
|
646
646
|
end
|
|
647
647
|
end
|
|
648
|
+
|
|
649
|
+
describe "implicit traits containing callbacks" do
|
|
650
|
+
before do
|
|
651
|
+
define_model("User", value: :integer)
|
|
652
|
+
|
|
653
|
+
FactoryGirl.define do
|
|
654
|
+
factory :user do
|
|
655
|
+
value 0
|
|
656
|
+
|
|
657
|
+
trait :trait_with_callback do
|
|
658
|
+
after(:build) {|user| user.value += 1 }
|
|
659
|
+
end
|
|
660
|
+
|
|
661
|
+
factory :user_with_trait_with_callback do
|
|
662
|
+
trait_with_callback
|
|
663
|
+
end
|
|
664
|
+
end
|
|
665
|
+
end
|
|
666
|
+
end
|
|
667
|
+
|
|
668
|
+
it "only runs the callback once" do
|
|
669
|
+
FactoryGirl.build(:user_with_trait_with_callback).value.should == 1
|
|
670
|
+
end
|
|
671
|
+
end
|
|
@@ -25,10 +25,6 @@ describe FactoryGirl::DeclarationList, "#attributes" do
|
|
|
25
25
|
attribute_list.should have_received(:define_attribute).with(static_attribute_2)
|
|
26
26
|
attribute_list.should have_received(:define_attribute).with(dynamic_attribute_1)
|
|
27
27
|
end
|
|
28
|
-
|
|
29
|
-
it "creates a new attribute list upon every invocation" do
|
|
30
|
-
subject.attributes.should_not == subject.attributes
|
|
31
|
-
end
|
|
32
28
|
end
|
|
33
29
|
|
|
34
30
|
describe FactoryGirl::DeclarationList, "#declare_attribute" do
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: factory_girl
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.4.
|
|
4
|
+
version: 3.4.2
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -10,7 +10,7 @@ authors:
|
|
|
10
10
|
autorequire:
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date: 2012-06-
|
|
13
|
+
date: 2012-06-20 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: activesupport
|