Skip to content

v0.1.23 raises NoMethodError when running specs #68

Closed
@bjeanes

Description

@bjeanes

As far as I can tell, it is depending on a core-ext from ruby-lsp but is not directly requiring it, so when the test runner requires the formatter, it results in a NoMethodError

See backtrace:

/usr/local/bundle/gems/ruby-lsp-rspec-0.1.23/lib/ruby_lsp/ruby_lsp_rspec/rspec_formatter.rb:58:in 'RubyLsp::RSpec::RSpecFormatter#uri_for': undefined method 'from_path' for class URI::Generic (NoMethodError)

        URI::Generic.from_path(path: absolute_path)
                    ^^^^^^^^^^
        from /usr/local/bundle/gems/ruby-lsp-rspec-0.1.23/lib/ruby_lsp/ruby_lsp_rspec/rspec_formatter.rb:25:in 'RubyLsp::RSpec::RSpecFormatter#example_started'
        from /usr/local/bundle/gems/rspec-core-3.13.3/lib/rspec/core/reporter.rb:210:in 'block in RSpec::Core::Reporter#notify'
        from /usr/local/bundle/gems/rspec-core-3.13.3/lib/rspec/core/reporter.rb:209:in 'Array#each'
        from /usr/local/bundle/gems/rspec-core-3.13.3/lib/rspec/core/reporter.rb:209:in 'RSpec::Core::Reporter#notify'
        from /usr/local/bundle/gems/rspec-core-3.13.3/lib/rspec/core/reporter.rb:129:in 'RSpec::Core::Reporter#example_started'
        from /usr/local/bundle/gems/rspec-core-3.13.3/lib/rspec/core/example.rb:474:in 'RSpec::Core::Example#start'
        from /usr/local/bundle/gems/rspec-core-3.13.3/lib/rspec/core/example.rb:440:in 'RSpec::Core::Example#fail_with_exception'
        from /usr/local/bundle/gems/rspec-core-3.13.3/lib/rspec/core/example_group.rb:614:in 'block in RSpec::Core::ExampleGroup.run'
        from /usr/local/bundle/gems/rspec-core-3.13.3/lib/rspec/core/example_group.rb:656:in 'Array#each'
        from /usr/local/bundle/gems/rspec-core-3.13.3/lib/rspec/core/example_group.rb:656:in 'RSpec::Core::ExampleGroup.for_filtered_examples'
        from /usr/local/bundle/gems/rspec-core-3.13.3/lib/rspec/core/example_group.rb:614:in 'RSpec::Core::ExampleGroup.run'
        from /usr/local/bundle/gems/rspec-core-3.13.3/lib/rspec/core/example_group.rb:608:in 'block in RSpec::Core::ExampleGroup.run'
        from /usr/local/bundle/gems/rspec-core-3.13.3/lib/rspec/core/example_group.rb:608:in 'Array#map'
        from /usr/local/bundle/gems/rspec-core-3.13.3/lib/rspec/core/example_group.rb:608:in 'RSpec::Core::ExampleGroup.run'
        from /usr/local/bundle/gems/rspec-core-3.13.3/lib/rspec/core/runner.rb:121:in 'block (3 levels) in RSpec::Core::Runner#run_specs'
        from /usr/local/bundle/gems/rspec-core-3.13.3/lib/rspec/core/runner.rb:121:in 'Array#map'
        from /usr/local/bundle/gems/rspec-core-3.13.3/lib/rspec/core/runner.rb:121:in 'block (2 levels) in RSpec::Core::Runner#run_specs'
        from /usr/local/bundle/gems/rspec-core-3.13.3/lib/rspec/core/configuration.rb:2097:in 'RSpec::Core::Configuration#with_suite_hooks'
        from /usr/local/bundle/gems/rspec-core-3.13.3/lib/rspec/core/runner.rb:116:in 'block in RSpec::Core::Runner#run_specs'
        from /usr/local/bundle/gems/rspec-core-3.13.3/lib/rspec/core/reporter.rb:74:in 'RSpec::Core::Reporter#report'
        from /usr/local/bundle/gems/rspec-core-3.13.3/lib/rspec/core/runner.rb:115:in 'RSpec::Core::Runner#run_specs'
        from /usr/local/bundle/gems/rspec-core-3.13.3/lib/rspec/core/runner.rb:89:in 'RSpec::Core::Runner#run'
        from /usr/local/bundle/gems/rspec-core-3.13.3/lib/rspec/core/runner.rb:71:in 'RSpec::Core::Runner.run'
        from /usr/local/bundle/gems/rspec-core-3.13.3/lib/rspec/core/runner.rb:45:in 'RSpec::Core::Runner.invoke'
        from /usr/local/bundle/gems/rspec-core-3.13.3/exe/rspec:4:in '<top (required)>'
        from /usr/local/bundle/gems/spring-commands-rspec-1.0.4/lib/spring/commands/rspec.rb:18:in 'Kernel#load'
        from /usr/local/bundle/gems/spring-commands-rspec-1.0.4/lib/spring/commands/rspec.rb:18:in 'Spring::Commands::RSpec#call'
        from /usr/local/bundle/gems/spring-4.2.1/lib/spring/command_wrapper.rb:38:in 'Spring::CommandWrapper#call'
        from /usr/local/bundle/gems/spring-4.2.1/lib/spring/application.rb:226:in 'block in Spring::Application#serve'
        from /usr/local/bundle/gems/spring-4.2.1/lib/spring/application.rb:190:in 'Kernel#fork'
        from /usr/local/bundle/gems/spring-4.2.1/lib/spring/application.rb:190:in 'Spring::Application#serve'
        from /usr/local/bundle/gems/spring-4.2.1/lib/spring/application.rb:153:in 'block in Spring::Application#run'
        from <internal:kernel>:168:in 'Kernel#loop'
        from /usr/local/bundle/gems/spring-4.2.1/lib/spring/application.rb:147:in 'Spring::Application#run'
        from /usr/local/bundle/gems/spring-4.2.1/lib/spring/application/boot.rb:25:in '<top (required)>'
        from <internal:/usr/local/lib/ruby/3.4.0/rubygems/core_ext/kernel_require.rb>:136:in 'Kernel#require'
        from <internal:/usr/local/lib/ruby/3.4.0/rubygems/core_ext/kernel_require.rb>:136:in 'Kernel#require'
        from -e:1:in '<main>'

