Reputation: 2745
All functional tests for my object "Line" fail. I don't even know where to start debugging this:
21) Error: test_should_update_line(LinesControllerTest): NoMethodError: undefined method
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:inconvert_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: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/serialization.rb:88:intype_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:in
write_attribute' c:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.3/lib/active_record/att ribute_methods/dirty.rb:67:inwrite_attribute' c:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-3.2.3/lib/active_record/att ribute_methods/write.rb:14:in
port=' c:/Ruby193/lib/ruby/gems/1.9.1/gems/factory_girl-4.0.0/lib/factory_girl/attr ibute_assigner.rb:16:inblock (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
each' c:/Ruby193/lib/ruby/gems/1.9.1/gems/factory_girl-4.0.0/lib/factory_girl/attr ibute_assigner.rb:15:inblock 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
tap' c:/Ruby193/lib/ruby/gems/1.9.1/gems/factory_girl-4.0.0/lib/factory_girl/attr ibute_assigner.rb:14:inobject' c:in
object' c:/Ruby193/lib/ruby/gems/1.9.1/gems/factory_girl-4.0.0/lib/factory_girl/stra tegy/create.rb:9:inresult' c:/Ruby193/lib/ruby/gems/1.9.1/gems/factory_girl-4.0.0/lib/factory_girl/fact ory.rb:42:in
run' 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
instrument' c:/Ruby193/lib/ruby/gems/1.9.1/gems/factory_girl-4.0.0/lib/factory_girl/fact ory_runner.rb:22:inrun' c:/Ruby193/lib/ruby/gems/1.9.1/gems/factory_girl-4.0.0/lib/factory_girl/stra tegy_syntax_method_registrar.rb:19:in
block in define_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:in
run_callbacks' c:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-3.2.3/lib/active_support/t esting/setup_and_teardown.rb:34:in `run'
lines_controller_test.rb:
class LinesControllerTest < ActionController::TestCase
setup do @line = FactoryGirl.create(:line)
endtest "should update line" do put :update, id: @line, line: { description: @line.description } assert_redirected_to line_path(assigns(:line)) end
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 # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order. # # Note: You'll currently still have to declare fixtures explicitly in integration tests # -- they do not yet inherit this setting
def setup #all kinds of owners @admin = FactoryGirl.create(:owner, iso:true, admin:true) @iso = FactoryGirl.create(:owner, iso:true) @isa = FactoryGirl.create(:owner) #be admin by default @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
# Add more helper methods to be used by all tests here... end
class ActionDispatch::IntegrationTest include Capybara::DSL
def teardown Capybara.reset_sessions! Capybara.use_default_driver end end
Upvotes: 0
Views: 1804
Reputation: 27374
Looks like you're passing @line
to update where you should be passing @line.id
. Try changing that to:
put :update, id: @line.id, line: { description: @line.description }
Upvotes: 0