Module: FixtureToFactory

Defined in:
lib/fixture_to_factory.rb,
lib/fixture_to_factory/version.rb,
lib/fixture_to_factory/factory_writer.rb,
lib/fixture_to_factory/fixture_file_parser.rb

Defined Under Namespace

Classes: FactoryWriter, FixtureFileParser

Constant Summary collapse

VERSION =
"0.0.1"

Class Method Summary collapse

Class Method Details

.execute(options) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
# 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