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

Usage of keyword arguments as positional arguments in stubs #47

Closed
icy-arctic-fox opened this issue Oct 9, 2022 · 1 comment
Closed
Assignees
Labels
enhancement New feature or request inconsistency Behaves differently from RSpec
Milestone

Comments

@icy-arctic-fox
Copy link
Owner

Allow positional arguments to be defined with keyword arguments. Currently, keyword arguments are treated separately from positional arguments.

class Original
  def foo(arg1, arg2)
    # ...
  end
end

mock Original

let(fake) { mock(Original) }

specify do
  expect(fake).to receive(:foo).with("arg1", arg2: "arg2")
  fake.foo("arg1", "arg2")
end

The expectation fails because it recorded the call #foo("arg1", "arg2") and not #foo("arg1", arg2: "arg2"). The two calls are technically the same to Crystal, but Spectator treats them differently.

@icy-arctic-fox icy-arctic-fox added enhancement New feature or request inconsistency Behaves differently from RSpec labels Oct 9, 2022
@icy-arctic-fox icy-arctic-fox added this to the v0.11 milestone Oct 9, 2022
@icy-arctic-fox icy-arctic-fox self-assigned this Oct 9, 2022
icy-arctic-fox added a commit that referenced this issue Oct 10, 2022
icy-arctic-fox added a commit that referenced this issue Oct 24, 2022
Implements #47
Some specs are failing and need to be resolved before the new feature is considered done.
@icy-arctic-fox
Copy link
Owner Author

Implemented on master. Will be in the next release.

icy-arctic-fox added a commit that referenced this issue Nov 28, 2022
Code changes for #47 caused a drastic increase in compilation times.
This improves compilation times by splitting concerns for arguments.
In one case, arguments are used for matching.
In the other, arguments are captured for comparison.
The second case has been moved to a FormalArguments class.
Theoretically, this reduces the complexity and combinations the compiler might be iterating.
icy-arctic-fox added a commit that referenced this issue Nov 30, 2022
Reenable test for #44 and #47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request inconsistency Behaves differently from RSpec
Projects
None yet
Development

No branches or pull requests

1 participant