Module: ApiValidator::Spec::SharedClassAndInstanceMethods

Included in:
ApiValidator::Spec, ApiValidator::Spec
Defined in:
lib/api-validator/spec.rb

Instance Method Summary collapse

Instance Method Details

#describe(name, options = {}, &block) ⇒ Object Also known as: context



25
26
27
28
29
# File 'lib/api-validator/spec.rb', line 25

def describe(name, options = {}, &block)
  validation = self.new(name, options.merge(:parent => self), &block)
  self.validations << validation
  validation
end

#shared_example(name, &block) ⇒ Object



17
18
19
# File 'lib/api-validator/spec.rb', line 17

def shared_example(name, &block)
  self.shared_examples[name] = block
end

#shared_examplesObject



7
8
9
10
11
12
13
14
15
# File 'lib/api-validator/spec.rb', line 7

def shared_examples
  @shared_examples ||= begin
    if self.respond_to?(:superclass) && self.superclass.respond_to?(:shared_examples)
      self.superclass.shared_examples || Hash.new
    else
      Hash.new
    end
  end
end

#validationsObject



21
22
23
# File 'lib/api-validator/spec.rb', line 21

def validations
  @validations ||= []
end