0

オブジェクト「ライン」のすべての機能テストが失敗します。これのデバッグをどこから開始すればよいかさえわかりません。

21) エラー: test_should_update_line(LinesControllerTest): NoMethodError: 未定義のメソッドname' for false:FalseClass c:/Ruby193/lib/ruby/gems/1.9.1/gems/factory_girl-4.0.0/lib/factory_girl/decl aration/static.rb:11:in==' c:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.3/lib/active_record/att ribute_methods/write.rb: 57:in convert_number_column_value' c:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.3/lib/active_record/att ribute_methods/write.rb:50:intype_cast_attribute_for_write' c:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.3/lib/active_record/att ribute_methods/serialization.rb:88:in type_cast_attribute_for_write' c:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.3/lib/active_record/att ribute_methods/write.rb:38:inwrite_attribute' c:/Ruby193/lib /ruby/gems/1.9.1/gems/activerecord-3.2.3/lib/active_record/att ribute_methods/dirty.rb:67:in write_attribute' c:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.3/lib/active_record/att ribute_methods/write.rb:14:inport=' c:/Ruby193/lib/ruby/gems/1.9.1/gems /factory_girl-4.0.0/lib/factory_girl/attr ibute_assigner.rb:16:block (2 levels) in object' c:/Ruby193/lib/ruby/gems/1.9.1/gems/factory_girl-4.0.0/lib/factory_girl/attr ibute_assigner.rb:15:inそれぞれ'c:/Ruby193/lib/ruby/gems/1.9.1/gems/factory_girl-4.0.0/lib/factory_girl/attribute_assigner .rb:15:でblock in object' c:/Ruby193/lib/ruby/gems/1.9.1/gems/factory_girl-4.0.0/lib/factory_girl/attr ibute_assigner.rb:14:in「c:/Ruby193/lib/ruby/gems/1.9.1/gems/factory_girl-4.0.0/lib/factory_girl/attr ibute_assigner.rb:14:object' c:inオブジェクト内」をタップしてください' c:/Ruby193/lib/ruby/gems/ 1.9.1/gems/factory_girl-4.0.0/lib/factory_girl/strategy/create.rb:9:in result' c:/Ruby193/lib/ruby/gems/1.9.1/gems/factory_girl-4.0.0/lib/factory_girl/fact ory.rb:42:inrun' c:/Ruby193/lib/ruby/gems/1.9.1/gems/factory_girl-4.0.0 /lib/factory_girl/fact ory_runner.rb:23:inblock in run' c:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.3/lib/active_support/n otifications.rb:125:in楽器' c:/Ruby193/lib/ruby/gems/1.9.1/gems/factory_girl-4.0.0/lib/factory_girl/fact ory_runner.rb:22:in run' c:/Ruby193/lib/ruby/gems/1.9.1/gems/factory_girl-4.0.0/lib/factory_girl/stra tegy_syntax_method_registrar.rb:19:indefine_singular_strategy_method のブロック'

c:/code/vsdb/test/functional/lines_controller_test.rb:5:in `block in <class: LinesControllerTest>'
c:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.3/lib/active_support/c

allbacks.rb :462: in _run__987382823__setup__855471168__callbacks' c:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.3/lib/active_support/c allbacks.rb:405:in__run_callback' c:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.3/lib/active_support/c allbacks.rb:385: in _run_setup_callbacks' c:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.3/lib/active_support/c allbacks.rb:81:inrun_callbacks ' c:/Ruby193 /lib/ruby/gems/1.9.1/gems/activesupport-3.2.3/lib/active_support/testing/setup_and_teardown.rb:34:in `run'

lines_controller_test.rb:

class LinesControllerTest < ActionController::TestCase
setup do @line = FactoryGirl.create(:line)
end

test "should update line" do
  put :update, id: @line, line: { description: @line.description }
  assert_redirected_to line_path(assigns(:line))   
end

終わり

test_helper.rb:

ENV["RAILS_ENV"] = "test" require File.expand_path('../../config/environment', FILE ) require 'rails/test_help' require 'capybara/rails'

class ActiveSupport::TestCase # test/fixtures/*.(yml|csv) 内のすべてのフィクスチャをすべてのテストに対してアルファベット順にセットアップします。# # 注: 現在のところ、統合テストでフィクスチャを明示的に宣言する必要があります # -- まだこの設定を継承していません

def setup #あらゆる種類の所有者 @admin = FactoryGirl.create(:owner, iso:true, admin:true) @iso = FactoryGirl.create(:owner, iso:true) @isa = FactoryGirl.create(:owner) #デフォルトで管理者になる @controller.stubs(:current_owner).returns(@admin)

#fixtures for compliance rates verification
@art = FactoryGirl.create(:unit, name: "art", unit_code: "1110000", parent_unit_id: 1100000)   end

# すべてのテストで使用されるヘルパー メソッドをここに追加します... end

class ActionDispatch::IntegrationTest include Capybar::DSL

def ティアダウン Capybara.reset_sessions! Capybara.use_default_driver end end

4

1 に答える 1

0

@line渡す必要がある場所を更新するために渡しているようです@line.id。それを次のように変更してみてください。

put :update, id: @line.id, line: { description: @line.description }
于 2012-08-20T22:00:42.843 に答える