2012-02-29 65 views
7

今天上午,我有以下錯誤:RSpec的和機械師錯誤:打開的文件太多

14) Deal on creation sets frozen to false or nil 
    Failure/Error: Unable to find matching line from backtrace 
    Errno::EMFILE: 
     Too many open files - identify -format %wx%h '/var/folders/BJ/BJcTANEBFxWcan28U2YEKE+++TI/-Tmp-/stream20120229-36866-4l1sa8.gif[0]' 
    # ./spec/support/blueprints.rb:29:in `block in <top (required)>' 

規格是如此該死的緩慢(甚至叉勺),所以它們是無用的。在模型中運行20個示例需要9分鐘。在blueprint.rb線29以下塊之間:

Company.blueprint do 
    name { "Office Tronic#{rand(10 ** 10)}" } 
    website { 'officetronic.com' } 
    subdomain {"officetronic#{rand(10 ** 10)}"} 
    facebook { 'officetronic' } 
    twitter { 'officetronic' } 
    description { 'We are a company dealing with electronics and office supply' } 
    address_line1 {'34 John Street'} 
    address_line2 {''} 
    post_code { 'EC2 3RR' } 
    phone { '01 343243434' } 
    city { 'London' } 
    your_name { 'john Doe' } 
    font_colour {'000000'} 
    logo_file_name { 'mylogo.png' } 
    logo_content_type { "application/png" } 
    logo_file_size { 100 } 
end 

Deal.blueprint do 
    company {Company.make!} 
    title { '50% off for web sites dev' } 
    description { '50% of discount...' } 
    quantity { 1 } 
    min_quantity { 0 } 
    start_time { Chronic.parse('one month') } 
    end_time { Chronic.parse('two months') } 
    price { 1500 } # in cents 
    shipping_cost{ 100 } # in cents 
    published { true } 
    small_print { 'Some text' } 
    show_map { true } 
    post_code { 'E1 6BJ' } 
    rrp {15} 
end 
+0

我意識到這個錯誤發生在使用spork時:rspec --drb spec/models/deal_spec.rb – rtacconi 2012-02-29 14:24:00

回答

10

打開了太多文件是操作系統錯誤,這意味着該操作系統已用完文件句柄。 Linux通常對可以同時打開多少個文件有嚴格的限制,並且已經達到了限制。

要暫時提高限制,請先運行ulimit -n 8192,然後運行規格。

要永久增加限制,follow these instructions,並與您正在使用運行規範的用戶帳戶的名稱來替代nginx

相關問題