factory_girl-preload 2.1.0 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +62 -41
- data/factory_girl-preload.gemspec +2 -1
- data/lib/factory_girl/preload/helpers.rb +1 -1
- data/lib/factory_girl/preload/version.rb +1 -1
- data/spec/factory_girl/preload_spec.rb +16 -16
- data/spec/spec_helper.rb +1 -0
- data/spec/support/app/app/models/category.rb +3 -0
- data/spec/support/app/app/models/user.rb +1 -0
- data/spec/support/app/db/schema.rb +10 -0
- metadata +27 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab3729f171070e0df3264bee3761fb1204c77076
|
4
|
+
data.tar.gz: ce6e84d25feb7922e5aa4a2da6cf9b8147e66c7b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c363f8016ab5703304da1e83712e5e0ce62447465c49c226920fb2229c7e0616bfadbb8bbc2e3d5aa15aa29d8f3225ea7b6a2de6ed5745ff7af28b777bc0f998
|
7
|
+
data.tar.gz: 58ae144f6f9c5211d7d8e566d2eee5b9b199dc2faae7b1aa48f45439756df6f285921e614e4be35a93135ef5a4f8a47e1abe703dffaa66a3378ebaa80c8a1c3d
|
data/Gemfile.lock
CHANGED
@@ -1,69 +1,89 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
factory_girl-preload (2.1.
|
4
|
+
factory_girl-preload (2.1.1)
|
5
5
|
factory_girl (>= 3.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
actionpack (4.0
|
11
|
-
|
12
|
-
|
13
|
-
erubis (~> 2.7.0)
|
10
|
+
actionpack (4.1.0)
|
11
|
+
actionview (= 4.1.0)
|
12
|
+
activesupport (= 4.1.0)
|
14
13
|
rack (~> 1.5.2)
|
15
14
|
rack-test (~> 0.6.2)
|
16
|
-
|
17
|
-
activesupport (= 4.0
|
18
|
-
builder (~> 3.1
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
15
|
+
actionview (4.1.0)
|
16
|
+
activesupport (= 4.1.0)
|
17
|
+
builder (~> 3.1)
|
18
|
+
erubis (~> 2.7.0)
|
19
|
+
activemodel (4.1.0)
|
20
|
+
activesupport (= 4.1.0)
|
21
|
+
builder (~> 3.1)
|
22
|
+
activerecord (4.1.0)
|
23
|
+
activemodel (= 4.1.0)
|
24
|
+
activesupport (= 4.1.0)
|
25
|
+
arel (~> 5.0.0)
|
26
|
+
activesupport (4.1.0)
|
27
|
+
i18n (~> 0.6, >= 0.6.9)
|
28
|
+
json (~> 1.7, >= 1.7.7)
|
29
|
+
minitest (~> 5.1)
|
29
30
|
thread_safe (~> 0.1)
|
30
|
-
tzinfo (~>
|
31
|
-
arel (
|
32
|
-
|
33
|
-
builder (3.
|
31
|
+
tzinfo (~> 1.1)
|
32
|
+
arel (5.0.1.20140414130214)
|
33
|
+
ast (1.1.0)
|
34
|
+
builder (3.2.2)
|
34
35
|
diff-lcs (1.2.5)
|
35
36
|
erubis (2.7.0)
|
36
37
|
factory_girl (4.4.0)
|
37
38
|
activesupport (>= 3.0.0)
|
38
39
|
i18n (0.6.9)
|
39
|
-
|
40
|
-
|
40
|
+
json (1.8.1)
|
41
|
+
minitest (5.3.3)
|
41
42
|
mysql2 (0.3.15)
|
43
|
+
parser (2.1.7)
|
44
|
+
ast (~> 1.1)
|
45
|
+
slop (~> 3.4, >= 3.4.5)
|
42
46
|
rack (1.5.2)
|
43
47
|
rack-test (0.6.2)
|
44
48
|
rack (>= 1.0)
|
45
|
-
railties (4.0
|
46
|
-
actionpack (= 4.0
|
47
|
-
activesupport (= 4.0
|
49
|
+
railties (4.1.0)
|
50
|
+
actionpack (= 4.1.0)
|
51
|
+
activesupport (= 4.1.0)
|
48
52
|
rake (>= 0.8.7)
|
49
53
|
thor (>= 0.18.1, < 2.0)
|
50
|
-
|
51
|
-
|
52
|
-
rspec-
|
53
|
-
|
54
|
-
rspec-
|
55
|
-
|
54
|
+
rainbow (2.0.0)
|
55
|
+
rake (10.3.0)
|
56
|
+
rspec-collection_matchers (0.0.3)
|
57
|
+
rspec-expectations (>= 2.99.0.beta1)
|
58
|
+
rspec-core (3.0.0.beta2)
|
59
|
+
rspec-support (= 3.0.0.beta2)
|
60
|
+
rspec-expectations (3.0.0.beta2)
|
61
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
62
|
+
rspec-support (= 3.0.0.beta2)
|
63
|
+
rspec-mocks (3.0.0.beta2)
|
64
|
+
rspec-support (= 3.0.0.beta2)
|
65
|
+
rspec-rails (3.0.0.beta2)
|
56
66
|
actionpack (>= 3.0)
|
57
67
|
activemodel (>= 3.0)
|
58
68
|
activesupport (>= 3.0)
|
59
69
|
railties (>= 3.0)
|
60
|
-
rspec-
|
61
|
-
rspec-
|
62
|
-
rspec-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
70
|
+
rspec-collection_matchers
|
71
|
+
rspec-core (= 3.0.0.beta2)
|
72
|
+
rspec-expectations (= 3.0.0.beta2)
|
73
|
+
rspec-mocks (= 3.0.0.beta2)
|
74
|
+
rspec-support (= 3.0.0.beta2)
|
75
|
+
rspec-support (3.0.0.beta2)
|
76
|
+
slop (3.5.0)
|
77
|
+
thor (0.19.1)
|
78
|
+
thread_safe (0.3.3)
|
79
|
+
transpec (1.10.4)
|
80
|
+
activesupport (~> 4.0)
|
81
|
+
bundler (~> 1.3)
|
82
|
+
json (~> 1.8)
|
83
|
+
parser (>= 2.1.6, < 3.0)
|
84
|
+
rainbow (>= 1.99.1, < 3.0)
|
85
|
+
tzinfo (1.1.0)
|
86
|
+
thread_safe (~> 0.1)
|
67
87
|
|
68
88
|
PLATFORMS
|
69
89
|
ruby
|
@@ -73,4 +93,5 @@ DEPENDENCIES
|
|
73
93
|
activerecord
|
74
94
|
factory_girl-preload!
|
75
95
|
mysql2
|
76
|
-
rspec-rails
|
96
|
+
rspec-rails (= 3.0.0.beta2)
|
97
|
+
transpec
|
@@ -20,6 +20,7 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.add_dependency "factory_girl", ">= 3.0"
|
21
21
|
s.add_development_dependency "activerecord"
|
22
22
|
s.add_development_dependency "actionpack"
|
23
|
-
s.add_development_dependency "rspec-rails"
|
23
|
+
s.add_development_dependency "rspec-rails", "3.0.0.beta2"
|
24
|
+
s.add_development_dependency "transpec"
|
24
25
|
s.add_development_dependency "mysql2"
|
25
26
|
end
|
@@ -6,16 +6,16 @@ describe FactoryGirl::Preload do
|
|
6
6
|
it "queues preloader block" do
|
7
7
|
block = proc {}
|
8
8
|
FactoryGirl.preload(&block)
|
9
|
-
FactoryGirl::Preload.preloaders.
|
9
|
+
expect(FactoryGirl::Preload.preloaders).to include(block)
|
10
10
|
end
|
11
11
|
|
12
12
|
it "should lazy load all factories, loading only when used" do
|
13
|
-
FactoryGirl::Preload.record_ids['User'][:john].
|
14
|
-
FactoryGirl::Preload.factories['User'][:john].
|
13
|
+
expect(FactoryGirl::Preload.record_ids['User'][:john]).to eq(1)
|
14
|
+
expect(FactoryGirl::Preload.factories['User'][:john]).to be_nil
|
15
15
|
|
16
16
|
user = users(:john)
|
17
17
|
|
18
|
-
FactoryGirl::Preload.factories['User'][:john].
|
18
|
+
expect(FactoryGirl::Preload.factories['User'][:john]).to eq(user)
|
19
19
|
end
|
20
20
|
|
21
21
|
it "injects model methods" do
|
@@ -23,19 +23,19 @@ describe FactoryGirl::Preload do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
it "returns :john factory for User model" do
|
26
|
-
users(:john).
|
26
|
+
expect(users(:john)).to be_an(User)
|
27
27
|
end
|
28
28
|
|
29
29
|
it "returns :ruby factory for Skill model" do
|
30
|
-
skills(:ruby).
|
30
|
+
expect(skills(:ruby)).to be_a(Skill)
|
31
31
|
end
|
32
32
|
|
33
33
|
it "returns :my factory for Preload model" do
|
34
|
-
preloads(:my).
|
34
|
+
expect(preloads(:my)).to be_a(Preload)
|
35
35
|
end
|
36
36
|
|
37
37
|
it "reuses existing factories" do
|
38
|
-
skills(:ruby).user.
|
38
|
+
expect(skills(:ruby).user).to eq(users(:john))
|
39
39
|
end
|
40
40
|
|
41
41
|
it "raises error for missing factories" do
|
@@ -49,17 +49,17 @@ describe FactoryGirl::Preload do
|
|
49
49
|
|
50
50
|
context "removes records" do
|
51
51
|
it "with deletion" do
|
52
|
-
User.count.
|
52
|
+
expect(User.count).to eq(1)
|
53
53
|
FactoryGirl::Preload.clean_with = :deletion
|
54
54
|
FactoryGirl::Preload.clean
|
55
|
-
User.count.
|
55
|
+
expect(User.count).to eq(0)
|
56
56
|
end
|
57
57
|
|
58
58
|
it "with truncation" do
|
59
|
-
User.count.
|
59
|
+
expect(User.count).to eq(1)
|
60
60
|
FactoryGirl::Preload.clean_with = :truncation
|
61
61
|
FactoryGirl::Preload.clean
|
62
|
-
User.count.
|
62
|
+
expect(User.count).to eq(0)
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
@@ -75,18 +75,18 @@ describe FactoryGirl::Preload do
|
|
75
75
|
|
76
76
|
it "freezes object" do
|
77
77
|
users(:john).destroy
|
78
|
-
users(:john).
|
78
|
+
expect(users(:john)).to be_frozen
|
79
79
|
end
|
80
80
|
|
81
81
|
it "updates invitation count" do
|
82
82
|
users(:john).increment(:invitations)
|
83
83
|
users(:john).save
|
84
|
-
users(:john).invitations.
|
84
|
+
expect(users(:john).invitations).to eq(1)
|
85
85
|
end
|
86
86
|
|
87
87
|
it "reloads factory" do
|
88
|
-
users(:john).invitations.
|
89
|
-
users(:john).
|
88
|
+
expect(users(:john).invitations).to eq(0)
|
89
|
+
expect(users(:john)).not_to be_frozen
|
90
90
|
end
|
91
91
|
end
|
92
92
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -3,6 +3,8 @@ ActiveRecord::Schema.define(:version => 0) do
|
|
3
3
|
drop_table :users
|
4
4
|
drop_table :skills
|
5
5
|
drop_table :preloads
|
6
|
+
drop_table :categories
|
7
|
+
drop_table :categories_users
|
6
8
|
rescue Exception => e
|
7
9
|
end
|
8
10
|
|
@@ -21,4 +23,12 @@ ActiveRecord::Schema.define(:version => 0) do
|
|
21
23
|
create_table :skills do |t|
|
22
24
|
t.references :user
|
23
25
|
end
|
26
|
+
|
27
|
+
create_table :categories do |t|
|
28
|
+
end
|
29
|
+
|
30
|
+
create_table :categories_users, :id => false do |t|
|
31
|
+
t.references :category
|
32
|
+
t.references :user
|
33
|
+
end
|
24
34
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: factory_girl-preload
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nando Vieira
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: factory_girl
|
@@ -54,6 +54,20 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec-rails
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 3.0.0.beta2
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 3.0.0.beta2
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: transpec
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
73
|
- - ">="
|
@@ -103,6 +117,7 @@ files:
|
|
103
117
|
- lib/factory_girl/preload/version.rb
|
104
118
|
- spec/factory_girl/preload_spec.rb
|
105
119
|
- spec/spec_helper.rb
|
120
|
+
- spec/support/app/app/models/category.rb
|
106
121
|
- spec/support/app/app/models/preload.rb
|
107
122
|
- spec/support/app/app/models/skill.rb
|
108
123
|
- spec/support/app/app/models/user.rb
|
@@ -133,4 +148,13 @@ signing_key:
|
|
133
148
|
specification_version: 4
|
134
149
|
summary: Preload factories (Factory Girl) just like fixtures. It will be easy and,
|
135
150
|
probably, faster!
|
136
|
-
test_files:
|
151
|
+
test_files:
|
152
|
+
- spec/factory_girl/preload_spec.rb
|
153
|
+
- spec/spec_helper.rb
|
154
|
+
- spec/support/app/app/models/category.rb
|
155
|
+
- spec/support/app/app/models/preload.rb
|
156
|
+
- spec/support/app/app/models/skill.rb
|
157
|
+
- spec/support/app/app/models/user.rb
|
158
|
+
- spec/support/app/config/database.yml
|
159
|
+
- spec/support/app/db/schema.rb
|
160
|
+
- spec/support/factories.rb
|