Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrong number of arguments #206

Open
sobrinho opened this issue Jan 10, 2024 · 4 comments
Open

wrong number of arguments #206

sobrinho opened this issue Jan 10, 2024 · 4 comments

Comments

@sobrinho
Copy link

Hi there!

I'm seeing this error:

       wrong number of arguments (0 for 1) for SuperDiff::ObjectInspection::InspectionTreeBuilders::Main initializer
     # /Users/sobrinho/.gem/ruby/2.7.6/gems/attr_extras-7.1.0/lib/attr_extras/attr_initialize.rb:55:in `validate_arity'
     # /Users/sobrinho/.gem/ruby/2.7.6/gems/attr_extras-7.1.0/lib/attr_extras/attr_initialize.rb:26:in `call'
     # /Users/sobrinho/.gem/ruby/2.7.6/gems/attr_extras-7.1.0/lib/attr_extras/attr_initialize.rb:26:in `block in apply'
     # /Users/sobrinho/.gem/ruby/2.7.6/gems/attr_extras-7.1.0/lib/attr_extras/explicit.rb:73:in `new'
     # /Users/sobrinho/.gem/ruby/2.7.6/gems/attr_extras-7.1.0/lib/attr_extras/explicit.rb:73:in `block (2 levels) in static_facade'
     # /Users/sobrinho/.gem/ruby/2.7.6/gems/super_diff-0.9.0/lib/super_diff.rb:42:in `block in inspect_object'
     # /Users/sobrinho/.gem/ruby/2.7.6/gems/super_diff-0.9.0/lib/super_diff/recursion_guard.rb:21:in `guarding_recursion_of'
     # /Users/sobrinho/.gem/ruby/2.7.6/gems/super_diff-0.9.0/lib/super_diff.rb:41:in `inspect_object'
     # /Users/sobrinho/.gem/ruby/2.7.6/gems/super_diff-0.9.0/lib/super_diff/rspec/monkey_patches.rb:269:in `format'
     # /Users/sobrinho/.gem/ruby/2.7.6/bundler/gems/sidekiq-delay_extensions-bbe5faeaed8b/lib/sidekiq/delay_extensions/class_methods.rb:23:in `perform'

The backtrace after that goes in other gems, let me know if you need it.

@mcmire
Copy link
Collaborator

mcmire commented Jan 11, 2024

Hi @sobrinho. Can you give me an example of the test you're trying to write? That would help me understand what caused this.

@sobrinho
Copy link
Author

There's nothing too specific there, it's a simple expect(something).to receive(:blah).with(1) and then something.blah(2) which causes the assertion failure to happen.

A lot of different specs with different assertions are failing.

Not sure if it's related to Ruby 2.7.6, I'm trying to isolate it.

@jas14
Copy link
Collaborator

jas14 commented Oct 15, 2024

Hey @sobrinho , thanks for the report! First, a note that since Ruby 2.7 has reached end of life, we don't support it any more. But this may be applicable to the latest version anyway.

I did rewind to Ruby 2.7.6, SuperDiff 0.9.0, and fast-forwarded to attr_extras v7.1.0, and was still unable to reproduce this with RSpec 3.9.0 or 3.10.0. Here's my repro file:

require 'super_diff/rspec'

RSpec.describe do
  it do
    something = Struct.new(:blah).new
    expect(something).to receive(:blah).with(1)
    something.blah(2)
  end
end

and here's the output I got:

Failures:

  1) is expected to receive blah(1) 1 time
     Failure/Error: something.blah(2)

       #<struct blah=nil> received :blah with unexpected arguments
         expected: (1)
              got: (2)

Let me know if you're able to reproduce this again. I wonder if the object you're stubbing has some interesting behavior that would make it difficult to inspect, so a full backtrace with the other gems would be good too.

@jas14
Copy link
Collaborator

jas14 commented Oct 16, 2024

Another note: possibly related to #140 – stack trace looks very similar.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants