module FixtureToFactory

Constants

VERSION

Public Class Methods

execute(options) click to toggle source
# File lib/fixture_to_factory.rb, line 9
def self.execute(options)
  ['./test', './spec'].each do |folder|
    prefix = options.delete(:prefix) || ''
    folder = "#{prefix}#{folder}"

    # This looks in a directory given and returns the fixtures in a hash form
    # filename => [fixture1, fixture2]
    parsed_fixtures = FixtureFileParser.parse_files("#{folder}/fixtures")

    # Then we pass the hashes to the writer to convert them into factory files
    FactoryWriter.write_files("#{folder}/factories", parsed_fixtures)
  end
end