power_assert icon indicating copy to clipboard operation
power_assert copied to clipboard

Failed to trace: NoMethodError: undefined method start_with?

Open akicho8 opened this issue 6 years ago • 1 comments

Get the following error

power_assert: [BUG] Failed to trace: NoMethodError: undefined method `start_with?' for nil:NilClass

It was validated as much as possible in a small code. But I do not know the cause.

Capybara be due to? Or there is cause to power_assert?

Even now the same result by testing it with github of master.

Steps to reproduce

RUBY_VERSION # => "2.6.1"

require 'bundler/inline'

gemfile(true) do
  gem 'capybara', '3.29.0'
  gem 'selenium-webdriver', '3.142.4'
  gem 'test-unit', '3.3.3'
  gem 'power_assert', '1.1.5'
end

require 'capybara/dsl'
Capybara.current_driver = :selenium_chrome

class TestFoo < Test::Unit::TestCase
  test 'case1' do
    Capybara.visit('http://httpbin.org/forms/post')
    assert { Capybara.first('input').value == '' }
  end
end

Expected behavior

ruby test.rb
Loaded suite test
Started
.
Finished in 2.373814 seconds.
-------------------------------------------------------------------------------
1 tests, 1 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
-------------------------------------------------------------------------------
0.42 tests/s, 0.42 assertions/s

Actual behavior

ruby test.rb
Loaded suite test
Started
power_assert: [BUG] Failed to trace: NoMethodError: undefined method `start_with?' for nil:NilClass
.
Finished in 2.373814 seconds.
-------------------------------------------------------------------------------
1 tests, 1 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
-------------------------------------------------------------------------------
0.42 tests/s, 0.42 assertions/s

System configuration

Ruby version: 2.6.1p33 (2019-01-30 revision 66950) [x86_64-darwin17]

akicho8 avatar Sep 25 '19 09:09 akicho8

It seems a third party's issue.

I added following debug code,

diff --git a/vendor/bundle/ruby/2.6.0/gems/power_assert-1.1.5/lib/power_assert.rb b/vendor/bundle/ruby/2.6.0/gems/power_assert-1.1.5/lib/power_assert.rb
index 7eaa5f9..996f03e 100644
--- a/vendor/bundle/ruby/2.6.0/gems/power_assert-1.1.5/lib/power_assert.rb
+++ b/vendor/bundle/ruby/2.6.0/gems/power_assert-1.1.5/lib/power_assert.rb
@@ -53,6 +53,7 @@ def trace(frame)
     end

     def app_caller_locations
+      pp caller_locations: caller_locations.zip(caller_locations.map(&:path))
       caller_locations.drop_while {|i| internal_file?(i.path) }.take_while {|i| ! internal_file?(i.path) }
     end

and got following output.

...
{:caller_locations=>
...
   ["test.rb:1:in `each'", nil],
   ["test.rb:1:in `each'", nil],
   ["test.rb:1:in `each'", nil],
   ["test.rb:1:in `each'", nil]]}

It is obviously strange that Thread::Backtrace::Location#path returns nil instead of "test.rb".

k-tsj avatar Oct 06 '19 09:10 k-tsj