require 'contracts'
include Contracts
Contract String => String
Contract Num => String
def foo x
end
This code raises a NameError:
$ ruby foo_test.rb
c:/Ruby22/lib/ruby/gems/2.2.0/gems/contracts-0.16.0/lib/contracts/method_handler
.rb:160:in validate_decorators!': undefined local variable or methodname' for
(NameError)
from c:/Ruby22/lib/ruby/gems/2.2.0/gems/contracts-0.16.0/lib/contracts/m
ethod_handler.rb:31:in handle' from c:/Ruby22/lib/ruby/gems/2.2.0/gems/contracts-0.16.0/lib/contracts/d ecorators.rb:13:inmethod_added'
from foo_test.rb:7:in `'
It should instead raise a RuntimeError with the intended message.
require 'contracts' include Contracts Contract String => String Contract Num => String def foo x end
This code raises a NameError:
$ ruby foo_test.rb c:/Ruby22/lib/ruby/gems/2.2.0/gems/contracts-0.16.0/lib/contracts/method_handler .rb:160:in
validate_decorators!': undefined local variable or method
name' forethod_handler.rb:31:in'
handle' from c:/Ruby22/lib/ruby/gems/2.2.0/gems/contracts-0.16.0/lib/contracts/d ecorators.rb:13:in
method_added' from foo_test.rb:7:in `It should instead raise a RuntimeError with the intended message.