Comments (15)
Yes, we did update to 3.12.6 last week and it does work like a charm ❤️ Thank you guys!
from rspec-mocks.
@JonRowe I wonder if this issue can be closed now, WDYT?
from rspec-mocks.
Seems fixed. Thanks everyone involved.
from rspec-mocks.
My pre-ruby 3 working, now not working test is finally green again
from rspec-mocks.
This is working for me as well, code for convenience:
module RSpec
module Mocks
class MessageExpectation
def and_call_original
block = lambda do |original, *args, **kwargs, &b|
original.call(*args, **kwargs, &b)
end
block = block.ruby2_keywords if block.respond_to?(:ruby2_keywords)
wrap_original(__method__, &block)
end
end
end
end
It still results in a warning:
Skipping set of ruby2_keywords flag for proc (proc accepts keywords or proc does not accept argument splat)
But tests are green.
from rspec-mocks.
@jonfreeland I wonder if the issue is fixed in 3.12.6 by this PR: #1552
@gregg-platogo 3.12.6 now contains the fix that is very similar to yours: #1552. Could you please verify that it works for you?
from rspec-mocks.
Whats the implementation of filter? As you can see from other issues we're aware of some differences in Ruby 3.2 so this is probably a duplicate.
from rspec-mocks.
In general, there should be no difference in 3.2?
a = {a: 1, b: 2}
def x(**opt)
puts opt.inspect
end
def y(a:, b:)
puts a + b
end
def x(opt)
puts opt.inspect
end
x(**a) # => {:a=>1, :b=>2}
y(**a) # => 3
z(**a) # => {:a=>1, :b=>2}
from rspec-mocks.
@pirj, in the case of def x(opt)
RSpecs output above would be correct, it doesn't take keyword arguments, and in general using **kwargs
to an argument as a hash is a duplicate of #1492 and there is something that changed there, but honestly people shouldn't be de-splating keyword arguments to hashes
from rspec-mocks.
Thanks for the response @JonRowe. Here's the implementation of filter
def filter(**filter)
get("customers", filter)
end
private
def get(path, params = {})
conn.get(path, params)
end
and the method is called like this:
repo.filter(first_name: "Toni", last_name: "Hawk")
from rspec-mocks.
That's what we came up with to fix this issue platogo@6cdc486
from rspec-mocks.
This is interesting, @gregg-platogo !
Wondering if it would work like we do e.g. here:
@original_implementation_callable ||= original_method ||
Proc.new do |*args, &block|
@object.__send__(:method_missing, @method_name, *args, &block)
end.tap do |proc|
proc.ruby2_keywords if proc.respond_to?(:ruby2_keywords)
end
Would you be so kind to check if this would work for your cases?
from rspec-mocks.
Digging internet late at night, I think the issue is here no ?
We should capture args and kwargs, I might be wrong of course
from rspec-mocks.
I don't have time nor faith to write the spec for that, hence make a PR. But in my case it fixed it
from rspec-mocks.
I noticed that this issue hasn't had any updates in a while and the issue has been resolved, can it be closed?
from rspec-mocks.
Related Issues (20)
- and_wrap_original doesn't work with kwargs in Ruby 3.2 HOT 3
- array_excluding matcher? HOT 2
- Rails 7.1 breaks receive().with HOT 6
- Assertion that Array#reverse is not called always fails
- stub_const doesn't work with constant inside `class << self` block HOT 3
- update repository 'About' setting to use rspec.info docs url instead of Relish
- Mocking methods changes `Method#parameters`. HOT 1
- Keyword args not validated HOT 1
- RSpec 3.11 mistakes kwargs for hash, when `verify_partial_doubles` is set to true HOT 4
- stub_const does not restore Object.const_source_location after reset HOT 3
- doc: broken links (404) on rspec.info HOT 6
- hash_including deviates from a_hash_including HOT 1
- (Fixed in `3.13.0pre`) `ActiveSupport`'s `Object#with` core extension overrides `RSpec::Mocks::Matchers::Receive(Object)#with` HOT 1
- facing issue with rspec-mocks test cases HOT 1
- `stack level too deep` when stubbing :is_a? with allow_any_instance_of
- `stack level too deep` when stubbing :is_a? with allow_any_instance_of
- `stub_const` doesn't clear `Class#subclasses` HOT 15
- and_wrap_original failing in ruby 3.2
- Mutex cannot be mocked since 3.9.0 (Stack level too deep) HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rspec-mocks.