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 #94

Closed
nirname opened this issue Mar 26, 2024 · 9 comments
Closed

Wrong number of arguments #94

nirname opened this issue Mar 26, 2024 · 9 comments

Comments

@nirname
Copy link

nirname commented Mar 26, 2024

Rails 5.2

Using rspec-support 3.12.1
Using rspec-core 3.12.2
Using rspec-expectations 3.12.3
Using rspec-mocks 3.12.6
Using rspec 3.12.0
Using rspec-html-matchers 0.10.0
Using rspec-its 1.3.0
Using rspec-rails 4.0.1

When using [] for accessing hash-subject attributes

Failure/Error: its([:amount]) { is_expected.to eq(1)}

ArgumentError:
  wrong number of arguments (given 2, expected 3..5)

https://github.com/rspec/rspec-its/blob/main/lib/rspec/its.rb#L169

@pirj
Copy link
Member

pirj commented Mar 26, 2024

Can you please provide a bit more context about the spec you’re dealing with?

What if you set the breakpoint here, what seems off to you?

@nirname
Copy link
Author

nirname commented Mar 26, 2024

The part you mention works. It complains about this part

example(nil, *options, &block)

Although these 2 methods should be identical
https://github.com/rspec/rspec-core/blob/1e661db5c5b431c0ee88a383e8e3767f02dccbfe/lib/rspec/core/example_group.rb#L158
and
https://github.com/rspec/rspec-core/blob/1e661db5c5b431c0ee88a383e8e3767f02dccbfe/lib/rspec/core/example_group.rb#L161
vendoring the lib and replacing example with it helped
Still not sure if it's compatibility problems

@pirj
Copy link
Member

pirj commented Mar 27, 2024

My apologies for being annoying. Let me repeat my questions.

Can you please provide a bit more context about the spec you’re dealing with?

What if you set the breakpoint here, what seems off to you?

@nirname
Copy link
Author

nirname commented Apr 21, 2024

@pirj Sorry for the long response, I'll try to reproduce this and provide more detailed description

@paniko0
Copy link

paniko0 commented Oct 21, 2024

I'm having the same issue. For me, this is happening because the gem rswag overrides the method example in here

I'm not entirely sure if it's a problem of the rswag gem or the rspec-its gem. If I were to bet, I'd say changing this gem to call RSpec::Core::ExampleGroup.example instead of just example in here is easier.

@pirj
Copy link
Member

pirj commented Oct 22, 2024

Do you want to send a PR?

@paniko0
Copy link

paniko0 commented Oct 22, 2024

I can certainly push a change, but I can't say this is going to fix OP's issue since OP didn't provide a Gemfile to compare.

@pirj
Copy link
Member

pirj commented Oct 22, 2024

That’s the best guess we have, and it will fix your issue that we know how to reproduce. If this it turns out not to fix the original issue, the author will reopen with details to reproduce.

@JonRowe
Copy link
Member

JonRowe commented Oct 22, 2024

Fixed in #95, I think its bad form to override this method but we have a readily accessible work around in defining our own example creation method and using it.

@JonRowe JonRowe closed this as completed Oct 23, 2024
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

4 participants