method
set_fixture_class
v5.1.7 -
Show latest stable
-
1 note -
Class: ActiveRecord::TestFixtures::ClassMethods
- 1.0.0
- 1.1.6
- 1.2.6
- 2.0.3
- 2.1.0
- 2.2.1
- 2.3.8 (0)
- 3.0.0 (0)
- 3.0.9 (0)
- 3.1.0 (0)
- 3.2.1 (0)
- 3.2.8 (0)
- 3.2.13 (0)
- 4.0.2 (38)
- 4.1.8 (0)
- 4.2.1 (0)
- 4.2.7 (0)
- 4.2.9 (0)
- 5.0.0.1 (0)
- 5.1.7 (0)
- 5.2.3 (0)
- 6.0.0 (0)
- 6.1.3.1 (0)
- 6.1.7.7 (0)
- 7.0.0 (0)
- 7.1.3.2 (0)
- 7.1.3.4 (0)
- What's this?
set_fixture_class(class_names = {})
public
Sets the model class for a fixture when the class name cannot be inferred from the fixture name.
Examples:
set_fixture_class some_fixture: SomeModel, 'namespaced/fixture' => Another::Model
The keys must be the fixture names, that coincide with the short paths to the fixture files.
Register or
log in
to add new notes.
gdelfino -
October 12, 2009
0 thanks
Use it to solve FixtureClassNotFound errors.
If you are using a non standard table name by means of set_table_name in your model:
class MyClassName < ActiveRecord::Base set_table_name "mytablename" end
then you will get FixtureClassNotFound errors when you try to use fixtures in you unit tests. To solve this use set_fixture_class inside your test:
require 'test_helper' class MyClassNameTest < ActiveSupport::TestCase set_fixture_class :mytablename => MyClassName end
and rename your fixture file to mytablename.yml