module WithPublic
A module to define with_public
method to Module class. With this module, one can test private methods without Object#send.
Constants
- VERSION
Public Instance Methods
with_public(*methods)
click to toggle source
Returns a refiner module to make target methods public
@param [Array<Symbol>] methods Method symbols to be made public @return [Module] a refinement module to make given methods public @example Make Foo#bar public
RSpec.describe Foo do using Foo.with_public(:bar) # Calling Foo#bar will not raise NoMethodError in this context. end
# File lib/with_public.rb, line 17 def with_public(*methods) target = self Module.new.tap do |refiner| refiner.module_eval do refine target do public(*methods) end end end end