summaryrefslogtreecommitdiff
path: root/spec/monkey_patches/publicize_methods.rb
blob: 3ae59f978b63db5cc35a0d27d7722ab08862b62e (plain)
1
2
3
4
5
6
7
8
9
10
11
#! /usr/bin/env ruby -S rspec
# Some monkey-patching to allow us to test private methods.
class Class
    def publicize_methods(*methods)
        saved_private_instance_methods = methods.empty? ? self.private_instance_methods : methods

        self.class_eval { public(*saved_private_instance_methods) }
        yield
        self.class_eval { private(*saved_private_instance_methods) }
    end
end