Fabricating cyclic dependencies with Fabrication [fabrication_gem]

280 views Asked by At

Okay, I didn't create this code, but I do need to find a good way to test it. We have been using factory_girl and minitest, but have a number of issues. I'm hoping to be able to move to Rspec and the Fabrication gems to setup some new tests, however I've run into a problem with cyclic dependencies. We have something like the following:

class Owner < ActiveRecord::Base
  :validates has_inner?

  def has_inner?
    # Make sure we have an inner object
  end
end

class Inner < ActiveRecord::Base
  :belongs_to :owner
end

And I have Fabricators for each, something like:

Fabricator(:owner) do
  inner
end

Fabricator(:inner) do
end

Anyone have any ideas on how I can pull this off? Is it possible?

1

There are 1 answers

1
Paul Elliott On

I don't see any relationship defined from Owner to Inner. Is it a has_many? A little more details would be great.