0
这个规范在我的CentOS开发框中通过,但在我的Macbook(10.7)上运行时失败。为什么此模型测试通过CentOS,但在Mac OS X(Lion)上失败?
应用程序/模型/ issue.rb
class Issue < ActiveRecord::Base
has_attached_file :cover_image,
:styles => {
:thumbnail => ["80x80>"],
:large => ["600x600>"]
},
:path => ":rails_root/public/images/issues/:id/:style_:basename.:extension",
:url => "issues/:id/:style_:basename.:extension"
validates_attachment_content_type :cover_image, :content_type => ['image/jpeg', 'image/png']
attr_protected :cover_image_file_name, :cover_image_content_type, :cover_image_file_size
end
规格/型号/ issue_spec.rb
require 'spec_helper'
describe Issue do
it 'should not accept invalid image types' do
%w[spec/factories/assets/docs/image.jpg spec/factories/assets/docs/image.txt].each do |file_path| #image.jpg is a text file with a .jpg extension
issue = Factory.build(:issue, :cover_image => File.new(Rails.root + file_path))
issue.should have(2).errors_on(:cover_image)
end
end
end
在我的CentOS的发展中,我没有得到任何的故障,当我运行测试。我的MacBook我得到这个错误:如果我尝试通过在浏览器上载无效图像类型之一,以创建一个问题
Failure/Error: issue.should have(2)errors_on(:cover_image)
expected 2 errors on :cover_image, got 0
在两台机器上,它失败,出现错误消息我想到,如果我用传递一个有效的图像类型。
paperclip-2.4.2
rspec-2.6.0
factory_girl_rails-1.2.0
CentOS: ImageMagick-6.2.8 (yum package)
Mac OS X: ImageMagick-6.7.2-0 (Macports)