This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[user] | |
name = … | |
email = … | |
signingkey = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RSpec.shared_examples_for "check interface against canonical" do |canonical_interface, classes_to_check| | |
classes_to_check.each do |class_to_check| | |
example "#{class_to_check} conforms to the required interface", :aggregate_failures do | |
interface_methods = canonical_interface.public_instance_methods(false) | |
methods_to_check = class_to_check.public_instance_methods(false) | |
diff = interface_methods - methods_to_check | |
expect(diff).to be_empty, (<<~MESSAGE).split("\n").join(" ") | |
Expected #{class_to_check} to be polymorphic with |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RSpec.shared_examples_for "interface checker" do | |
def diff_for(array_1, array_2) | |
(array_1 - array_2) + (array_2 - array_1) | |
end | |
def arities_for(object) | |
object.public_methods.map do |m| | |
arity = object.method(m).arity | |
[m, arity == -1 ? anything : arity] | |
end |