Run in Terminal has the same issue but if I remove the -r path/to/ruby_lsp_rspec/rspec_formatter then it works:

/app git:(49e7b10bf) bundle exec bin/rspec -r /usr/local/bundle/gems/ruby-lsp-rspec-0.1.23/lib/ruby_lsp/ruby_lsp_rspec/rspec_formatter.rb -f RubyLsp::RSpec::RSpecFormatter /app/spec/core/billing_spec.rb:8
Running via Spring preloader in process 5341
Run options: include {focus: true, locations: {"./spec/core/billing_spec.rb" => [8]}}
/usr/local/bundle/gems/ruby-lsp-rspec-0.1.23/lib/ruby_lsp/ruby_lsp_rspec/rspec_formatter.rb:58:in 'RubyLsp::RSpec::RSpecFormatter#uri_for': undefined method 'from_path' for class URI::Generic (NoMethodError)

        URI::Generic.from_path(path: absolute_path)
                    ^^^^^^^^^^
        [ ... snip ... ]/app git:(49e7b10bf) bundle exec bin/rspec /app/spec/core/billing_spec.rb:8              
Running via Spring preloader in process 5900
Run options: include {focus: true, locations: {"./spec/core/billing_spec.rb" => [8]}}

Randomized with seed 41148

Billing
  .debit!
    takes money out of an account
    raises on insufficient balance
    raises on negative balance

Finished in 0.82687 seconds (files took 0.23695 seconds to load)
3 examples, 0 failures

Randomized with seed 41148

Originally posted by @bjeanes in #62 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions