Module: Contracts::RSpec

Defined in:
lib/contracts/rspec/verifier.rb

Class Method Summary collapse

Class Method Details

.verify_all!Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/contracts/rspec/verifier.rb', line 9

def verify_all!
  failures = Contracts.registry.all.filter_map do |contract|
    next if contract.method_name == :__invariant__

    owner = contract.owner
    next if owner.method_defined?(contract.method_name) ||
            owner.private_method_defined?(contract.method_name) ||
            owner.protected_method_defined?(contract.method_name)

    "#{contract.id} references a missing method"
  end
  raise Contracts::DefinitionError, failures.join("\n") unless failures.empty?

  true
end