factory_bot 4.10.0 → 4.11.0

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/NEWS CHANGED
@@ -1,3 +1,8 @@
1
+ 4.11.0 (August, 15, 2018)
2
+ Bugfix: Do not raise error for valid build_stubbed methods: decrement, increment, and toggle
3
+ Bugfix: Do not add timestamps with build_stubbed for objects that shouldn't have timestamps
4
+ Deprecate static attributes
5
+
1
6
  4.10.0 (May 25, 2018)
2
7
  Allow sequences to be rewound
3
8
 
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # factory_bot [![Build Status](https://travis-ci.org/thoughtbot/factory_bot.svg)](http://travis-ci.org/thoughtbot/factory_bot?branch=master) [![Code Climate](https://codeclimate.com/github/thoughtbot/factory_bot/badges/gpa.svg)](https://codeclimate.com/github/thoughtbot/factory_bot)
1
+ # factory_bot [![Build Status][ci-image]][ci] [![Code Climate][grade-image]][grade] [![Gem Version][version-image]][version] [![Reviewed by Hound][hound-badge-image]][hound]
2
2
 
3
3
  factory_bot is a fixtures replacement with a straightforward definition syntax, support for multiple build strategies (saved instances, unsaved instances, attribute hashes, and stubbed objects), and support for multiple factories for the same class (user, admin_user, and so on), including factory inheritance.
4
4
 
@@ -103,4 +103,12 @@ See [our other projects][community] or
103
103
  [hire us][hire] to design, develop, and grow your product.
104
104
 
105
105
  [community]: https://thoughtbot.com/community?utm_source=github
106
- [hire]: https://thoughtbot.com?utm_source=github
106
+ [hire]: https://thoughtbot.com/hire-us?utm_source=github
107
+ [ci-image]: https://travis-ci.org/thoughtbot/factory_bot.svg
108
+ [ci]: http://travis-ci.org/thoughtbot/factory_bot?branch=master
109
+ [grade-image]: https://codeclimate.com/github/thoughtbot/factory_bot/badges/gpa.svg
110
+ [grade]: https://codeclimate.com/github/thoughtbot/factory_bot
111
+ [version-image]: https://badge.fury.io/rb/factory_bot.svg
112
+ [version]: https://badge.fury.io/rb/factory_bot
113
+ [hound-badge-image]: https://img.shields.io/badge/Reviewed_by-Hound-8E64B0.svg
114
+ [hound]: https://houndci.com
@@ -45,6 +45,7 @@ module FactoryBot
45
45
  declaration = if block_given?
46
46
  Declaration::Dynamic.new(name, @ignore, block)
47
47
  else
48
+ warn_static_attribute_deprecation(name, value)
48
49
  Declaration::Static.new(name, value, @ignore)
49
50
  end
50
51
 
@@ -170,5 +171,31 @@ module FactoryBot
170
171
  def initialize_with(&block)
171
172
  @definition.define_constructor(&block)
172
173
  end
174
+
175
+ private
176
+
177
+ def warn_static_attribute_deprecation(name, value)
178
+ attribute_caller = caller(2)
179
+
180
+ if attribute_caller[0].include?("method_missing")
181
+ attribute_caller = caller(3)
182
+ end
183
+
184
+ ActiveSupport::Deprecation.warn(<<-MSG, attribute_caller)
185
+ Static attributes will be removed in FactoryBot 5.0. Please use dynamic
186
+ attributes instead by wrapping the attribute value in a block:
187
+
188
+ #{name} { #{value.inspect} }
189
+
190
+ To automatically update from static attributes to dynamic ones,
191
+ install rubocop-rspec and run:
192
+
193
+ rubocop \\
194
+ --require rubocop-rspec \\
195
+ --only FactoryBot/AttributeDefinedStatically \\
196
+ --auto-correct
197
+
198
+ MSG
199
+ end
173
200
  end
174
201
  end
