-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
WIP Requirable factories #623
Conversation
Our goal is to break up all of the factories so that they can be required independently of each other so we need these sequences available outside of factories.rb which requires all of the factories.
Doing this class eval in factories.rb would have create an unreasonable dependency on this file for the ShippingMethod factory
zones { |a| [Spree::Zone.global] } | ||
zones do | ||
[Spree::Zone.find_by(name: 'GlobalZone') || FactoryGirl.create(:global_zone)] | ||
end |
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.
👍
Yeah. What a Christmas present!!! Thank you so very much @Sinetheta 🎄🎄🎅🏻🎅🏻 |
@Sinetheta This is really, really nice stuff. There's a bit of stuff missing; if you want help - can I PR against your branch? |
That sounds great @mamhoff. I meant to finish this over the holidays but got a little side-tracked. In order to test these I pulled https://github.com/solidusio/solidus/blob/master/core/spec/spec_helper.rb#L36 out of the spec_helper and was using a simple require 'spec_helper'
require 'spree/testing_support/factories/address_factory'
describe 'things', :type => :model do
let(:address) { create(:address) }
it "should pass" do
expect(address).to be_an(Spree::Address)
end
end The only problem is that I wasn't being super thorough testing all factories in a file, or checking all of the traits. I was planning on doing little By all means send PRs to my branch, or just open a second PR with your own fork. If you finish first I can shut this one down, or I can just cherry-pick any progress you make. It will probably be a few days before I'd get a chance to get back to this anyways. Thanks! |
Okay, it looks like all these commits are in #627 so I'm killing this PR |
This is mostly just a lot of unfortunate tree traversal, as we laboriously trace out a dependency graph.
Resolves #595