Module: ArgumentSpecification::DSL

Defined in:
lib/argspec/dsl.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.register_matcher(klass, name) ⇒ Object

Register a matcher

Arguments:

klass: (Matchers::BaseMatcher)
name: (Symbol)

Example:

>> register_matcher(TestMatcher, :test_matcher)
=> true


14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/argspec/dsl.rb', line 14

def register_matcher(klass, name)
  return unless klass.ancestors.include?(Matchers::BaseMatcher)
  return unless name.is_a?(Symbol)

  module_eval "    def \#{name}(*args, &block)\n      instance = \#{klass}.new(*args, &block)\n      instance.send(:setup, '\#{name}'.to_sym, args)\n      instance\n    end\n  EOS\nend\n"

Instance Method Details

#argument(object) ⇒ Object

Get an argument object

Arguments:

object: (Object)

Example:

>> test = :test
>> argument(test)
=> #<Argument:0x00000000000000 @object=:test>


38
39
40
# File 'lib/argspec/dsl.rb', line 38

def argument(object)
    ArgumentSpecification::Argument.new(object)
end