@@ -6,17 +6,14 @@ module FactoryBot
6
6
  DISABLED_PERSISTENCE_METHODS = [
7
7
  :connection,
8
8
  :decrement!,
9
- :decrement,
10
9
  :delete,
11
10
  :destroy!,
12
11
  :destroy,
13
12
  :increment!,
14
- :increment,
15
13
  :reload,
16
14
  :save!,
17
15
  :save,
18
16
  :toggle!,
19
- :toggle,
20
17
  :touch,
21
18
  :update!,
22
19
  :update,
@@ -69,9 +66,8 @@ module FactoryBot
69
66
  end
70
67
 
71
68
  created_at_missing_default = result_instance.respond_to?(:created_at) && !result_instance.created_at
72
- result_instance_missing_created_at = !result_instance.respond_to?(:created_at)
73
69
 
74
- if created_at_missing_default || result_instance_missing_created_at
70
+ if created_at_missing_default
75
71
  result_instance.instance_eval do
76
72
  def created_at
77
73
  @created_at ||= Time.now.in_time_zone
@@ -81,9 +77,8 @@ module FactoryBot
81
77
 
82
78
  has_updated_at = result_instance.respond_to?(:updated_at)
83
79
  updated_at_no_default = has_updated_at && !result_instance.updated_at
84
- result_instance_missing_updated_at = !has_updated_at
85
80
 
86
- if updated_at_no_default || result_instance_missing_updated_at
81
+ if updated_at_no_default
87
82
  result_instance.instance_eval do
88
83
  def updated_at
89
84
  @updated_at ||= Time.current
@@ -1,3 +1,3 @@
1
1
  module FactoryBot
2
- VERSION = "4.10.0".freeze
2
+ VERSION = "4.11.0".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: factory_bot
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.10.0
4
+ version: 4.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Clayton
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-05-25 00:00:00.000000000 Z
12
+ date: 2018-08-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -26,117 +26,117 @@ dependencies:
26
26
  - !ruby/object:Gem::Version
27
27
  version: 3.0.0
28
28
  - !ruby/object:Gem::Dependency
29
- name: rspec
29
+ name: activerecord
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - "~>"
32
+ - - ">="
33
33
  - !ruby/object:Gem::Version
34
- version: '3.0'
34
+ version: 3.0.0
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - "~>"
39
+ - - ">="
40
40
  - !ruby/object:Gem::Version
41
- version: '3.0'
41
+ version: 3.0.0
42
42
  - !ruby/object:Gem::Dependency
43
- name: rspec-its
43
+ name: appraisal
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
46
  - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: '1.0'
48
+ version: 2.1.0
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - "~>"
54
54
  - !ruby/object:Gem::Version
55
- version: '1.0'
55
+ version: 2.1.0
56
56
  - !ruby/object:Gem::Dependency
57
- name: cucumber
57
+ name: aruba
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - "~>"
60
+ - - ">="
61
61
  - !ruby/object:Gem::Version
62
- version: 1.3.15
62
+ version: '0'
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - "~>"
67
+ - - ">="
68
68
  - !ruby/object:Gem::Version
69
- version: 1.3.15
69
+ version: '0'
70
70
  - !ruby/object:Gem::Dependency
71
- name: timecop
71
+ name: cucumber
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
- - - ">="
74
+ - - "~>"
75
75
  - !ruby/object:Gem::Version
76
- version: '0'
76
+ version: 1.3.15
77
77
  type: :development
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
- - - ">="
81
+ - - "~>"
82
82
  - !ruby/object:Gem::Version
83
- version: '0'
83
+ version: 1.3.15
84
84
  - !ruby/object:Gem::Dependency
85
- name: simplecov
85
+ name: rspec
86
86
  requirement: !ruby/object:Gem::Requirement
87
87
  requirements:
88
- - - ">="
88
+ - - "~>"
89
89
  - !ruby/object:Gem::Version
90
- version: '0'
90
+ version: '3.0'
91
91
  type: :development
92
92
  prerelease: false
93
93
  version_requirements: !ruby/object:Gem::Requirement
94
94
  requirements:
95
- - - ">="
95
+ - - "~>"
96
96
  - !ruby/object:Gem::Version
97
- version: '0'
97
+ version: '3.0'
98
98
  - !ruby/object:Gem::Dependency
99
- name: aruba
99
+ name: rspec-its
100
100
  requirement: !ruby/object:Gem::Requirement
101
101
  requirements:
102
- - - ">="
102
+ - - "~>"
103
103
  - !ruby/object:Gem::Version
104
- version: '0'
104
+ version: '1.0'
105
105
  type: :development
106
106
  prerelease: false
107
107
  version_requirements: !ruby/object:Gem::Requirement
108
108
  requirements:
109
- - - ">="
109
+ - - "~>"
110
110
  - !ruby/object:Gem::Version
111
- version: '0'
111
+ version: '1.0'
112
112
  - !ruby/object:Gem::Dependency
113
- name: appraisal
113
+ name: simplecov
114
114
  requirement: !ruby/object:Gem::Requirement
115
115
  requirements:
116
- - - "~>"
116
+ - - ">="
117
117
  - !ruby/object:Gem::Version
118
- version: 2.1.0
118
+ version: '0'
119
119
  type: :development
120
120
  prerelease: false
121
121
  version_requirements: !ruby/object:Gem::Requirement
122
122
  requirements:
123
- - - "~>"
123
+ - - ">="
124
124
  - !ruby/object:Gem::Version
125
- version: 2.1.0
125
+ version: '0'
126
126
  - !ruby/object:Gem::Dependency
127
- name: activerecord
127
+ name: timecop
128
128
  requirement: !ruby/object:Gem::Requirement
129
129
  requirements:
130
130
  - - ">="
131
131
  - !ruby/object:Gem::Version
132
- version: 3.0.0
132
+ version: '0'
133
133
  type: :development
134
134
  prerelease: false
135
135
  version_requirements: !ruby/object:Gem::Requirement
136
136
  requirements:
137
137
  - - ">="
138
138
  - !ruby/object:Gem::Version
139
- version: 3.0.0
139
+ version: '0'
140
140
  - !ruby/object:Gem::Dependency
141
141
  name: yard
142
142
  requirement: !ruby/object:Gem::Requirement
@@ -151,10 +151,8 @@ dependencies:
151
151
  - - ">="
152
152
  - !ruby/object:Gem::Version
153
153
  version: '0'
154
- description: |-
155
- factory_bot provides a framework and DSL for defining and
156
- using factories - less error-prone, more explicit, and
157
- all-around easier to work with than fixtures.
154
+ description: factory_bot provides a framework and DSL for defining and using factories
155
+ - less error-prone, more explicit, and all-around easier to work with than fixtures.
158
156
  email:
159
157
  - jclayton@thoughtbot.com
160
158
  - jferris@thoughtbot.com
@@ -162,37 +160,12 @@ executables: []
162
160
  extensions: []
163
161
  extra_rdoc_files: []
164
162
  files:
165
- - ".autotest"
166
- - ".gitignore"
167
- - ".rspec"
168
- - ".simplecov"
169
- - ".travis.yml"
170
- - ".yardopts"
171
- - Appraisals
172
163
  - CONTRIBUTING.md
173
164
  - GETTING_STARTED.md
174
- - Gemfile
175
- - Gemfile.lock
176
165
  - LICENSE
177
166
  - NAME.md
178
167
  - NEWS
179
168
  - README.md
180
- - Rakefile
181
- - cucumber.yml
182
- - factory_bot.gemspec
183
- - factory_girl.gemspec
184
- - gemfiles/3.2.gemfile
185
- - gemfiles/3.2.gemfile.lock
186
- - gemfiles/4.0.gemfile
187
- - gemfiles/4.0.gemfile.lock
188
- - gemfiles/4.1.gemfile
189
- - gemfiles/4.1.gemfile.lock
190
- - gemfiles/4.2.gemfile
191
- - gemfiles/4.2.gemfile.lock
192
- - gemfiles/5.0.gemfile
193
- - gemfiles/5.0.gemfile.lock
194
- - gemfiles/5.1.gemfile
195
- - gemfiles/5.1.gemfile.lock
196
169
  - lib/factory_bot.rb
197
170
  - lib/factory_bot/aliases.rb
198
171
  - lib/factory_bot/attribute.rb
@@ -246,7 +219,6 @@ files:
246
219
  - lib/factory_bot/syntax_runner.rb
247
220
  - lib/factory_bot/trait.rb
248
221
  - lib/factory_bot/version.rb
249
- - lib/factory_girl.rb
250
222
  homepage: https://github.com/thoughtbot/factory_bot
251
223
  licenses:
252
224
  - MIT
@@ -267,7 +239,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
267
239
  version: '0'
268
240
  requirements: []
269
241
  rubyforge_project:
270
- rubygems_version: 2.7.6
242
+ rubygems_version: 2.7.7
271
243
  signing_key:
272
244
  specification_version: 4
273
245
  summary: factory_bot provides a framework and DSL for defining and using model instance
data/.autotest DELETED
@@ -1,9 +0,0 @@
1
- Autotest.add_hook :initialize do |at|
2
- at.clear_mappings
3
-
4
- at.add_mapping(%r{^test/.*_test\.rb$}) {|f, _| [f] }
5
- at.add_mapping(%r{^lib/factory_girl/(.*)\.rb$}) {|_, m| ["test/#{m[1]}_test.rb",
6
- "test/integration_test.rb"] }
7
- at.add_mapping(%r{^test/(test_helper|models)\.rb$}) { at.files_matching %r{^test/.*_test\.rb$} }
8
- at.add_mapping(%r{^lib/.*\.rb$}) { at.files_matching %r{^test/.*_test\.rb$} }
9
- end
data/.gitignore DELETED
@@ -1,10 +0,0 @@
1
- *.swp
2
- test.db
3
- factory_girl-*.gem
4
- factory_bot-*.gem
5
- doc
6
- .yardoc
7
- coverage
8
- .bundle
9
- tmp
10
- bin
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format progress
2
- --color
3
- --require spec_helper
data/.simplecov DELETED
@@ -1,4 +0,0 @@
1
- SimpleCov.start do
2
- add_filter "/spec/"
3
- add_filter "/tmp/"
4
- end
@@ -1,58 +0,0 @@
1
- rvm:
2
- - 1.9.3
3
- - 2.0.0
4
- - 2.1.9
5
- - 2.2.8
6
- - 2.3.5
7
- - 2.4.2
8
- - ruby-head
9
- - rbx-2
10
- before_install:
11
- - gem update --system
12
- - gem update bundler
13
- - gem cleanup bundler
14
- install: "bundle install --jobs 8"
15
- script: "bundle exec rake"
16
- gemfile:
17
- - gemfiles/3.2.gemfile
18
- - gemfiles/4.0.gemfile
19
- - gemfiles/4.1.gemfile
20
- - gemfiles/4.2.gemfile
21
- - gemfiles/5.0.gemfile
22
- - gemfiles/5.1.gemfile
23
- matrix:
24
- fast_finish: true
25
- exclude:
26
- - rvm: 1.9.3
27
- gemfile: gemfiles/5.0.gemfile
28
- - rvm: 1.9.3
29
- gemfile: gemfiles/5.1.gemfile
30
- - rvm: 2.0.0
31
- gemfile: gemfiles/5.0.gemfile
32
- - rvm: 2.0.0
33
- gemfile: gemfiles/5.1.gemfile
34
- - rvm: 2.1.9
35
- gemfile: gemfiles/5.0.gemfile
36
- - rvm: 2.1.9
37
- gemfile: gemfiles/5.1.gemfile
38
- - rvm: 2.4.2
39
- gemfile: gemfiles/3.2.gemfile
40
- - rvm: 2.4.2
41
- gemfile: gemfiles/4.0.gemfile
42
- - rvm: 2.4.2
43
- gemfile: gemfiles/4.1.gemfile
44
- - rvm: ruby-head
45
- gemfile: gemfiles/3.2.gemfile
46
- - rvm: ruby-head
47
- gemfile: gemfiles/4.0.gemfile
48
- - rvm: ruby-head
49
- gemfile: gemfiles/4.1.gemfile
50
- allow_failures:
51
- - rvm: ruby-head
52
- - rvm: rbx-2
53
- branches:
54
- only:
55
- - master
56
-
57
- sudo: false
58
- cache: bundler
data/.yardopts DELETED
@@ -1,5 +0,0 @@
1
- lib/**/*.rb
2
- -
3
- GETTING_STARTED.md
4
- CONTRIBUTING.md
5
- LICENSE