Question

How do you test a model Topic that accepts nested attributes for an Image?

Given /^I have topics titled (.+)$/ do |titles|
    path ="#{RAILS_ROOT}/features/upload-files/" 
    image = File.new(path + "image.jpg")
    titles.split(', ').each do |title|
        Topic.create!(:title => title, :image => File.new(image) ) # this doesn't work!
    end
end
Was it helpful?

Solution

Topic.create!(:title => title, :image_attributes => {:image => File.new(image) } ) # this works!
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top