daddys_girl 0.7.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZDViYmY5YmE1ZDg0ZGZmYWIzZTU1YTliMGVjZDFlYzc0ZDZlZTdmNQ==
5
+ data.tar.gz: !binary |-
6
+ ZmEyNWYxOWY0NmU2Y2JkNWZlMzdjYzFhMTMwNmVhYzU5ZGZiNDQ1ZA==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ Y2YzNWU1Mjk3OGY5MzUyYzU1ZmY2ZWExMWE2MzJkMDNiZTQ5NWJkY2IyYzgz
10
+ MGEzOGZjZDI4MWJjZWIwMzc4N2M1MWI2YTcxYmJhZjc5YjM0NzdlNDAyNDY3
11
+ YTBiYmEwMTVjZjZhOTY0M2Y5MDhjYWVlZGNiMjY2ZTFjZTE5YmE=
12
+ data.tar.gz: !binary |-
13
+ YmY3OTA1YTBlYzRiZjk3MWYzYTRkMWE2MmNlOTQzZWZjYWQwYTI0Njk3ZjI1
14
+ MmYzOGVlMDFkMmU1ZWY2NDA4Y2IwYWY4MDY2MjAzZGNlZDQ3YzIyM2FhMjc3
15
+ MWU5NmYyYjdmMzQ1YzNhN2UzOTg1MmUzZTJmNjcwMzU0ZmVmMDQ=
data/.gitignore CHANGED
@@ -1,3 +1,2 @@
1
1
  *.gem
