43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/duck_typer/rspec.rb', line 43
def self.define_shared_example(name = "an interface")
::RSpec.shared_examples name do |*args, namespace: nil, name: nil, type: :instance_methods, methods: nil, strict: false|
objects = namespace ? nil : args.first
it "has compatible interfaces" do
checker = DuckTyper::BulkInterfaceChecker
.new(objects, namespace:, type:, methods:, strict:, name:)
failures = checker.call.reject(&:match?)
if failures.any?
message = failures.map(&:failure_message).join("\n")
raise ::RSpec::Expectations::ExpectationNotMetError, message
end
end
end
end
|