के साथ लटकने वाले रुपेक परीक्षण मेरे पास मेरे ऐप में एक पिक्चर मॉडल है जो पेपरक्लिप का उपयोग छवि को संलग्न करने के लिए करता है।पेपरक्लिप
मॉडल:
class Picture < ActiveRecord::Base
has_attached_file :image, :default_url => "/system/:attachment/missing.png", :styles => { :small => "100x100#", :medium => "460x460>", :large => "1024x1024>" }
validates_attachment_presence :image
validates_attachment_content_type :image, :content_type => [/image\/(x-)?png/i, /image\/(p)?jpeg/i]
validates_attachment_size :image, :less_than => 5.megabytes
validates_presence_of :name
validates_format_of :name, :with => /^[a-z0-9_\[email protected]#%&()' ]+$/i
end
जब मैं अपने परीक्षण चलाने वे लॉग में परीक्षण के इस भाग पर लटका:
Processing PagesController#index (for 0.0.0.0 at 2010-07-10 11:29:54) [GET]
Parameters: {"action"=>"index", "controller"=>"pages"}
Picture Load (0.2ms) SELECT * FROM "pictures" LIMIT 1
Rendering template within layouts/application
Rendering pages/index
Completed in 2ms (View: 0, DB: 0) | 200 OK [http://test.host/index]
[paperclip] identify '-format' '%wx%h' '/var/folders/cD/cDCiDnTlH5ehwTjJq1pxYE+++TI/-Tmp-/stream,6515,0.txt[0]' 2>/dev/null
मेरे पेज नियंत्रक इस तरह दिखता है:
class PagesController < ApplicationController
def index
@picture = Picture.first ? Picture.first : Picture.new
end
end
नियंत्रक के लिए परीक्षण इस तरह दिखता है:
describe PagesController do
describe "GET 'index'" do
before(:each) do
get :index
end
it "should be successful" do
response.should be_success
end
it "should assign picture" do
assigns[:picture].should_not be_nil
end
it "should assign a valid picture" do
assigns[:picture].class.should == Picture
end
end
end
मेरे परीक्षण भी फांसी कर रहे हैं जब rake spec:models
चल रहा यह सिर्फ लॉग में
[paperclip] identify '-format' '%wx%h' '/var/folders/cD/cDCiDnTlH5ehwTjJq1pxYE+++TI/-Tmp-/stream,6515,0.txt[0]' 2>/dev/null
लाइन को दर्शाता है। मेरा मॉडल टेस्ट इस तरह दिखता है:
describe Picture do
it { should have_attached_file(:image) }
it { should validate_attachment_presence(:image) }
it {
should validate_attachment_content_type(:image).
allowing('image/png', 'image/x-png', 'image/jpeg', 'image/pjpeg').
rejecting('text/plain', 'text/xml', 'image/tiff')
}
it { should validate_attachment_size(:image).less_than(5.megabytes) }
it { should validate_presence_of(:name) }
["Client's website", "This is a great site!", "my_awes0me-s!te"].each do |phrase|
it { should allow_value(phrase).for(:name) }
end
["Client's web$ite", "This is a great^ site!", "my_awes;0me-s!te"].each do |phrase|
it { should_not allow_value(phrase).for(:name) }
end
context "is new" do
it "should have a default missing image" do
picture = Picture.new
picture.image.url.should == "/system/images/missing.png"
end
end
end
यह ठंडा क्यों है? (यदि मैं थोड़ी देर के लिए मॉडल परीक्षण चलाता है तो यह धीरे-धीरे चलता है, ऐसा लगता है कि यह सभी रूपांतरण चला रहा है, मैं इन्हें कैसे रोक सकता हूं?)