2
2
  .bundle/*
3
- spec/test.db
data/.rvmrc CHANGED
@@ -1,3 +1,3 @@
1
- rvm use --create 1.9.2@daddys_girl
1
+ rvm use --create 1.9.3
2
2
  echo "Loading bundle..."
3
3
  bundle install --without=production
@@ -1,50 +1,56 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- daddys_girl (0.7.0)
5
- activerecord (>= 3.0)
4
+ daddys_girl (1.0.0)
5
+ activerecord (>= 3)
6
6
  factory_girl (>= 2.0)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- activemodel (3.2.3)
12
- activesupport (= 3.2.3)
13
- builder (~> 3.0.0)
14
- activerecord (3.2.3)
15
- activemodel (= 3.2.3)
16
- activesupport (= 3.2.3)
17
- arel (~> 3.0.2)
18
- tzinfo (~> 0.3.29)
19
- activesupport (3.2.3)
20
- i18n (~> 0.6)
21
- multi_json (~> 1.0)
22
- arel (3.0.2)
23
- builder (3.0.0)
24
- diff-lcs (1.1.3)
25
- factory_girl (3.1.1)
11
+ activemodel (4.0.4)
12
+ activesupport (= 4.0.4)
13
+ builder (~> 3.1.0)
14
+ activerecord (4.0.4)
15
+ activemodel (= 4.0.4)
16
+ activerecord-deprecated_finders (~> 1.0.2)
17
+ activesupport (= 4.0.4)
18
+ arel (~> 4.0.0)
19
+ activerecord-deprecated_finders (1.0.3)
20
+ activesupport (4.0.4)
21
+ i18n (~> 0.6, >= 0.6.9)
22
+ minitest (~> 4.2)
23
+ multi_json (~> 1.3)
24
+ thread_safe (~> 0.1)
25
+ tzinfo (~> 0.3.37)
26
+ arel (4.0.2)
27
+ builder (3.1.4)
28
+ diff-lcs (1.2.5)
29
+ factory_girl (4.4.0)
26
30
  activesupport (>= 3.0.0)
27
- i18n (0.6.0)
28
- multi_json (1.3.2)
29
- rspec (2.9.0)
30
- rspec-core (~> 2.9.0)
31
- rspec-expectations (~> 2.9.0)
32
- rspec-mocks (~> 2.9.0)
33
- rspec-core (2.9.0)
34
- rspec-expectations (2.9.1)
35
- diff-lcs (~> 1.1.3)
36
- rspec-mocks (2.9.0)
37
- sqlite3 (1.3.6)
31
+ i18n (0.6.9)
32
+ minitest (4.7.5)
33
+ multi_json (1.9.2)
34
+ rspec (2.14.1)
35
+ rspec-core (~> 2.14.0)
36
+ rspec-expectations (~> 2.14.0)
37
+ rspec-mocks (~> 2.14.0)
38
+ rspec-core (2.14.8)
39
+ rspec-expectations (2.14.5)
40
+ diff-lcs (>= 1.1.3, < 2.0)
41
+ rspec-mocks (2.14.6)
42
+ sqlite3 (1.3.9)
38
43
  sqlite3-ruby (1.3.3)
39
44
  sqlite3 (>= 1.3.3)
40
- tzinfo (0.3.33)
45
+ thread_safe (0.3.3)
46
+ tzinfo (0.3.39)
41
47
 
42
48
  PLATFORMS
43
49
  ruby
44
50
 
45
51
  DEPENDENCIES
46
- activerecord (>= 3.0)
52
+ activerecord (>= 3)
47
53
  daddys_girl!
48
54
  factory_girl (>= 2.0)
49
- rspec (~> 2.0)
55
+ rspec (>= 2.0)
50
56
  sqlite3-ruby
data/README.md CHANGED
@@ -21,7 +21,7 @@ First, you must add a class definition to the Factory Girl factories file (norma
21
21
 
22
22
  Methods:
23
23
 
24
- 1. ```ClassName.spawn(params)```: creates an object, but does not save it
24
+ 1. ```ClassName.factory_spawn(params)```: creates an object, but does not save it
25
25
  2. ```ClassName.generate(params)```: creates an object and attempts to save it
26
26
  3. ```ClassName.generate!(params)```: creates an object, and throws an error if it can not save it
27
27
 
@@ -3,7 +3,7 @@ require File.expand_path('../lib/daddys_girl/version', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
5
  gem.authors = ["Kurt Preston"]
6
- gem.email = ["development@inventables.com"]
6
+ gem.email = ["github@kurtpreston.com"]
7
7
  gem.description = "Rubygem to provide object_daddy-like syntax for factory_girl"
8
8
  gem.summary = "[Object] Daddy's [Factory] Girl"
9
9
  gem.homepage = "https://github.com/inventables/daddys_girl"
@@ -14,9 +14,9 @@ Gem::Specification.new do |gem|
14
14
  gem.name = "daddys_girl"
15
15
  gem.require_paths = ["lib"]
16
16
  gem.version = DaddysGirl::VERSION
17
- gem.add_dependency "activerecord", ">= 3.0"
17
+ gem.add_dependency "activerecord", ">= 3"
18
18
  gem.add_dependency "factory_girl", ">= 2.0"
19
- gem.add_development_dependency "rspec", "~> 2.0"
19
+ gem.add_development_dependency "rspec", ">= 2.0"
20
20
  gem.add_development_dependency "sqlite3-ruby"
21
21
  end
22
22
 
@@ -8,17 +8,17 @@ ActiveRecord::Base.class_eval do
8
8
 
9
9
  def generate(attributes = {})
10
10
  begin
11
- FactoryGirl.create(self.symbol, attributes)
11
+ FactoryGirl.create(self.symbol, attributes).reload
12
12
  rescue ActiveRecord::RecordInvalid
13
13
  FactoryGirl.build(self.symbol, attributes)
14
14
  end
15
15
  end
16
16
 
17
17
  def generate!(attributes = {})
18
- FactoryGirl.create(self.symbol, attributes)
18
+ FactoryGirl.create(self.symbol, attributes).reload
19
19
  end
20
20
 
21
- def spawn(attributes = {})
21
+ def factory_spawn(attributes = {})
22
22
  FactoryGirl.build(self.symbol, attributes)
23
23
  end
24
24
  end
@@ -44,7 +44,7 @@ if ActiveRecord::VERSION::MAJOR == 3 && ActiveRecord::VERSION::MINOR == 0
44
44
  FactoryGirl.create(target_class_symbol, attributes)
45
45
  end
46
46
 
47
- def spawn(attributes = {})
47
+ def factory_spawn(attributes = {})
48
48
  attributes = attributes.merge(association_attribute)
49
49
  FactoryGirl.build(target_class_symbol, attributes)
50
50
  end
@@ -61,7 +61,9 @@ if ActiveRecord::VERSION::MAJOR == 3 && ActiveRecord::VERSION::MINOR == 0
61
61
  end
62
62
 
63
63
 
64
- if ActiveRecord::VERSION::MAJOR == 3 && ActiveRecord::VERSION::MINOR >= 1
64
+ if (ActiveRecord::VERSION::MAJOR == 3 && ActiveRecord::VERSION::MINOR >= 1) ||
65
+ ActiveRecord::VERSION::MAJOR >= 4
66
+
65
67
  ActiveRecord::Relation.class_eval do
66
68
  def target_class_symbol
67
69
  self.symbol
@@ -81,10 +83,9 @@ if ActiveRecord::VERSION::MAJOR == 3 && ActiveRecord::VERSION::MINOR >= 1
81
83
  FactoryGirl.create(target_class_symbol, attributes)
82
84
  end
83
85
 
84
- def spawn(attributes = {})
86
+ def factory_spawn(attributes = {})
85
87
  attributes = attributes.merge(where_values_hash)
86
88
  FactoryGirl.build(target_class_symbol, attributes)
87
89
  end
88
-
89
90
  end
90
91
  end
@@ -1,3 +1,3 @@
1
1
  module DaddysGirl
2
- VERSION = "0.7.0"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -18,22 +18,32 @@ describe DaddysGirl do
18
18
  define_model('TestAssociation', {:name => :string, :test_class_id => :integer})
19
19
 
20
20
  TestClass.class_eval do
21
- validates_format_of :name, :with => /^[^!]+$/
21
+ validates_format_of :name, :with => /[^!]+\z/
22
22
  has_many :test_associations
23
23
  end
24
24
  TestAssociation.class_eval do
25
- validates_format_of :name, :with => /^[^!]+$/
25
+ validates_format_of :name, :with => /[^!]+\z/
26
26
  belongs_to :test_class
27
27
  end
28
28
 
29
29
  @test_object = TestClass.create(:name => "Valid")
30
30
  end
31
31
 
32
- describe "ActiveRecord::Base#spawn" do
32
+ describe "Validate test classes" do
33
+ it "TestClass should validate name format" do
34
+ TestClass.new(name: "Invalid!").should_not be_valid
35
+ end
36
+
37
+ it "TestAssociation should validate name format" do
38
+ TestAssociation.new(name: "Invalid!").should_not be_valid
39
+ end
40
+ end
41
+
42
+ describe "ActiveRecord::Base#factory_spawn" do
33
43
  it "creates a new object without saving" do
34
- TestClass.spawn.class.should == TestClass
35
- TestClass.spawn(:name => "Test Name").name.should == "Test Name"
36
- TestClass.spawn.id.should be_nil
44
+ TestClass.factory_spawn.class.should == TestClass
45
+ TestClass.factory_spawn(:name => "Test Name").name.should == "Test Name"
46
+ TestClass.factory_spawn.id.should be_nil
37
47
  end
38
48
  end
39
49
 
@@ -72,12 +82,12 @@ describe DaddysGirl do
72
82
  end
73
83
  end
74
84
 
75
- describe "ActiveRecord::Associations::AssociationProxy.spawn" do
85
+ describe "ActiveRecord::Associations::AssociationProxy.factory_spawn" do
76
86
  it "creates a new object without saving" do
77
- @test_object.test_associations.spawn.class.should == TestAssociation
78
- @test_object.test_associations.spawn(:name => 'Test Association').name.should == 'Test Association'
79
- @test_object.test_associations.spawn.id.should be_nil
80
- @test_object.test_associations.spawn.test_class.should == @test_object.reload
87
+ @test_object.test_associations.factory_spawn.class.should == TestAssociation
88
+ @test_object.test_associations.factory_spawn(:name => 'Test Association').name.should == 'Test Association'
89
+ @test_object.test_associations.factory_spawn.id.should be_nil
90
+ @test_object.test_associations.factory_spawn.test_class.should == @test_object.reload
81
91
  end
82
92
  end
83
93
 
@@ -74,7 +74,7 @@ RSpec.configure do |config|
74
74
  config.before(:all) do
75
75
  ActiveRecord::Base.establish_connection(
76
76
  adapter: 'sqlite3',
77
- database: File.join(File.dirname(__FILE__), 'test.db')
77
+ database: ":memory:"
78
78
  )
79
79
  end
80
80
 
metadata CHANGED
@@ -1,63 +1,74 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: daddys_girl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
5
- prerelease:
4
+ version: 1.0.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Kurt Preston
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-04-20 00:00:00.000000000Z
11
+ date: 2014-04-14 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: activerecord
16
- requirement: &70814090 !ruby/object:Gem::Requirement
17
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
17
  - - ! '>='
20
18
  - !ruby/object:Gem::Version
21
- version: '3.0'
19
+ version: '3'
22
20
  type: :runtime
23
21
  prerelease: false
24
- version_requirements: *70814090
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '3'
25
27
  - !ruby/object:Gem::Dependency
26
28
  name: factory_girl
27
- requirement: &70813810 !ruby/object:Gem::Requirement
28
- none: false
29
+ requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
31
  - - ! '>='
31
32
  - !ruby/object:Gem::Version
32
33
  version: '2.0'
33
34
  type: :runtime
34
35
  prerelease: false
35
- version_requirements: *70813810
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '2.0'
36
41
  - !ruby/object:Gem::Dependency
37
42
  name: rspec
38
- requirement: &70813510 !ruby/object:Gem::Requirement
39
- none: false
43
+ requirement: !ruby/object:Gem::Requirement
40
44
  requirements:
41
- - - ~>
45
+ - - ! '>='
42
46
  - !ruby/object:Gem::Version
43
47
  version: '2.0'
44
48
  type: :development
45
49
  prerelease: false
46
- version_requirements: *70813510
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '2.0'
47
55
  - !ruby/object:Gem::Dependency
48
56
  name: sqlite3-ruby
49
- requirement: &70813250 !ruby/object:Gem::Requirement
50
- none: false
57
+ requirement: !ruby/object:Gem::Requirement
51
58
  requirements:
52
59
  - - ! '>='
53
60
  - !ruby/object:Gem::Version
54
61
  version: '0'
55
62
  type: :development
56
63
  prerelease: false
57
- version_requirements: *70813250
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
58
69
  description: Rubygem to provide object_daddy-like syntax for factory_girl
59
70
  email:
60
- - development@inventables.com
71
+ - github@kurtpreston.com
61
72
  executables: []
62
73
  extensions: []
63
74
  extra_rdoc_files: []
@@ -76,27 +87,26 @@ files:
76
87
  - spec/spec_helper.rb
77
88
  homepage: https://github.com/inventables/daddys_girl
78
89
  licenses: []
90
+ metadata: {}
79
91
  post_install_message:
80
92
  rdoc_options: []
81
93
  require_paths:
82
94
  - lib
83
95
  required_ruby_version: !ruby/object:Gem::Requirement
84
- none: false
85
96
  requirements:
86
97
  - - ! '>='
87
98
  - !ruby/object:Gem::Version
88
99
  version: '0'
89
100
  required_rubygems_version: !ruby/object:Gem::Requirement
90
- none: false
91
101
  requirements:
92
102
  - - ! '>='
93
103
  - !ruby/object:Gem::Version
94
104
  version: '0'
95
105
  requirements: []
96
106
  rubyforge_project:
97
- rubygems_version: 1.8.10
107
+ rubygems_version: 2.2.2
98
108
  signing_key:
99
- specification_version: 3
109
+ specification_version: 4
100
110
  summary: ! '[Object] Daddy''s [Factory] Girl'
101
111
  test_files:
102
112
  - spec/daddys_girl_spec.rb