factory_girl 3.4.1 → 3.4.2

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- factory_girl (3.4.1)
4
+ factory_girl (3.4.2)
5
5
  activesupport (>= 3.0.0)
6
6
 
7
7
  GEM
data/NEWS CHANGED
@@ -1,3 +1,7 @@
1
+ 3.4.2 (June 12, 2012)
2
+ Fix bug in traits with callbacks called implicitly in factories whose
3
+ callbacks trigger multiple times
4
+
1
5
  3.4.1 (June 18, 2012)
2
6
  Fix traits so they can be nested and referred to from other traits
3
7
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/joshuaclayton/dev/gems/factory_girl
3
3
  specs:
4
- factory_girl (3.4.1)
4
+ factory_girl (3.4.2)
5
5
  activesupport (>= 3.0.0)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/joshuaclayton/dev/gems/factory_girl
3
3
  specs:
4
- factory_girl (3.4.1)
4
+ factory_girl (3.4.2)
5
5
  activesupport (>= 3.0.0)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/joshuaclayton/dev/gems/factory_girl
3
3
  specs:
4
- factory_girl (3.4.1)
4
+ factory_girl (3.4.2)
5
5
  activesupport (>= 3.0.0)
6
6
 
7
7
  GEM
@@ -21,7 +21,7 @@ module FactoryGirl
21
21
  end
22
22
 
23
23
  def attributes
24
- AttributeList.new(@name).tap do |list|
24
+ @attributes ||= AttributeList.new(@name).tap do |list|
25
25
  to_attributes.each do |attribute|
26
26
  list.define_attribute(attribute)
27
27
  end
@@ -1,3 +1,3 @@
1
1
  module FactoryGirl
2
- VERSION = '3.4.1'
2
+ VERSION = '3.4.2'
3
3
  end
@@ -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.1
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-18 00:00:00.000000000 Z
13
+ date: 2012-06-20 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport