Class: Webspicy::Specification::Service

Inherits:
Object
  • Object
show all
Includes:
Webspicy::Support::DataObject
Defined in:
lib/webspicy/specification/service.rb

Direct Known Subclasses

Web::Specification::Service

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Webspicy::Support::DataObject

#method_missing, #to_info

Constructor Details

#initialize(raw) ⇒ Service

Returns a new instance of Service.



6
7
8
9
10
# File 'lib/webspicy/specification/service.rb', line 6

def initialize(raw)
  super(raw)
  bind_examples
  bind_counterexamples
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Webspicy::Support::DataObject

Instance Attribute Details

#specificationObject Also known as: resource

Returns the value of attribute specification.



11
12
13
# File 'lib/webspicy/specification/service.rb', line 11

def specification
  @specification
end

Class Method Details

.info(raw) ⇒ Object



16
17
18
# File 'lib/webspicy/specification/service.rb', line 16

def self.info(raw)
  new(raw)
end

Instance Method Details

#conditionsObject



32
33
34
# File 'lib/webspicy/specification/service.rb', line 32

def conditions
  preconditions + postconditions
end

#configObject



20
21
22
# File 'lib/webspicy/specification/service.rb', line 20

def config
  specification.config
end

#counterexamplesObject



68
69
70
# File 'lib/webspicy/specification/service.rb', line 68

def counterexamples
  @raw[:counterexamples] || []
end

#default_exampleObject



60
61
62
# File 'lib/webspicy/specification/service.rb', line 60

def default_example
  @raw[:default_example]
end

#descriptionObject



28
29
30
# File 'lib/webspicy/specification/service.rb', line 28

def description
  @raw[:description]
end

#dress_params(params) ⇒ Object



93
94
95
# File 'lib/webspicy/specification/service.rb', line 93

def dress_params(params)
  input_schema.dress(params)
end

#errconditionsObject



52
53
54
# File 'lib/webspicy/specification/service.rb', line 52

def errconditions
  @errconditions ||= compile_errconditions
end

#error_schemaObject



89
90
91
# File 'lib/webspicy/specification/service.rb', line 89

def error_schema
  @raw[:error_schema]
end

#examplesObject



64
65
66
# File 'lib/webspicy/specification/service.rb', line 64

def examples
  @raw[:examples] || []
end

#generated_counterexamplesObject



72
73
74
75
76
77
78
79
# File 'lib/webspicy/specification/service.rb', line 72

def generated_counterexamples
  preconditions.map{|pre|
    pre.counterexamples(self).map{|tc|
      tc = config.factory.test_case(tc, Webspicy.current_scope)
      tc.bind(self, true)
    }
  }.flatten
end

#has_errconditions?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/webspicy/specification/service.rb', line 56

def has_errconditions?
  !errconditions.empty?
end

#has_postconditions?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/webspicy/specification/service.rb', line 48

def has_postconditions?
  !postconditions.empty?
end

#has_preconditions?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/webspicy/specification/service.rb', line 40

def has_preconditions?
  !preconditions.empty?
end

#input_schemaObject



81
82
83
# File 'lib/webspicy/specification/service.rb', line 81

def input_schema
  @raw[:input_schema]
end

#nameObject



24
25
26
# File 'lib/webspicy/specification/service.rb', line 24

def name
  @raw[:name]
end

#output_schemaObject



85
86
87
# File 'lib/webspicy/specification/service.rb', line 85

def output_schema
  @raw[:output_schema]
end

#postconditionsObject



44
45
46
# File 'lib/webspicy/specification/service.rb', line 44

def postconditions
  @postconditions ||= compile_postconditions
end

#preconditionsObject



36
37
38
# File 'lib/webspicy/specification/service.rb', line 36

def preconditions
  @preconditions ||= compile_preconditions
end

#to_sObject



97
98
99
# File 'lib/webspicy/specification/service.rb', line 97

def to_s
  "#{method} #{specification.url}"
end