14 Sep 2012, 17:08
Generic-user-small

Oliver Gottwald (2 posts)

Hi,
I have a ActiveRecord in Rails that has a
serialize :file_names, Array
field

In my cucumber details.feature I have something like the following: Given the following details exist effect_date comp_id file_names sent_at 2012-03-01 1 t1.p,t2.p 2012-04-01 2012-05-01 1 t1.p,t2.p 2012-04-01

when I run my cucumber test I get the following error:
Attribute was supposed to be a Array, but was a String (ActiveRecord::SerializationTypeMismatch) ./features/step_definitions/pickle_steps.rb:15:in `/^the following ((

14 Sep 2012, 18:00
Generic-user-small

Oliver Gottwald (2 posts)

I was able to figure this out. By doing the following code snipped in the ActiveRecord i did the following:

before_validation :update_file_names
def update_file_names
  if file_names_changed? and !file_names.is_a?(Array)
    self.file_names = self.file_names.split(',').collect(&:strip) 
  end
end
  You must be logged in to comment