错误的参数数量,调试

时间:2014-12-15 04:39:49

标签: ruby-on-rails

我目前正在调试一些代码,我一直在努力尝试让它“干净”,然后继续前进。在某个时刻,我开始从我的警卫终端接到故障,所以我停下来清理它们。

这对我来说是一个开关项目所以我不确定究竟发生了什么变化,但现在我有19个错误的参数数量(1个为0)错误。这些错误以前不存在,所以我不太清楚为什么他们现在这样做。

我的问题是,我应该如何找到这个问题的根源?同时出现的不同文件中存在许多相同的错误。我猜测必须有一个共同的线程,但我没有看到它。

我的Google foo还不够强大,无法找到有关我的问题的相关信息,因为“错误的参数数量”相当普遍。

欢迎任何帮助,建议或一般指导。提前谢谢。

bitbucket repo: FermiInventory

我的测试结果示例:

    [1] guard(main)> 
04:02:05 - INFO - Run all
04:02:05 - INFO - Running: all tests
Started

ERROR["test_valid_item_information", NewItemTest, 2.466063744]
 test_valid_item_information#NewItemTest (2.47s)
ArgumentError:         ArgumentError: wrong number of arguments (1 for 0)
            app/controllers/items_controller.rb:31:in `block in create'
            app/controllers/items_controller.rb:30:in `create'
            test/integration/new_item_test.rb:20:in `block (2 levels) in <class:NewItemTest>'
            test/integration/new_item_test.rb:19:in `block in <class:NewItemTest>'
        app/controllers/items_controller.rb:31:in `block in create'
        app/controllers/items_controller.rb:30:in `create'
        test/integration/new_item_test.rb:20:in `block (2 levels) in <class:NewItemTest>'
        test/integration/new_item_test.rb:19:in `block in <class:NewItemTest>'

  37/37: [=================================] 100% Time: 00:00:02, Time: 00:00:02

Finished in 2.47525s
37 tests, 41 assertions, 0 failures, 19 errors, 0 skips

测试/集成/ new_item_test.rb

require 'test_helper'

class NewItemTest < ActionDispatch::IntegrationTest

  test "invalid item information" do
    get newitem_path
    assert_no_difference 'Item.count' do
      post items_path, item: {  name: "" }
    end
    assert_template 'items/new'
    assert_select 'div#error_explanation'
    assert_select 'div.field_with_errors'
  end

  test "valid item information" do
    get newitem_path
    name    = "Example Item"
    user_id = 1
    assert_difference 'Item.count', 1 do
      post_via_redirect items_path, item: { name:     name,
                                            user_id:  user_id }
    end
    assert_template 'items/show'
    assert_not flash.nil?
  end
end

0 个答案:

没有答案