Skip to content

Global definition of 'with' function in Kernel module breaks rspec functionality #290

@PhilippOtto89

Description

@PhilippOtto89

Hey developers,

in our project we use facets and RSpec. Rspec has an awesome feature to check if a function was called with parameters like

expect(dbl).to receive(:foo).with(1, anything, /bar/)

Unfortunately this breaks because there seems to be a global override of this function in facets. We receive the error

ArgumentError:
wrong number of arguments (given 3, expected 0..1)
/Users/philip.otto/.rvm/gems/ruby-2.6.0/gems/facets-3.1.0/lib/core/facets/kernel/with.rb:15:in `with'

And this file indeed contains a definition of this function

module Kernel
  def with(obj=self, &block)
    obj.instance_eval(&block)
  end
end

Is this global definition really necessary since it seems to interfere with other implementations?

Thanks for reading my question and have a nice day guys!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions