I am trying to set up the rails testing framework but am facing some issues. My setup is as follows
test/models/clinic_test.rb
require 'test_helper'
class ClinicTest < ActiveSupport::TestCase
test "sample" do
clinic = clinics(:myclinic)
assert(clinic.name == 'Krishan')
end
end
test/fixtures/clinics.yml
myclinic:
name: Krishan
But when I run the clinic_test rake process I get the following error:
ActiveRecord::FixtureClassNotFound: No class attached to find
test/models/clinic_test.rb:5:in `block in <class:ClinicTest>'
I see that the database is actually populated with the sample data from the clinics.yml file.
Where is the problem? Is this some configuration issue?
Add following lines in test_helper.rb file, before fixtures :all
class ActiveSupport::TestCase
self.use_transactional_fixtures = true
set_fixture_class clinics: Clinic
fixtures :all
...
end
clinics is the name of yml file where Clinic is the name of model.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With