Skip to content
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

Closed
wants to merge 12 commits into from

Conversation

Sinetheta
Copy link
Contributor

This is mostly just a lot of unfortunate tree traversal, as we laboriously trace out a dependency graph.

Resolves #595

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@tvdeyen
Copy link
Member

tvdeyen commented Dec 24, 2015

Yeah. What a Christmas present!!! Thank you so very much @Sinetheta 🎄🎄🎅🏻🎅🏻

@mamhoff
Copy link
Contributor

mamhoff commented Dec 27, 2015

@Sinetheta This is really, really nice stuff. There's a bit of stuff missing; if you want help - can I PR against your branch?

@Sinetheta
Copy link
Contributor Author

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 test_spec.rb where I would just swap out the factory I wanted to isolate.

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 --fixups where needed.

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!

This was referenced Dec 29, 2015
@cbrunsdon
Copy link
Contributor

Okay, it looks like all these commits are in #627 so I'm killing this PR

@cbrunsdon cbrunsdon closed this Dec 31, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants