I’ve looked at the rails guide to testing but I can seem to get fixture data from inside my test. I have a fixture:
one:
pay_period: one
employee: kent
cpp: 50
ei: 40
tax: 100
vacation_pay: 30
Then I have a test as per below (where EmployeePayPeriod is a model)
require 'test_helper'
class EmployeePayPeriodTest < ActiveSupport::TestCase
# Replace this with your real tests.
test "Calculate wages under 80 hours correctly" do
p = EmployeePayPeriod(:one)
assert true
end
end
Obviously the above isn’t working. I’ve looked at the guide. In the guide it uses a code snippet to illustrate how you get fixture data:
@user = users(:david).
It seems that ‘users’ isn’t a model (because the normal convention is that it would singular and capitalized. So where does ‘users’ come from? If its autogenerated should there be a comparable ’employee_pay_periods’ object available for me? (I’ve tried, but it doesn’t seem to work).
Thanks
I believe users is a convention based on the yml filename. In the example, they have a
users.yml. So, to answer your question more directly, try whatever the name of your .yml fixture file is.Something that might be easier in the long run, though, is something like FactoryGirl, Machinist, or fixjour