Module: Spectro::ClassMethods
- Defined in:
- lib/spectro.rb
Instance Method Summary collapse
-
#implements(interfaces) ⇒ Object
Register the given method name supporting the given parameters.
Instance Method Details
#implements(interfaces) ⇒ Object
Register the given method name supporting the given parameters.
Whenever Spectro::Config.mocks_enabled? is true it will try to cover unfulfilled specs using the known rules as mocks.
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/spectro.rb', line 43 def implements interfaces file_path = caller.first.match(/(?:^|#{Dir.pwd}\/)([^\/].*):\d+:in .+/)[1] interfaces.each do |method_name, required_params| λ = Spectro::Database.fetch(file_path, method_name, *required_params) || Spectro::Mock.create(file_path, method_name) raise Spectro::Exception::UndefinedMethodDefinition.new(file_path, method_name) if λ.nil? self.send(:define_method, method_name, &λ) end end |