ruby on rails - Why do some rake tests fail with 'method_missing: private method location called for...'? -


i'm upgrading rails 4.0 app rails 4.2. tests passed prior upgrade. however, getting several errors (but no failures). output of 1 of tests:

run options: --seed 30437  # running:  e  finished in 1.738307s, 0.5753 runs/s, 0.0000 assertions/s. /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/actionpack-4.2.1/lib/action_dispatch/testing/assertions/routing.rb:171:in `method_missing': private method `location' called #<[mytestclass]:0xb46557c> (nomethoderror)     /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/actionpack-4.2.1/lib/action_dispatch/testing/integration.rb:397:in `method_missing'     /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/minitest-5.6.0/lib/minitest/test.rb:265:in `block in to_s'     /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/minitest-5.6.0/lib/minitest/test.rb:264:in `map'     /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/minitest-5.6.0/lib/minitest/test.rb:264:in `to_s'     /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/minitest-5.6.0/lib/minitest.rb:580:in `%'     /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/minitest-5.6.0/lib/minitest.rb:580:in `block in aggregated_results'     /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/minitest-5.6.0/lib/minitest.rb:579:in `each'     /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/minitest-5.6.0/lib/minitest.rb:579:in `each_with_index'     /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/minitest-5.6.0/lib/minitest.rb:579:in `each'     /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/minitest-5.6.0/lib/minitest.rb:579:in `map'     /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/minitest-5.6.0/lib/minitest.rb:579:in `aggregated_results'     /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/minitest-5.6.0/lib/minitest.rb:566:in `report'     /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/minitest-5.6.0/lib/minitest.rb:638:in `each'     /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/minitest-5.6.0/lib/minitest.rb:638:in `report'     /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/minitest-5.6.0/lib/minitest.rb:134:in `run'     /opt/rbenv/versions/2.2.0/lib/ruby/gems/2.2.0/gems/minitest-5.6.0/lib/minitest.rb:56:in `block in autorun' 

i can't seem find in code causing error. looking @ of files mentioned in stacktrace, looks erroring while trying generate failure message. (double fail...)

what cause of error?

edit:

the first line of test s = login(:user). if place return before line, test passes, if place after line, still error. login function defined in test_helper.rb follows:

def login(user)   open_session |sess|     u = users(user)     sess.extend(mysession)     sess.get "/users/sign_in"     sess.assert_response :success     sess.post_via_redirect "/users/sign_in",       user: {         email: u.email,         password: "<password>"       }     assert_equal '/', sess.path     assert_equal "signed in successfully.", sess.flash[:notice]   end end 

the module mysession contains few helper methods.

edit 2:

i opened rails console session, required test class, , did mytestclass.private_methods. output:

=> [:initialize, :_stash_object_in_method, :_superclass_delegating_accessor, :included, :extended, :prepended, :method_added, :method_removed, :method_undefined, :initialize_copy, :attr, :attr_reader, :attr_writer, :attr_accessor, :initialize_clone, :remove_const, :using, :remove_method, :undef_method, :alias_method, :public, :protected, :private, :define_method, :attr_internal_ivar_name, :attr_internal_define, :delegateclass, :digest, :timeout, :default_src_encoding, :nokogiri, :irb_binding, :create_fixtures, :load, :require, :initialize_dup, :sprintf, :format, :integer, :float, :string, :array, :hash, :warn, :raise, :fail, :global_variables, :__method__, :__callee__, :__dir__, :eval, :local_variables, :iterator?, :block_given?, :catch, :throw, :loop, :respond_to_missing?, :trace_var, :untrace_var, :at_exit, :syscall, :open, :printf, :print, :putc, :puts, :gets, :readline, :select, :readlines, :p, :srand, :rand, :trap, :require_relative, :proc, :lambda, :binding, :caller, :caller_locations, :exec, :fork, :exit!, :system, :spawn, :sleep, :exit, :abort, :rational, :complex, :set_trace_func, :gem_original_require, :pathname, :uri, :rubygems_require, :bigdecimal, :j, :jj, :json, :not_implemented, :y, :open_uri_original_open, :pp, :singleton_method_added, :singleton_method_removed, :singleton_method_undefined, :method_missing] 

edit 3:

i opened rails console session, required test class, , did test = mytestclass.new , test.private_methods. time, output did contain :location. app have location model, , output appeared in between several other of app's models, suspect problem. question now: why test classes have private methods named after app's models? how can fix or work around problem? (obviously rename location model, i'd prefer avoid that, if possible.)

did location method change public private on whatever class you're calling on between rails 4.0 , 4.2?

maybe i'm misunderstanding, error seems pretty straightforward. somewhere (in code, or maybe gem rely on that's changed versions well) method called location being called private. stack track shows it's happening, take @ code , see what's going on.

might helpful see test code, stack trace pointing source can trace what's going on.

i looked through code on github , can't find anything. chance defined method called location on mytestclass overrides 1 in minitest::test ? also, if go console , require mytestclass, , call .private_methods on (or rather instance of it), :location indeed show in list? include statements anywhere can find in code might bringing in location method mytestclass?

it looks question/answer might provide way track down these methods coming from.