lib/with_public.rb
def with_public(*methods)
    target = self
    Module.new.tap do |refiner|
      refiner.module_eval do
        refine target do
          public(*methods)
        end
      end
    end
  end
# 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
Returns a refiner module to make target methods public
Returns a refiner module to make target methods public
def with_public(*methods)
    target = self
    Module.new.tap do |refiner|
      refiner.module_eval do
        refine target do
          public(*methods)
        end
      end
    end
  end
def with_public ( * methods ) target = self Module . new . tap do | refiner | refiner . module_eval do refine target do public ( * methods ) end end end end
Returns a refiner module to make target methods public
Returns a refiner module to make target methods public
a refinement module to make given methods public
a refinement module to make given methods public
Module
methods
methods Method symbols to be made public
methods Method symbols to be made 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
Make Foo#bar public RSpec . describe Foo do using Foo . with_public ( : bar ) # Calling Foo#bar will not raise NoMethodError in this context . end