0
我正在创建一个程序,它将检查由用户登录的图像。我有RMagick代码写入做检查(基本上发现如果一个像素黑色在图像中),但我不知道如何为这个模型编写单元测试。使用附件的功能的轨道单元测试
目前我正在使用回形针将上传的文件附加到模型上,我知道使用数据库中的多个字段来跟踪文件。我应该如何设置我的灯具,以便每次都能对相同的数据进行单元测试?
我的模型是目前:
class Map < ActiveRecord::Base
has_attached_file :image, :styles => { :small => "150x150>" }
validates_attachment_presence :image
validates_uniqueness_of :name, :message => "must be unique"
def pixel_is_black(x, y)
<code to return true if position (x,y) in image is black>
end
end