我的上传功能测试在 Rails 中不起作用?

发布于 2024-11-29 21:55:19 字数 19250 浏览 1 评论 0原文

And I attach the file "spec/test_photo.jpg" to "payment_object_file_attachment" # features/step_definitions/web_steps.rb:105
And I click on "Upload"                                                         # features/step_definitions/web_steps.rb:52
Then show me the page                                                           # features/step_definitions/web_steps.rb:213
And I should see "Documents [1]"                                                # features/step_definitions/web_steps.rb:109
  expected there to be content "Documents [1]" in "Internal Server Error\n\nbad content body\nWEBrick/1.3.1 (Ruby/1.9.2/2011-07-09) at 127.0.0.1:61672" (RSpec::Expectations::ExpectationNotMetError)
  ./features/step_definitions/web_steps.rb:111:in `/^(?:|I )should see "([^"]*)"$/'
  features/manage_payment_object_documents.feature:14:in `And I should see "Documents [1]"'

来自 Cucumber

那么为什么我会收到内部服务器错误

test.log 也非常无用:

Started POST "/accounting/payment_objects/15/files" for 127.0.0.1 at 2011-08-16 13:03:21 +0800
  Processing by Accounting::FilesController#create as HTML
  Parameters: {"utf8"=>"✓", "payment_object_file"=>{"attachment"=>#<ActionDispatch::Http::UploadedFile:0x007f82d9277960 @original_filename="test_photo.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"payment_object_file[attachment]\"; filename=\"test_photo.jpg\"\r\nContent-Type: image/jpeg\r\n", @tempfile=#<File:/var/folders/8b/lwp04gwn4kz02gspddmw56c80000gs/T/RackMultipart20110816-81422-sav3wt>>}, "commit"=>"Upload", "payment_object_id"=>"15"}
  User Load (0.4ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 55 ORDER BY name ASC LIMIT 1
  SQL (0.3ms)  SELECT COUNT(*) FROM `companies` WHERE `companies`.`id` = 56
  Company Load (0.1ms)  SELECT `companies`.* FROM `companies` WHERE `companies`.`id` = 56 ORDER BY name ASC LIMIT 1
  Permission Load (0.3ms)  SELECT `permissions`.* FROM `permissions` WHERE `permissions`.`subject_id` = 56 AND (`permissions`.user_id = 55)
  PaymentObject Load (0.2ms)  SELECT `payment_objects`.* FROM `payment_objects` WHERE `payment_objects`.`id` = 15 AND (`payment_objects`.company_id = 56) ORDER BY id DESC LIMIT 1
[paperclip] identify -format %wx%h '/var/folders/8b/lwp04gwn4kz02gspddmw56c80000gs/T/stream20110816-81422-iuaoiv.jpg[0]' 2>/dev/null
[paperclip] convert '/var/folders/8b/lwp04gwn4kz02gspddmw56c80000gs/T/stream20110816-81422-iuaoiv.jpg[0]' -resize "128x128" '/var/folders/8b/lwp04gwn4kz02gspddmw56c80000gs/T/stream20110816-81422-iuaoiv20110816-81422-59eeoa' 2>/dev/null
  SQL (0.2ms)  SAVEPOINT active_record_1
  PaymentObject Load (0.5ms)  SELECT `payment_objects`.* FROM `payment_objects` WHERE `payment_objects`.`id` = 15 ORDER BY id DESC LIMIT 1
  CACHE (0.0ms)  SELECT `companies`.* FROM `companies` WHERE `companies`.`id` = 56 ORDER BY name ASC LIMIT 1
  SQL (0.2ms)  SELECT COUNT(*) FROM `payment_object_files` WHERE ((`payment_object_files`.`payment_object_id` = 15 AND `payment_object_files`.`md5_checksum` = '386908b62aa3f02213bcb9c74960f92d'))
  SQL (0.7ms)  describe `payment_object_files`
  AREL (0.2ms)  INSERT INTO `payment_object_files` (`payment_object_id`, `user_id`, `company_id`, `md5_checksum`, `attachment_file_name`, `attachment_content_type`, `attachment_file_size`, `attachment_updated_at`) VALUES (15, 55, 56, '386908b62aa3f02213bcb9c74960f92d', 'test_photo.jpg', 'image/jpeg', 83283, '2011-08-16 05:03:21')
  AREL (0.3ms)  UPDATE `payment_objects` SET `updated_at` = '2011-08-16 05:03:21' WHERE `payment_objects`.`id` = 15
  AREL (0.1ms)  UPDATE `companies` SET `updated_at` = '2011-08-16 05:03:21' WHERE `companies`.`id` = 56
[paperclip] Saving attachments.
[paperclip] saving /Users/patrickma.uel/Sites/app/public/system/attachments/13/original/test_photo.jpg
[paperclip] saving /Users/patrickma.uel/Sites/app/public/system/attachments/13/thumb/test_photo.jpg
  SQL (0.2ms)  RELEASE SAVEPOINT active_record_1
  Company Load (0.3ms)  SELECT `companies`.* FROM `companies` WHERE `companies`.`id` = 56 ORDER BY name ASC LIMIT 1
  Permission Load (0.3ms)  SELECT `permissions`.* FROM `permissions` WHERE ((`permissions`.`subject_class` = 'PaymentObject' AND `permissions`.`action` != 'none' AND `permissions`.`subject_id` = 56))
  User Load (0.3ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 55 ORDER BY name ASC LIMIT 1
  SQL (0.1ms)  SAVEPOINT active_record_1
  AREL (0.6ms)  INSERT INTO `notifications` (`user_id`, `company_id`, `message`, `url`, `created_at`, `updated_at`, `actor_id`, `action`, `object`) VALUES (55, 56, NULL, '/accounting/payment_objects/15', '2011-08-16 05:03:21', '2011-08-16 05:03:21', 55, 'file_uploaded', '--- &70100047184420 !ruby/object:PaymentObjectFile\nattributes:\n payment_object_id: 15\n user_id: 55\n company_id: 56\n md5_checksum: 386908b62aa3f02213bcb9c74960f92d\n attachment_file_name: test_photo.jpg\n attachment_content_type: image/jpeg\n attachment_file_size: 83283\n attachment_updated_at: 2011-08-16 13:03:21.846108000 +08:00\n id: 13\nattributes_cache:\n attachment_updated_at: 2011-08-16 05:03:21.846108000Z\nnew_record: false\nreadonly: false\ndestroyed: false\nmarked_for_destruction: false\npreviously_changed:\n user_id:\n - !!null \n - 55\n attachment_file_name:\n - !!null \n - test_photo.jpg\n attachment_content_type:\n - !!null \n - image/jpeg\n attachment_file_size:\n - !!null \n - 83283\n attachment_updated_at:\n - !!null \n - 2011-08-16 05:03:21.846108000Z\n payment_object_id:\n - !!null \n - 15\n md5_checksum:\n - !!null \n - 386908b62aa3f02213bcb9c74960f92d\n company_id:\n - !!null \n - 56\n id:\n - !!null \n - 13\nchanged_attributes: {}\nerrors: !omap []\n_paperclip_attachments:\n :attachment: &70100047181200 !ruby/object:Paperclip::Attachment\n name: :attachment\n instance: *70100047184420\n url: /system/:attachment/:id/:style/:filename\n path: \':rails_root/public:url\'\n styles: &70099991918120\n :thumb:\n - 128x128\n normalized_styles:\n :thumb: !ruby/object:Paperclip::Style\n name: :thumb\n attachment: *70100047181200\n geometry: 128x128\n format: !!null \n other_args: {}\n default_url: /:attachment/:style/missing.png\n default_style: :original\n storage: :filesystem\n use_timestamp: true\n whiny: true\n use_default_time_zone: true\n hash_digest: SHA1\n hash_data: \':class/:attachment/:id/:style/:updated_at\'\n hash_secret: !!null \n convert_options: &70100046528100 {}\n processors: &70100046528120\n - :thumbnail\n options:\n :url: /system/:attachment/:id/:style/:filename\n :path: \':rails_root/public:url\'\n :styles: *70099991918120\n :processors: *70100046528120\n :convert_options: *70100046528100\n :default_url: /:attachment/:style/missing.png\n :default_style: :original\n :storage: :filesystem\n :use_timestamp: true\n :whiny: true\n :use_default_time_zone: true\n :hash_digest: SHA1\n :hash_data: \':class/:attachment/:id/:style/:updated_at\'\n :validations: []\n post_processing: true\n queued_for_delete: []\n queued_for_write: {}\n errors: {}\n dirty: false\n storage_module: !ruby/object:Module {}\n _attachment_file_name: test_photo.jpg\n _attachment_content_type: image/jpeg\n _attachment_file_size: 83283\n _attachment_fingerprint: 386908b62aa3f02213bcb9c74960f92d\n _attachment_updated_at: 2011-08-16 13:03:21.846108000 +08:00\n_start_transaction_state:\n :new_record: true\n :destroyed: false\n :level: 1\nvalidation_context: !!null \npayment_object: !ruby/object:PaymentObject\n attributes:\n id: \'15\'\n company_id: \'56\'\n delivery_date: \'2011-08-16\'\n payment_terms: CBD\n vendor: Apple\n applicant_id: \'55\'\n approved_id: !!null \n declined: \'0\'\n amount: \'1000.00\'\n last_sent: !!null \n payment_date: \'2011-08-16\'\n created_at: \'2011-08-16 05:03:20\'\n updated_at: 2011-08-16 05:03:21.921361000Z\n cancelled: !!null \n currency: HKD\n paid: \'0\'\n paid_by_id: !!null \n paid_at: !!null \n received: None\n payment_status: Pending\n company_specific_id: \'1\'\n stage: Requisition\n approved_at: !!null \n declined_at: !!null \n attributes_cache: {}\n new_record: false\n readonly: false\n destroyed: false\n marked_for_destruction: false\n previously_changed: {}\n changed_attributes: {}\n company: !ruby/object:Company\n attributes:\n id: \'56\'\n name: Urban Entertainment Ltd.\n created_at: \'2011-08-16 05:03:18\'\n updated_at: 2011-08-16 05:03:21.925477000Z\n company_group_id: \'0\'\n currency: HKD\n api_key: 3c4caf936ce6c3b0c98075d24b4e6514\n attributes_cache: {}\n new_record: false\n readonly: false\n destroyed: false\n marked_for_destruction: false\n previously_changed: {}\n changed_attributes: {}\ncompany: !ruby/object:Company\n attributes:\n id: \'56\'\n name: Urban Entertainment Ltd.\n created_at: \'2011-08-16 05:03:18\'\n updated_at: \'2011-08-16 05:03:21\'\n company_group_id: \'0\'\n currency: HKD\n api_key: 3c4caf936ce6c3b0c98075d24b4e6514\n attributes_cache: {}\n new_record: false\n readonly: false\n destroyed: false\n marked_for_destruction: false\n previously_changed: {}\n changed_attributes: {}\n')
  SQL (0.1ms)  RELEASE SAVEPOINT active_record_1
Redirected to http://127.0.0.1:62127/accounting/payment_objects/15
Completed 302 Found in 218ms


Started GET "/accounting/payment_objects/15" for 127.0.0.1 at 2011-08-16 13:03:21 +0800
  SQL (1.4ms)  ROLLBACK

所以是的,我不知道如何通过了解我的数据库在 GET 请求上回滚来真正诊断错误。

让事情变得更加混乱的是,我可以上传开发中的图片,并且当我在 Cucumber 之外执行时,所有步骤似乎都很好。

更新:

我创建了一个演示应用程序来查看是否可以上传文件,并正确进行重定向和保存过程,而且确实如此。

来自原型应用程序的 Gemfile.lock:

GEM
  remote: http://rubygems.org/
  specs:
    abstract (1.0.0)
    actionmailer (3.0.9)
      actionpack (= 3.0.9)
      mail (~> 2.2.19)
    actionpack (3.0.9)
      activemodel (= 3.0.9)
      activesupport (= 3.0.9)
      builder (~> 2.1.2)
      erubis (~> 2.6.6)
      i18n (~> 0.5.0)
      rack (~> 1.2.1)
      rack-mount (~> 0.6.14)
      rack-test (~> 0.5.7)
      tzinfo (~> 0.3.23)
    activemodel (3.0.9)
      activesupport (= 3.0.9)
      builder (~> 2.1.2)
      i18n (~> 0.5.0)
    activerecord (3.0.9)
      activemodel (= 3.0.9)
      activesupport (= 3.0.9)
      arel (~> 2.0.10)
      tzinfo (~> 0.3.23)
    activeresource (3.0.9)
      activemodel (= 3.0.9)
      activesupport (= 3.0.9)
    activesupport (3.0.9)
    arel (2.0.10)
    builder (2.1.2)
    capybara (1.0.1)
      mime-types (>= 1.16)
      nokogiri (>= 1.3.3)
      rack (>= 1.0.0)
      rack-test (>= 0.5.4)
      selenium-webdriver (~> 2.0)
      xpath (~> 0.1.4)
    capybara-webkit (0.6.0)
      capybara (~> 1.0.0)
    childprocess (0.2.1)
      ffi (~> 1.0.6)
    cocaine (0.1.0)
    cucumber (1.0.2)
      builder (>= 2.1.2)
      diff-lcs (>= 1.1.2)
      gherkin (~> 2.4.5)
      json (>= 1.4.6)
      term-ansicolor (>= 1.0.5)
    cucumber-rails (1.0.2)
      capybara (>= 1.0.0)
      cucumber (~> 1.0.0)
      nokogiri (>= 1.4.6)
    database_cleaner (0.6.7)
    diff-lcs (1.1.2)
    erubis (2.6.6)
      abstract (>= 1.0.0)
    ffi (1.0.9)
    gherkin (2.4.6)
      json (>= 1.4.6)
    haml (3.1.2)
    i18n (0.5.0)
    json (1.5.3)
    json_pure (1.5.3)
    mail (2.2.19)
      activesupport (>= 2.3.6)
      i18n (>= 0.4.0)
      mime-types (~> 1.16)
      treetop (~> 1.4.8)
    mime-types (1.16)
    nokogiri (1.5.0)
    paperclip (2.3.16)
      activerecord (>= 2.3.0)
      activesupport (>= 2.3.2)
      cocaine (>= 0.0.2)
      mime-types
    polyglot (0.3.2)
    rack (1.2.3)
    rack-mount (0.6.14)
      rack (>= 1.0.0)
    rack-test (0.5.7)
      rack (>= 1.0)
    rails (3.0.9)
      actionmailer (= 3.0.9)
      actionpack (= 3.0.9)
      activerecord (= 3.0.9)
      activeresource (= 3.0.9)
      activesupport (= 3.0.9)
      bundler (~> 1.0)
      railties (= 3.0.9)
    railties (3.0.9)
      actionpack (= 3.0.9)
      activesupport (= 3.0.9)
      rake (>= 0.8.7)
      rdoc (~> 3.4)
      thor (~> 0.14.4)
    rake (0.9.2)
    rdoc (3.9.2)
    rspec (2.6.0)
      rspec-core (~> 2.6.0)
      rspec-expectations (~> 2.6.0)
      rspec-mocks (~> 2.6.0)
    rspec-core (2.6.4)
    rspec-expectations (2.6.0)
      diff-lcs (~> 1.1.2)
    rspec-mocks (2.6.0)
    rspec-rails (2.6.1)
      actionpack (~> 3.0)
      activesupport (~> 3.0)
      railties (~> 3.0)
      rspec (~> 2.6.0)
    rubyzip (0.9.4)
    selenium-webdriver (2.4.0)
      childprocess (>= 0.2.1)
      ffi (>= 1.0.7)
      json_pure
      rubyzip
    sqlite3 (1.3.4)
    term-ansicolor (1.0.6)
    thor (0.14.6)
    treetop (1.4.10)
      polyglot
      polyglot (>= 0.3.1)
    tzinfo (0.3.29)
    xpath (0.1.4)
      nokogiri (~> 1.3)

PLATFORMS
  ruby

DEPENDENCIES
  capybara
  capybara-webkit
  cucumber-rails
  database_cleaner
  haml
  paperclip
  rails (= 3.0.9)
  rspec-rails
  sqlite3

来自损坏应用程序的 Gemfile.lock:

GEM
  remote: http://rubygems.org/
  specs:
    Saikuro (1.1.0)
    abstract (1.0.0)
    actionmailer (3.0.9)
      actionpack (= 3.0.9)
      mail (~> 2.2.19)
    actionpack (3.0.9)
      activemodel (= 3.0.9)
      activesupport (= 3.0.9)
      builder (~> 2.1.2)
      erubis (~> 2.6.6)
      i18n (~> 0.5.0)
      rack (~> 1.2.1)
      rack-mount (~> 0.6.14)
      rack-test (~> 0.5.7)
      tzinfo (~> 0.3.23)
    activemodel (3.0.9)
      activesupport (= 3.0.9)
      builder (~> 2.1.2)
      i18n (~> 0.5.0)
    activerecord (3.0.9)
      activemodel (= 3.0.9)
      activesupport (= 3.0.9)
      arel (~> 2.0.10)
      tzinfo (~> 0.3.23)
    activeresource (3.0.9)
      activemodel (= 3.0.9)
      activesupport (= 3.0.9)
    activesupport (3.0.9)
    addressable (2.2.6)
    arel (2.0.10)
    arrayfields (4.7.4)
    bcrypt-ruby (2.1.4)
    builder (2.1.2)
    cancan (1.6.5)
    capistrano (2.8.0)
      highline
      net-scp (>= 1.0.0)
      net-sftp (>= 2.0.0)
      net-ssh (>= 2.0.14)
      net-ssh-gateway (>= 1.1.0)
    capybara (1.0.1)
      mime-types (>= 1.16)
      nokogiri (>= 1.3.3)
      rack (>= 1.0.0)
      rack-test (>= 0.5.4)
      selenium-webdriver (~> 2.0)
      xpath (~> 0.1.4)
    capybara-webkit (0.6.0)
      capybara (~> 1.0.0)
    childprocess (0.2.1)
      ffi (~> 1.0.6)
    chronic (0.3.0)
    churn (0.0.13)
      chronic (>= 0.2.3)
      hirb
      json_pure
      main
      ruby_parser (~> 2.0.4)
      sexp_processor (~> 3.0.3)
    cocaine (0.1.0)
    colored (1.2)
    cucumber (1.0.2)
      builder (>= 2.1.2)
      diff-lcs (>= 1.1.2)
      gherkin (~> 2.4.5)
      json (>= 1.4.6)
      term-ansicolor (>= 1.0.5)
    cucumber-rails (1.0.2)
      capybara (>= 1.0.0)
      cucumber (~> 1.0.0)
      nokogiri (>= 1.4.6)
    database_cleaner (0.6.7)
    devise (1.4.2)
      bcrypt-ruby (~> 2.1.2)
      orm_adapter (~> 0.0.3)
      warden (~> 1.0.3)
    diff-lcs (1.1.2)
    erubis (2.6.6)
      abstract (>= 1.0.0)
    escape_utils (0.2.3)
    factory_girl (2.0.4)
    factory_girl_rails (1.1.0)
      factory_girl (~> 2.0.0)
      railties (>= 3.0.0)
    fattr (2.2.0)
    ffi (1.0.9)
    flay (1.4.3)
      ruby_parser (~> 2.0)
      sexp_processor (~> 3.0)
    flog (2.5.2)
      ruby_parser (~> 2.0)
      sexp_processor (~> 3.0)
    gherkin (2.4.6)
      json (>= 1.4.6)
    google_currency (1.2.0)
      money (~> 3.5)
    growl (1.0.3)
    haml (3.1.2)
    highline (1.6.2)
    hirb (0.5.0)
    i18n (0.5.0)
    jquery-rails (1.0.13)
      railties (~> 3.0)
      thor (~> 0.14)
    json (1.5.3)
    json_pure (1.5.3)
    launchy (2.0.5)
      addressable (~> 2.2.6)
    mail (2.2.19)
      activesupport (>= 2.3.6)
      i18n (>= 0.4.0)
      mime-types (~> 1.16)
      treetop (~> 1.4.8)
    main (4.6.0)
      arrayfields (>= 4.7.4)
      fattr (>= 2.1.0)
      map (>= 2.0.0)
    map (4.2.0)
    memcache (1.2.13)
    memcache-client (1.8.5)
    meta_where (1.0.4)
      activerecord (~> 3.0.0)
      activesupport (~> 3.0.0)
      arel (~> 2.0.7)
    metric_fu (2.1.1)
      Saikuro (>= 1.1.0)
      activesupport (>= 2.0.0)
      chronic (~> 0.3.0)
      churn (>= 0.0.7)
      flay (>= 1.2.1)
      flog (>= 2.3.0)
      rails_best_practices (>= 0.6.4)
      rcov (>= 0.8.3.3)
      reek (>= 1.2.6)
      roodi (>= 2.1.0)
      syntax
    mime-types (1.16)
    money (3.7.1)
      i18n (~> 0.4)
    mysql (2.8.1)
    net-scp (1.0.4)
      net-ssh (>= 1.99.1)
    net-sftp (2.0.5)
      net-ssh (>= 2.0.9)
    net-ssh (2.1.4)
    net-ssh-gateway (1.1.0)
      net-ssh (>= 1.99.1)
    nokogiri (1.5.0)
    orm_adapter (0.0.5)
    paperclip (2.3.16)
      activerecord (>= 2.3.0)
      activesupport (>= 2.3.2)
      cocaine (>= 0.0.2)
      mime-types
    polyglot (0.3.2)
    rack (1.2.3)
    rack-mount (0.6.14)
      rack (>= 1.0.0)
    rack-test (0.5.7)
      rack (>= 1.0)
    rails (3.0.9)
      actionmailer (= 3.0.9)
      actionpack (= 3.0.9)
      activerecord (= 3.0.9)
      activeresource (= 3.0.9)
      activesupport (= 3.0.9)
      bundler (~> 1.0)
      railties (= 3.0.9)
    rails_best_practices (0.10.1)
      activesupport
      colored
      erubis
      haml
      i18n
      ruby-progressbar
      ruby_parser
    railties (3.0.9)
      actionpack (= 3.0.9)
      activesupport (= 3.0.9)
      rake (>= 0.8.7)
      rdoc (~> 3.4)
      thor (~> 0.14.4)
    rake (0.9.2)
    rb-fsevent (0.4.3)
    rcov (0.9.10)
    rdoc (3.9.2)
    reek (1.2.8)
      ruby2ruby (~> 1.2)
      ruby_parser (~> 2.0)
      sexp_processor (~> 3.0)
    roodi (2.1.0)
      ruby_parser
    rspec (2.6.0)
      rspec-core (~> 2.6.0)
      rspec-expectations (~> 2.6.0)
      rspec-mocks (~> 2.6.0)
    rspec-core (2.6.4)
    rspec-expectations (2.6.0)
      diff-lcs (~> 1.1.2)
    rspec-mocks (2.6.0)
    rspec-rails (2.6.1)
      actionpack (~> 3.0)
      activesupport (~> 3.0)
      railties (~> 3.0)
      rspec (~> 2.6.0)
    ruby-progressbar (0.0.10)
    ruby2ruby (1.2.5)
      ruby_parser (~> 2.0)
      sexp_processor (~> 3.0)
    ruby_parser (2.0.6)
      sexp_processor (~> 3.0)
    rubyzip (0.9.4)
    sass (3.1.7)
    selenium-webdriver (2.4.0)
      childprocess (>= 0.2.1)
      ffi (>= 1.0.7)
      json_pure
      rubyzip
    sexp_processor (3.0.5)
    shoulda (2.11.3)
    syntax (1.0.0)
    term-ansicolor (1.0.6)
    thor (0.14.6)
    treetop (1.4.10)
      polyglot
      polyglot (>= 0.3.1)
    tzinfo (0.3.29)
    warden (1.0.5)
      rack (>= 1.0)
    xpath (0.1.4)
      nokogiri (~> 1.3)

PLATFORMS
  ruby

DEPENDENCIES
  cancan
  capistrano
  capybara
  capybara-webkit
  cucumber
  cucumber-rails
  database_cleaner
  devise
  escape_utils
  factory_girl
  factory_girl_rails
  google_currency
  growl
  haml
  jquery-rails
  json
  launchy
  memcache
  memcache-client
  meta_where
  metric_fu
  mime-types
  money
  mysql
  paperclip
  rails (= 3.0.9)
  rb-fsevent
  rspec-rails
  sass
  shoulda
  warden
And I attach the file "spec/test_photo.jpg" to "payment_object_file_attachment" # features/step_definitions/web_steps.rb:105
And I click on "Upload"                                                         # features/step_definitions/web_steps.rb:52
Then show me the page                                                           # features/step_definitions/web_steps.rb:213
And I should see "Documents [1]"                                                # features/step_definitions/web_steps.rb:109
  expected there to be content "Documents [1]" in "Internal Server Error\n\nbad content body\nWEBrick/1.3.1 (Ruby/1.9.2/2011-07-09) at 127.0.0.1:61672" (RSpec::Expectations::ExpectationNotMetError)
  ./features/step_definitions/web_steps.rb:111:in `/^(?:|I )should see "([^"]*)"$/'
  features/manage_payment_object_documents.feature:14:in `And I should see "Documents [1]"'

From Cucumber

So why would I be getting a Internal Server Error

test.log is also very useless:

Started POST "/accounting/payment_objects/15/files" for 127.0.0.1 at 2011-08-16 13:03:21 +0800
  Processing by Accounting::FilesController#create as HTML
  Parameters: {"utf8"=>"✓", "payment_object_file"=>{"attachment"=>#<ActionDispatch::Http::UploadedFile:0x007f82d9277960 @original_filename="test_photo.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"payment_object_file[attachment]\"; filename=\"test_photo.jpg\"\r\nContent-Type: image/jpeg\r\n", @tempfile=#<File:/var/folders/8b/lwp04gwn4kz02gspddmw56c80000gs/T/RackMultipart20110816-81422-sav3wt>>}, "commit"=>"Upload", "payment_object_id"=>"15"}
  User Load (0.4ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 55 ORDER BY name ASC LIMIT 1
  SQL (0.3ms)  SELECT COUNT(*) FROM `companies` WHERE `companies`.`id` = 56
  Company Load (0.1ms)  SELECT `companies`.* FROM `companies` WHERE `companies`.`id` = 56 ORDER BY name ASC LIMIT 1
  Permission Load (0.3ms)  SELECT `permissions`.* FROM `permissions` WHERE `permissions`.`subject_id` = 56 AND (`permissions`.user_id = 55)
  PaymentObject Load (0.2ms)  SELECT `payment_objects`.* FROM `payment_objects` WHERE `payment_objects`.`id` = 15 AND (`payment_objects`.company_id = 56) ORDER BY id DESC LIMIT 1
[paperclip] identify -format %wx%h '/var/folders/8b/lwp04gwn4kz02gspddmw56c80000gs/T/stream20110816-81422-iuaoiv.jpg[0]' 2>/dev/null
[paperclip] convert '/var/folders/8b/lwp04gwn4kz02gspddmw56c80000gs/T/stream20110816-81422-iuaoiv.jpg[0]' -resize "128x128" '/var/folders/8b/lwp04gwn4kz02gspddmw56c80000gs/T/stream20110816-81422-iuaoiv20110816-81422-59eeoa' 2>/dev/null
  SQL (0.2ms)  SAVEPOINT active_record_1
  PaymentObject Load (0.5ms)  SELECT `payment_objects`.* FROM `payment_objects` WHERE `payment_objects`.`id` = 15 ORDER BY id DESC LIMIT 1
  CACHE (0.0ms)  SELECT `companies`.* FROM `companies` WHERE `companies`.`id` = 56 ORDER BY name ASC LIMIT 1
  SQL (0.2ms)  SELECT COUNT(*) FROM `payment_object_files` WHERE ((`payment_object_files`.`payment_object_id` = 15 AND `payment_object_files`.`md5_checksum` = '386908b62aa3f02213bcb9c74960f92d'))
  SQL (0.7ms)  describe `payment_object_files`
  AREL (0.2ms)  INSERT INTO `payment_object_files` (`payment_object_id`, `user_id`, `company_id`, `md5_checksum`, `attachment_file_name`, `attachment_content_type`, `attachment_file_size`, `attachment_updated_at`) VALUES (15, 55, 56, '386908b62aa3f02213bcb9c74960f92d', 'test_photo.jpg', 'image/jpeg', 83283, '2011-08-16 05:03:21')
  AREL (0.3ms)  UPDATE `payment_objects` SET `updated_at` = '2011-08-16 05:03:21' WHERE `payment_objects`.`id` = 15
  AREL (0.1ms)  UPDATE `companies` SET `updated_at` = '2011-08-16 05:03:21' WHERE `companies`.`id` = 56
[paperclip] Saving attachments.
[paperclip] saving /Users/patrickma.uel/Sites/app/public/system/attachments/13/original/test_photo.jpg
[paperclip] saving /Users/patrickma.uel/Sites/app/public/system/attachments/13/thumb/test_photo.jpg
  SQL (0.2ms)  RELEASE SAVEPOINT active_record_1
  Company Load (0.3ms)  SELECT `companies`.* FROM `companies` WHERE `companies`.`id` = 56 ORDER BY name ASC LIMIT 1
  Permission Load (0.3ms)  SELECT `permissions`.* FROM `permissions` WHERE ((`permissions`.`subject_class` = 'PaymentObject' AND `permissions`.`action` != 'none' AND `permissions`.`subject_id` = 56))
  User Load (0.3ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 55 ORDER BY name ASC LIMIT 1
  SQL (0.1ms)  SAVEPOINT active_record_1
  AREL (0.6ms)  INSERT INTO `notifications` (`user_id`, `company_id`, `message`, `url`, `created_at`, `updated_at`, `actor_id`, `action`, `object`) VALUES (55, 56, NULL, '/accounting/payment_objects/15', '2011-08-16 05:03:21', '2011-08-16 05:03:21', 55, 'file_uploaded', '--- &70100047184420 !ruby/object:PaymentObjectFile\nattributes:\n payment_object_id: 15\n user_id: 55\n company_id: 56\n md5_checksum: 386908b62aa3f02213bcb9c74960f92d\n attachment_file_name: test_photo.jpg\n attachment_content_type: image/jpeg\n attachment_file_size: 83283\n attachment_updated_at: 2011-08-16 13:03:21.846108000 +08:00\n id: 13\nattributes_cache:\n attachment_updated_at: 2011-08-16 05:03:21.846108000Z\nnew_record: false\nreadonly: false\ndestroyed: false\nmarked_for_destruction: false\npreviously_changed:\n user_id:\n - !!null \n - 55\n attachment_file_name:\n - !!null \n - test_photo.jpg\n attachment_content_type:\n - !!null \n - image/jpeg\n attachment_file_size:\n - !!null \n - 83283\n attachment_updated_at:\n - !!null \n - 2011-08-16 05:03:21.846108000Z\n payment_object_id:\n - !!null \n - 15\n md5_checksum:\n - !!null \n - 386908b62aa3f02213bcb9c74960f92d\n company_id:\n - !!null \n - 56\n id:\n - !!null \n - 13\nchanged_attributes: {}\nerrors: !omap []\n_paperclip_attachments:\n :attachment: &70100047181200 !ruby/object:Paperclip::Attachment\n name: :attachment\n instance: *70100047184420\n url: /system/:attachment/:id/:style/:filename\n path: \':rails_root/public:url\'\n styles: &70099991918120\n :thumb:\n - 128x128\n normalized_styles:\n :thumb: !ruby/object:Paperclip::Style\n name: :thumb\n attachment: *70100047181200\n geometry: 128x128\n format: !!null \n other_args: {}\n default_url: /:attachment/:style/missing.png\n default_style: :original\n storage: :filesystem\n use_timestamp: true\n whiny: true\n use_default_time_zone: true\n hash_digest: SHA1\n hash_data: \':class/:attachment/:id/:style/:updated_at\'\n hash_secret: !!null \n convert_options: &70100046528100 {}\n processors: &70100046528120\n - :thumbnail\n options:\n :url: /system/:attachment/:id/:style/:filename\n :path: \':rails_root/public:url\'\n :styles: *70099991918120\n :processors: *70100046528120\n :convert_options: *70100046528100\n :default_url: /:attachment/:style/missing.png\n :default_style: :original\n :storage: :filesystem\n :use_timestamp: true\n :whiny: true\n :use_default_time_zone: true\n :hash_digest: SHA1\n :hash_data: \':class/:attachment/:id/:style/:updated_at\'\n :validations: []\n post_processing: true\n queued_for_delete: []\n queued_for_write: {}\n errors: {}\n dirty: false\n storage_module: !ruby/object:Module {}\n _attachment_file_name: test_photo.jpg\n _attachment_content_type: image/jpeg\n _attachment_file_size: 83283\n _attachment_fingerprint: 386908b62aa3f02213bcb9c74960f92d\n _attachment_updated_at: 2011-08-16 13:03:21.846108000 +08:00\n_start_transaction_state:\n :new_record: true\n :destroyed: false\n :level: 1\nvalidation_context: !!null \npayment_object: !ruby/object:PaymentObject\n attributes:\n id: \'15\'\n company_id: \'56\'\n delivery_date: \'2011-08-16\'\n payment_terms: CBD\n vendor: Apple\n applicant_id: \'55\'\n approved_id: !!null \n declined: \'0\'\n amount: \'1000.00\'\n last_sent: !!null \n payment_date: \'2011-08-16\'\n created_at: \'2011-08-16 05:03:20\'\n updated_at: 2011-08-16 05:03:21.921361000Z\n cancelled: !!null \n currency: HKD\n paid: \'0\'\n paid_by_id: !!null \n paid_at: !!null \n received: None\n payment_status: Pending\n company_specific_id: \'1\'\n stage: Requisition\n approved_at: !!null \n declined_at: !!null \n attributes_cache: {}\n new_record: false\n readonly: false\n destroyed: false\n marked_for_destruction: false\n previously_changed: {}\n changed_attributes: {}\n company: !ruby/object:Company\n attributes:\n id: \'56\'\n name: Urban Entertainment Ltd.\n created_at: \'2011-08-16 05:03:18\'\n updated_at: 2011-08-16 05:03:21.925477000Z\n company_group_id: \'0\'\n currency: HKD\n api_key: 3c4caf936ce6c3b0c98075d24b4e6514\n attributes_cache: {}\n new_record: false\n readonly: false\n destroyed: false\n marked_for_destruction: false\n previously_changed: {}\n changed_attributes: {}\ncompany: !ruby/object:Company\n attributes:\n id: \'56\'\n name: Urban Entertainment Ltd.\n created_at: \'2011-08-16 05:03:18\'\n updated_at: \'2011-08-16 05:03:21\'\n company_group_id: \'0\'\n currency: HKD\n api_key: 3c4caf936ce6c3b0c98075d24b4e6514\n attributes_cache: {}\n new_record: false\n readonly: false\n destroyed: false\n marked_for_destruction: false\n previously_changed: {}\n changed_attributes: {}\n')
  SQL (0.1ms)  RELEASE SAVEPOINT active_record_1
Redirected to http://127.0.0.1:62127/accounting/payment_objects/15
Completed 302 Found in 218ms


Started GET "/accounting/payment_objects/15" for 127.0.0.1 at 2011-08-16 13:03:21 +0800
  SQL (1.4ms)  ROLLBACK

So yeah, I don't know how to really diagnose the error by knowing my database ROLLBACK on a GET request.

And to make things even more confusing, I can upload pictures in development and all the steps seem fine when I do out outside of Cucumber.

Update:

I've created a demo app to see if I could upload a file, and have the redirect and save process correctly, and wallah, it did.

Gemfile.lock from prototype app:

GEM
  remote: http://rubygems.org/
  specs:
    abstract (1.0.0)
    actionmailer (3.0.9)
      actionpack (= 3.0.9)
      mail (~> 2.2.19)
    actionpack (3.0.9)
      activemodel (= 3.0.9)
      activesupport (= 3.0.9)
      builder (~> 2.1.2)
      erubis (~> 2.6.6)
      i18n (~> 0.5.0)
      rack (~> 1.2.1)
      rack-mount (~> 0.6.14)
      rack-test (~> 0.5.7)
      tzinfo (~> 0.3.23)
    activemodel (3.0.9)
      activesupport (= 3.0.9)
      builder (~> 2.1.2)
      i18n (~> 0.5.0)
    activerecord (3.0.9)
      activemodel (= 3.0.9)
      activesupport (= 3.0.9)
      arel (~> 2.0.10)
      tzinfo (~> 0.3.23)
    activeresource (3.0.9)
      activemodel (= 3.0.9)
      activesupport (= 3.0.9)
    activesupport (3.0.9)
    arel (2.0.10)
    builder (2.1.2)
    capybara (1.0.1)
      mime-types (>= 1.16)
      nokogiri (>= 1.3.3)
      rack (>= 1.0.0)
      rack-test (>= 0.5.4)
      selenium-webdriver (~> 2.0)
      xpath (~> 0.1.4)
    capybara-webkit (0.6.0)
      capybara (~> 1.0.0)
    childprocess (0.2.1)
      ffi (~> 1.0.6)
    cocaine (0.1.0)
    cucumber (1.0.2)
      builder (>= 2.1.2)
      diff-lcs (>= 1.1.2)
      gherkin (~> 2.4.5)
      json (>= 1.4.6)
      term-ansicolor (>= 1.0.5)
    cucumber-rails (1.0.2)
      capybara (>= 1.0.0)
      cucumber (~> 1.0.0)
      nokogiri (>= 1.4.6)
    database_cleaner (0.6.7)
    diff-lcs (1.1.2)
    erubis (2.6.6)
      abstract (>= 1.0.0)
    ffi (1.0.9)
    gherkin (2.4.6)
      json (>= 1.4.6)
    haml (3.1.2)
    i18n (0.5.0)
    json (1.5.3)
    json_pure (1.5.3)
    mail (2.2.19)
      activesupport (>= 2.3.6)
      i18n (>= 0.4.0)
      mime-types (~> 1.16)
      treetop (~> 1.4.8)
    mime-types (1.16)
    nokogiri (1.5.0)
    paperclip (2.3.16)
      activerecord (>= 2.3.0)
      activesupport (>= 2.3.2)
      cocaine (>= 0.0.2)
      mime-types
    polyglot (0.3.2)
    rack (1.2.3)
    rack-mount (0.6.14)
      rack (>= 1.0.0)
    rack-test (0.5.7)
      rack (>= 1.0)
    rails (3.0.9)
      actionmailer (= 3.0.9)
      actionpack (= 3.0.9)
      activerecord (= 3.0.9)
      activeresource (= 3.0.9)
      activesupport (= 3.0.9)
      bundler (~> 1.0)
      railties (= 3.0.9)
    railties (3.0.9)
      actionpack (= 3.0.9)
      activesupport (= 3.0.9)
      rake (>= 0.8.7)
      rdoc (~> 3.4)
      thor (~> 0.14.4)
    rake (0.9.2)
    rdoc (3.9.2)
    rspec (2.6.0)
      rspec-core (~> 2.6.0)
      rspec-expectations (~> 2.6.0)
      rspec-mocks (~> 2.6.0)
    rspec-core (2.6.4)
    rspec-expectations (2.6.0)
      diff-lcs (~> 1.1.2)
    rspec-mocks (2.6.0)
    rspec-rails (2.6.1)
      actionpack (~> 3.0)
      activesupport (~> 3.0)
      railties (~> 3.0)
      rspec (~> 2.6.0)
    rubyzip (0.9.4)
    selenium-webdriver (2.4.0)
      childprocess (>= 0.2.1)
      ffi (>= 1.0.7)
      json_pure
      rubyzip
    sqlite3 (1.3.4)
    term-ansicolor (1.0.6)
    thor (0.14.6)
    treetop (1.4.10)
      polyglot
      polyglot (>= 0.3.1)
    tzinfo (0.3.29)
    xpath (0.1.4)
      nokogiri (~> 1.3)

PLATFORMS
  ruby

DEPENDENCIES
  capybara
  capybara-webkit
  cucumber-rails
  database_cleaner
  haml
  paperclip
  rails (= 3.0.9)
  rspec-rails
  sqlite3

Gemfile.lock from broken app:

GEM
  remote: http://rubygems.org/
  specs:
    Saikuro (1.1.0)
    abstract (1.0.0)
    actionmailer (3.0.9)
      actionpack (= 3.0.9)
      mail (~> 2.2.19)
    actionpack (3.0.9)
      activemodel (= 3.0.9)
      activesupport (= 3.0.9)
      builder (~> 2.1.2)
      erubis (~> 2.6.6)
      i18n (~> 0.5.0)
      rack (~> 1.2.1)
      rack-mount (~> 0.6.14)
      rack-test (~> 0.5.7)
      tzinfo (~> 0.3.23)
    activemodel (3.0.9)
      activesupport (= 3.0.9)
      builder (~> 2.1.2)
      i18n (~> 0.5.0)
    activerecord (3.0.9)
      activemodel (= 3.0.9)
      activesupport (= 3.0.9)
      arel (~> 2.0.10)
      tzinfo (~> 0.3.23)
    activeresource (3.0.9)
      activemodel (= 3.0.9)
      activesupport (= 3.0.9)
    activesupport (3.0.9)
    addressable (2.2.6)
    arel (2.0.10)
    arrayfields (4.7.4)
    bcrypt-ruby (2.1.4)
    builder (2.1.2)
    cancan (1.6.5)
    capistrano (2.8.0)
      highline
      net-scp (>= 1.0.0)
      net-sftp (>= 2.0.0)
      net-ssh (>= 2.0.14)
      net-ssh-gateway (>= 1.1.0)
    capybara (1.0.1)
      mime-types (>= 1.16)
      nokogiri (>= 1.3.3)
      rack (>= 1.0.0)
      rack-test (>= 0.5.4)
      selenium-webdriver (~> 2.0)
      xpath (~> 0.1.4)
    capybara-webkit (0.6.0)
      capybara (~> 1.0.0)
    childprocess (0.2.1)
      ffi (~> 1.0.6)
    chronic (0.3.0)
    churn (0.0.13)
      chronic (>= 0.2.3)
      hirb
      json_pure
      main
      ruby_parser (~> 2.0.4)
      sexp_processor (~> 3.0.3)
    cocaine (0.1.0)
    colored (1.2)
    cucumber (1.0.2)
      builder (>= 2.1.2)
      diff-lcs (>= 1.1.2)
      gherkin (~> 2.4.5)
      json (>= 1.4.6)
      term-ansicolor (>= 1.0.5)
    cucumber-rails (1.0.2)
      capybara (>= 1.0.0)
      cucumber (~> 1.0.0)
      nokogiri (>= 1.4.6)
    database_cleaner (0.6.7)
    devise (1.4.2)
      bcrypt-ruby (~> 2.1.2)
      orm_adapter (~> 0.0.3)
      warden (~> 1.0.3)
    diff-lcs (1.1.2)
    erubis (2.6.6)
      abstract (>= 1.0.0)
    escape_utils (0.2.3)
    factory_girl (2.0.4)
    factory_girl_rails (1.1.0)
      factory_girl (~> 2.0.0)
      railties (>= 3.0.0)
    fattr (2.2.0)
    ffi (1.0.9)
    flay (1.4.3)
      ruby_parser (~> 2.0)
      sexp_processor (~> 3.0)
    flog (2.5.2)
      ruby_parser (~> 2.0)
      sexp_processor (~> 3.0)
    gherkin (2.4.6)
      json (>= 1.4.6)
    google_currency (1.2.0)
      money (~> 3.5)
    growl (1.0.3)
    haml (3.1.2)
    highline (1.6.2)
    hirb (0.5.0)
    i18n (0.5.0)
    jquery-rails (1.0.13)
      railties (~> 3.0)
      thor (~> 0.14)
    json (1.5.3)
    json_pure (1.5.3)
    launchy (2.0.5)
      addressable (~> 2.2.6)
    mail (2.2.19)
      activesupport (>= 2.3.6)
      i18n (>= 0.4.0)
      mime-types (~> 1.16)
      treetop (~> 1.4.8)
    main (4.6.0)
      arrayfields (>= 4.7.4)
      fattr (>= 2.1.0)
      map (>= 2.0.0)
    map (4.2.0)
    memcache (1.2.13)
    memcache-client (1.8.5)
    meta_where (1.0.4)
      activerecord (~> 3.0.0)
      activesupport (~> 3.0.0)
      arel (~> 2.0.7)
    metric_fu (2.1.1)
      Saikuro (>= 1.1.0)
      activesupport (>= 2.0.0)
      chronic (~> 0.3.0)
      churn (>= 0.0.7)
      flay (>= 1.2.1)
      flog (>= 2.3.0)
      rails_best_practices (>= 0.6.4)
      rcov (>= 0.8.3.3)
      reek (>= 1.2.6)
      roodi (>= 2.1.0)
      syntax
    mime-types (1.16)
    money (3.7.1)
      i18n (~> 0.4)
    mysql (2.8.1)
    net-scp (1.0.4)
      net-ssh (>= 1.99.1)
    net-sftp (2.0.5)
      net-ssh (>= 2.0.9)
    net-ssh (2.1.4)
    net-ssh-gateway (1.1.0)
      net-ssh (>= 1.99.1)
    nokogiri (1.5.0)
    orm_adapter (0.0.5)
    paperclip (2.3.16)
      activerecord (>= 2.3.0)
      activesupport (>= 2.3.2)
      cocaine (>= 0.0.2)
      mime-types
    polyglot (0.3.2)
    rack (1.2.3)
    rack-mount (0.6.14)
      rack (>= 1.0.0)
    rack-test (0.5.7)
      rack (>= 1.0)
    rails (3.0.9)
      actionmailer (= 3.0.9)
      actionpack (= 3.0.9)
      activerecord (= 3.0.9)
      activeresource (= 3.0.9)
      activesupport (= 3.0.9)
      bundler (~> 1.0)
      railties (= 3.0.9)
    rails_best_practices (0.10.1)
      activesupport
      colored
      erubis
      haml
      i18n
      ruby-progressbar
      ruby_parser
    railties (3.0.9)
      actionpack (= 3.0.9)
      activesupport (= 3.0.9)
      rake (>= 0.8.7)
      rdoc (~> 3.4)
      thor (~> 0.14.4)
    rake (0.9.2)
    rb-fsevent (0.4.3)
    rcov (0.9.10)
    rdoc (3.9.2)
    reek (1.2.8)
      ruby2ruby (~> 1.2)
      ruby_parser (~> 2.0)
      sexp_processor (~> 3.0)
    roodi (2.1.0)
      ruby_parser
    rspec (2.6.0)
      rspec-core (~> 2.6.0)
      rspec-expectations (~> 2.6.0)
      rspec-mocks (~> 2.6.0)
    rspec-core (2.6.4)
    rspec-expectations (2.6.0)
      diff-lcs (~> 1.1.2)
    rspec-mocks (2.6.0)
    rspec-rails (2.6.1)
      actionpack (~> 3.0)
      activesupport (~> 3.0)
      railties (~> 3.0)
      rspec (~> 2.6.0)
    ruby-progressbar (0.0.10)
    ruby2ruby (1.2.5)
      ruby_parser (~> 2.0)
      sexp_processor (~> 3.0)
    ruby_parser (2.0.6)
      sexp_processor (~> 3.0)
    rubyzip (0.9.4)
    sass (3.1.7)
    selenium-webdriver (2.4.0)
      childprocess (>= 0.2.1)
      ffi (>= 1.0.7)
      json_pure
      rubyzip
    sexp_processor (3.0.5)
    shoulda (2.11.3)
    syntax (1.0.0)
    term-ansicolor (1.0.6)
    thor (0.14.6)
    treetop (1.4.10)
      polyglot
      polyglot (>= 0.3.1)
    tzinfo (0.3.29)
    warden (1.0.5)
      rack (>= 1.0)
    xpath (0.1.4)
      nokogiri (~> 1.3)

PLATFORMS
  ruby

DEPENDENCIES
  cancan
  capistrano
  capybara
  capybara-webkit
  cucumber
  cucumber-rails
  database_cleaner
  devise
  escape_utils
  factory_girl
  factory_girl_rails
  google_currency
  growl
  haml
  jquery-rails
  json
  launchy
  memcache
  memcache-client
  meta_where
  metric_fu
  mime-types
  money
  mysql
  paperclip
  rails (= 3.0.9)
  rb-fsevent
  rspec-rails
  sass
  shoulda
  warden

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

百思不得你姐 2024-12-06 21:55:19

我也遇到了同样的问题,不知道问题出在哪里。这是 features/support/env.rb 中的罪魁祸首

  # By default, any exception happening in your Rails application will bubble up
  # to Cucumber so that your scenario will fail. This is a different from how 
  # your application behaves in the production environment, where an error page will 
  # be rendered instead.
  #
  # Sometimes we want to override this default behaviour and allow Rails to rescue
  # exceptions and display an error page (just like when the app is running in production).
  # Typical scenarios where you want to do this is when you test your error pages.
  # There are two ways to allow Rails to rescue exceptions:
  #
  # 1) Tag your scenario (or feature) with @allow-rescue
  #
  # 2) Set the value below to true. Beware that doing this globally is not
  # recommended as it will mask a lot of errors for you!
  #
  ActionController::Base.allow_rescue = false

I had the same issue, not knowing what the problem was. This is the culprit in features/support/env.rb

  # By default, any exception happening in your Rails application will bubble up
  # to Cucumber so that your scenario will fail. This is a different from how 
  # your application behaves in the production environment, where an error page will 
  # be rendered instead.
  #
  # Sometimes we want to override this default behaviour and allow Rails to rescue
  # exceptions and display an error page (just like when the app is running in production).
  # Typical scenarios where you want to do this is when you test your error pages.
  # There are two ways to allow Rails to rescue exceptions:
  #
  # 1) Tag your scenario (or feature) with @allow-rescue
  #
  # 2) Set the value below to true. Beware that doing this globally is not
  # recommended as it will mask a lot of errors for you!
  #
  ActionController::Base.allow_rescue = false
小鸟爱天空丶 2024-12-06 21:55:19

这是数据库使用了错误的事务策略导致的问题。

通过设置: DatabaseCleaner.strategy = :truncation

您可以缓解这个问题。

This is a problem caused by the database using the wrong transaction strategy.

By setting: DatabaseCleaner.strategy = :truncation

You can alleviate your self from this issue.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文