mardi 31 janvier 2017

Error on unit testing in rails

I got same errors for all functions in test_controller.rb the error was following

ClassTimingsControllerTest#test_should_be_create: ActiveRecord::Fixture::FormatError: ActiveRecord::Fixture::FormatError Error: ClassTimingsControllerTest#test_should_be_create: NoMethodError: undefined method `each' for nil:NilClass

Here my code in test_controller.rb

test 'should be create' do
assert_difference('Faculty.count') do
  post :create, class_timing: { created_by: @class_timing.created_by, school_year: @class_timing.school_year,
                                standard_id: @class_timing.standard_id, period_name: @class_timing.period_name,
                                org_id: @class_timing.org_id, period_no: @class_timing.period_no,
                                from_time: @class_timing.from_time, to_time: @class_timing.to_time,
                                is_break: @class_timing.is_break, updated_by: @class_timing.updated_by }
end
assert_redirected_to faculty_path(assigns(:class_timing))

end Here my yml code in Fixtures

one: class_timing_id: org_id: 1 school_year: 2016 standard_id: 1 period_no: 1 period_name: MyString from_time: 2017-01-12 04:30:00 to_time: 2017-01-12 05:30:00 is_break: 1 created_by: MyString updated_by: MyString

How can I fix the issue.

Aucun commentaire:

Enregistrer un commentaire