【发布时间】:2013-07-14 15:19:23
【问题描述】:
我正在使用回形针 gem 上传图片。
我有一个看起来像这样的测试;
describe Person do
it { should have_attached_file(:image_one) }
end
在我的模型中,我有以下代码
class Person < ActiveRecord::Base
attr_accessible :first_name, :last_name, :gender, :story, :image_one
has_attached_file :image_one
end
但测试仍然失败。
我的 spec_helper 文件中还有以下内容
require 'paperclip/matchers'
config.include Paperclip::Shoulda::Matchers
是不是我做错了什么?
【问题讨论】:
-
配置块中有
config.include Paperclip::Shoulda::Matchers吗? -
是的,它在区块中
-
您遇到什么错误?你使用的是什么版本的 Rails?
-
FWIW,Rails 4 中的类定义和规范“通过”,没有
attr_accessible行,现在已弃用。 -
我正在使用 rails-3.2.13 并且测试失败并显示以下消息。 “失败/错误:它 { should have_attached_file(:image_one) } 应该有一个名为 image_one 的附件”
标签: ruby-on-rails rspec paperclip