Giter Site home page Giter Site logo

Comments (15)

gregg-platogo avatar gregg-platogo commented on July 17, 2024 3

Yes, we did update to 3.12.6 last week and it does work like a charm ❤️ Thank you guys!

from rspec-mocks.

igor-drozdov avatar igor-drozdov commented on July 17, 2024 3

@JonRowe I wonder if this issue can be closed now, WDYT?

from rspec-mocks.

pirj avatar pirj commented on July 17, 2024 3

Seems fixed. Thanks everyone involved.

from rspec-mocks.

ngouy avatar ngouy commented on July 17, 2024 1

yea. When I monkey patch to
image

My pre-ruby 3 working, now not working test is finally green again

from rspec-mocks.

jonfreeland avatar jonfreeland commented on July 17, 2024 1

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.

igor-drozdov avatar igor-drozdov commented on July 17, 2024 1

@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.

JonRowe avatar JonRowe commented on July 17, 2024

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.

pirj avatar pirj commented on July 17, 2024

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.

JonRowe avatar JonRowe commented on July 17, 2024

@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.

wuarmin avatar wuarmin commented on July 17, 2024

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.

gregg-platogo avatar gregg-platogo commented on July 17, 2024

That's what we came up with to fix this issue platogo@6cdc486

from rspec-mocks.

pirj avatar pirj commented on July 17, 2024

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.

ngouy avatar ngouy commented on July 17, 2024

Digging internet late at night, I think the issue is here no ?

image

We should capture args and kwargs, I might be wrong of course

from rspec-mocks.

ngouy avatar ngouy commented on July 17, 2024

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.

DylanEtris avatar DylanEtris commented on July 17, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.