ruby on rails - Rspec/FactoryGirl: NoMethodError: undefined method 'description' for true:TrueClass -
exchange communidad. trying write feature test ror program, getting following error when run rspec
:
failure/error: page.should have_content entry.description nomethoderror: undefined method `description' true:trueclass
here context in error being thrown:
entries.each |entry| page.should have_content entry.description end
where entries
defined earlier in same test follows:
entries = 5.times.map factorygirl.create(:entry, project_id: proj.id, :date => 9/10/13, :type_of_work => 'chump', :description => 'chumpin', :phase => 'draft', :status => 'draft' , :on_off_site => 'off', :user_id => 1, :start_time => now, :end_time => later).should be_valid end
entry
model has attribute of type string called description
testing against , returning true:trueclass nonsense.
any leads? thank kindly!
while creating entry records via factorygirl using "should be_valid" method returning boolean object. so, in entries array, have boolean values.
entries = [true,true,true,true,true]
thats why giving error:
undefined method `description' true:trueclass
you should array of active_records in entries variable. try code:
entries = 5.times.map entry = factorygirl.create(:entry, project_id: proj.id, :date => 9/10/13, :type_of_work => 'chump', :description => 'chumpin', :phase => 'draft', :status => 'draft' , :on_off_site => 'off', :user_id => 1, :start_time => now, :end_time => later) entry.should be_valid entry end
it return active_record array , can use related methods.
Comments
Post a Comment