-
-
Notifications
You must be signed in to change notification settings - Fork 373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support file_fixture
in Factory definitions
#427
base: main
Are you sure you want to change the base?
Conversation
lib/factory_bot_rails/railtie.rb
Outdated
|
||
if defined?(RSpec) | ||
RSpec.configure do |config| | ||
if config.respond_to?(:file_fixture_path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, this conditional is always resolving to false
, and so the file_fixture_path
is never set.
As of rspec-rails@5.0.0, that setting is available. The current Gemfile.lock
that are generated for me locally depends on rspec-rails@6.0.0
, so a hunch tells me that a loading order issue is at the root of the failure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would test an actual file upload if possible. Otherwise looks good to me
This is our first time extending I can't think of how this could break existing tests but maybe I'm just not being creative enough. |
8a739aa
to
5a1a15e
Compare
a343bd3
to
0cd66df
Compare
Related to [factory_bot#1282][] [rails/rails#45606][] has been merged and is likely to be released as part of Rails 7.1. With that addition, the path toward resolving [factory_bot#1282][] becomes more clear. If factories can pass along [Pathname][] instances to attachment attributes, Active Support will handle the rest. Instances of `ActiveSupport::TestCase` provide a [file_fixture][] helper to construct a `Pathname` instance based on the path defined by `ActiveSupport::TestCase.file_fixture_path` (relative to the Rails root directory). [factory_bot#1282]: thoughtbot/factory_bot#1282 (comment) [rails/rails#45606]: rails/rails#45606 [Pathname]: https://docs.ruby-lang.org/en/master/Pathname.html [file_fixture]: https://api.rubyonrails.org/classes/ActiveSupport/Testing/FileFixtures.html#method-i-file_fixture
0cd66df
to
33c1348
Compare
Related to factory_bot#1282
rails/rails#45606 has been merged and is likely to be released as part of Rails 7.1.
With that addition, the path toward resolving factory_bot#1282 becomes more clear. If factories can pass along Pathname instances to attachment attributes, Active Support will handle the rest.
Instances of
ActiveSupport::TestCase
provide a file_fixture helper to construct aPathname
instance based on the path defined byActiveSupport::TestCase.file_fixture_path
(relative to the Rails root directory).