-
-
Notifications
You must be signed in to change notification settings - Fork 365
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
Factory not registered: "credit_card" #341
Comments
+1 Same situation with solidus 2.9.1 and factory_bot_rails 5.0.2 |
@vassalloandrea I think it's a "chicken and egg" problem. I fixed the problem by moving out the file where I use Inside require 'spree/testing_support/factories'
Dir[Rails.root.join('spec', 'modified_spree_factories', '**', '*.rb')].sort.each { |file| require file } Hope it helps! |
This has to do with This has always been a problem when using spring, since spring triggers a It would be nice if we could get this use case working with spring, but I think that would require changes on the solidus side. We have an official way of sharing factories in the README, but solidus is not sharing them like that. You could add something like: config.factory_bot.definition_file_paths.unshift(
Gem::Specification.find_by_name("solidus_core").gem_dir +
"/lib/spree/testing_support/factories/credit_card_factory"
) to your application config to let factory_bot handle reloading the definitions as necessary, but unfortunately you can't do that with the whole "/lib/spree/testing_support/factories" directory because some of the factories there Another approach would be to set I will probably close this issue, since factory_bot_rails is back to the old behavior, and we do have a documented way of sharing factories. |
Thank you very much for the explanation @composerinteralia ! |
@composerinteralia , I'm getting the The factory is pretty simple and defined in test/factories.rb:
Should I create a separate issue? If I add
|
@mikong If you don't have solidus anywhere in your Gemfile.lock then this is a separate issue. I don't see anything obviously wrong in your code. Could you provide a sample application that reproduces the problem? |
@composerinteralia The error isn't happening anymore in my application. I tried to replicate the error in a branch just after I added factory_bot_rails but it's also no longer happening. If I reproduce the error next time, I'll open a new issue with a link to a sample application. Thanks. |
Sounds good. Thanks! I am going to close this issue for now for the reasons mentioned in #341 (comment). |
This is still an issue in Rails 6, I had to add |
Same here, rails 6, sometimes factories can't be found. |
Ran into this issue just now. In implementing the above, I was able to get my factories to work in the console, but unable to run my specs. I discovered that adding |
This commit adds the Article model, which belongs_to a Post. In order to facilitate testing, factories were added. Unfortunately, there were [unrecognized factories], and it was necessary to add `config.include FactoryBot::Syntax::Methods` to my `rails_helper` config. [unrecognized factories] thoughtbot/factory_bot_rails#341
This commit adds the Article model, which belongs_to a Post. In order to facilitate testing, factories were added. Unfortunately, there were [unrecognized factories], and it was necessary to add `config.include FactoryBot::Syntax::Methods` to my `rails_helper` config. [unrecognized factories] thoughtbot/factory_bot_rails#341
This commit adds the Article model, which belongs_to a Post. In order to facilitate testing, factories were added. Unfortunately, there were [unrecognized factories], and it was necessary to add `config.include FactoryBot::Syntax::Methods` to my `rails_helper` config. [unrecognized factories] thoughtbot/factory_bot_rails#341
This commit adds the Article model, which belongs_to a Post. In order to facilitate testing, factories were added. Unfortunately, there were [unrecognized factories], and it was necessary to add `config.include FactoryBot::Syntax::Methods` to my `rails_helper` config. [unrecognized factories] thoughtbot/factory_bot_rails#341
Same here, rails 6, Thanks for supporting. It's worked for me <3 |
Was stuck on the same issue for a while for If you spin up |
Camelcase error with rails7 dependency upgrade thoughtbot/factory_bot_rails#341 ```NameError: uninitialized constant Barcelona::Network::RDSStack Did you mean? Barcelona::Network::RdsStack```
I'm using Solidus to build an e-commerce.
Updating
factory_bot_rails
from the version4.11.1
to the latest5.0.2
something broke.Running the test locally, RSpec returns this error:
In this case, I included the
credit_card
factory from Solidus and overrode it adding acc_type.
My override:
spec/factories/credit_card_factory.rb
Solidus factory: here the link
I tried to figure out without success.
For now, I blocked the version on the project to
factory_bot_rails
4.11.1
.The text was updated successfully, but these errors were encountered: