A plugin for the Merb framework and DataMapper that provides a way to create records from YAML files.
Send this method in merb irb console, merb -i >> Merb::Fixtures.load_fixture("filename without extension", "file2", "file3") Or merb -i >> MF.load_fixture(:file1, :file2) is also possible. When using rspec, - load_fixture method : loading data - fixtures method : accessing to loaded data - :given_fixture option : specify fixture file names that a ExampleGroup uses. By default DataMapper.auto_migrate! is called before storing records. This option is available for disabling this behavior. Merb::Plugins.config[:sweet_merb_fixtures][:auto_migrate] = false Or you can override Merb::Fixture.prepare_database method. These method are chainable: Merb::Fixtures::Hash#code_to_create_record Merb::Fixtures::Hash#code_to_create_child_record Merb::Fixtures::Hash#code_to_report Merb::Fixtures::Hash#code_to_report_errors
You can specify the directory for fixture YAML files by Merb::Plugins.config[:sweet_merb_fixtures][:fixture_dir] = path / to / your_dir If you don't specify any direcotry, Merb.dir_for(:lib) / fixtures is used.
1. you can write parameters of multiple storage in a file. cats: - name: Tama - name: Tora dogs: - name: Pochi - name: Hachi 2. you can specify the one to many associations and :through associations. parents: - name: Tama children: - name: Tora 3. you can specify the name of records. cats: - # pass string as id id: white name: Tama 4. you can specify the common value of records. cats: # The way could be better. :"{color: white}" - name: Tama - name: Shiro 5. you can write erb code in yaml file cats: - name: <%= "a" * 5 %> More details are in spec doc, actually possible ways are gradually increasing, it's better to see YAML files under spec/fixture/lib/fixtures/*.yml.