Sha256: dfc9ad4c7113d5402e09e38ffabeff5664a8ba5ba4576c906c2374e0011c3ffb

Contents?: true

Size: 420 Bytes

Versions: 2

Compression:

Stored size: 420 Bytes

Contents

require 'werd'
require 'pry'


def verify_contracted_instance_method(klass, method, ret)
  klass.decorated_methods[:instance_methods][method.to_sym].each do |contract|
    validator = Contract.make_validator(contract.ret_contract)
    if validator.call(ret)
      return ret
    else
      raise <<-END
      #{klass}##{method} contract violated.
      #{contract}
      Cannot return #{ret}
      END
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
werd-0.0.2 spec/spec_helper.rb
werd-0.0.1 spec/spec_helper.rb