Class: Webspicy::Specification::TestCase

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

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) ⇒ TestCase

Returns a new instance of TestCase.



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

def initialize(raw)
  super(raw)
  @counterexample = nil
end

Dynamic Method Handling

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

Instance Attribute Details

#counterexampleObject (readonly)

Returns the value of attribute counterexample.



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

def counterexample
  @counterexample
end

#serviceObject (readonly)

Returns the value of attribute service.



10
11
12
# File 'lib/webspicy/specification/test_case.rb', line 10

def service
  @service
end

Class Method Details

.info(raw) ⇒ Object



34
35
36
# File 'lib/webspicy/specification/test_case.rb', line 34

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

Instance Method Details

#assertObject



115
116
117
# File 'lib/webspicy/specification/test_case.rb', line 115

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

#bind(service, counterexample) ⇒ Object



13
14
15
16
17
# File 'lib/webspicy/specification/test_case.rb', line 13

def bind(service, counterexample)
  @service = service
  @counterexample = counterexample
  self
end

#bodyObject



67
68
69
# File 'lib/webspicy/specification/test_case.rb', line 67

def body
  @raw[:body]
end

#counterexample?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/webspicy/specification/test_case.rb', line 23

def counterexample?
  !!@counterexample
end

#descriptionObject



38
39
40
# File 'lib/webspicy/specification/test_case.rb', line 38

def description
  @raw[:description]
end

#dress_paramsObject Also known as: dress_params?



58
59
60
# File 'lib/webspicy/specification/test_case.rb', line 58

def dress_params
  @raw.fetch(:dress_params){ true }
end

#example?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/webspicy/specification/test_case.rb', line 19

def example?
  !@counterexample
end

#expectedObject



79
80
81
# File 'lib/webspicy/specification/test_case.rb', line 79

def expected
  @raw[:expected] || {}
end

#expected_content_typeObject



83
84
85
# File 'lib/webspicy/specification/test_case.rb', line 83

def expected_content_type
  expected[:content_type]
end

#expected_errorObject



99
100
101
# File 'lib/webspicy/specification/test_case.rb', line 99

def expected_error
  expected[:error]
end

#expected_headersObject



107
108
109
# File 'lib/webspicy/specification/test_case.rb', line 107

def expected_headers
  expected[:headers] || {}
end

#expected_statusObject



87
88
89
# File 'lib/webspicy/specification/test_case.rb', line 87

def expected_status
  expected[:status]
end

#file_uploadObject



71
72
73
# File 'lib/webspicy/specification/test_case.rb', line 71

def file_upload
  @raw[:file_upload]
end

#has_assertions?Boolean

Returns:

  • (Boolean)


119
120
121
# File 'lib/webspicy/specification/test_case.rb', line 119

def has_assertions?
  !assert.empty?
end

#has_expected_error?Boolean

Returns:

  • (Boolean)


103
104
105
# File 'lib/webspicy/specification/test_case.rb', line 103

def has_expected_error?
  !expected_error.nil?
end

#has_expected_headers?Boolean

Returns:

  • (Boolean)


111
112
113
# File 'lib/webspicy/specification/test_case.rb', line 111

def has_expected_headers?
  !expected_headers.empty?
end

#has_expected_status?Boolean

Returns:

  • (Boolean)


95
96
97
# File 'lib/webspicy/specification/test_case.rb', line 95

def has_expected_status?
  not expected[:status].nil?
end

#headersObject



46
47
48
# File 'lib/webspicy/specification/test_case.rb', line 46

def headers
  @raw[:headers] ||= {}
end

#is_expected_status?(status) ⇒ Boolean

Returns:

  • (Boolean)


91
92
93
# File 'lib/webspicy/specification/test_case.rb', line 91

def is_expected_status?(status)
  expected_status === status
end

#located_file_uploadObject



75
76
77
# File 'lib/webspicy/specification/test_case.rb', line 75

def located_file_upload
  file_upload ? file_upload.locate(specification) : nil
end

#metadataObject



50
51
52
# File 'lib/webspicy/specification/test_case.rb', line 50

def 
  @raw[:metadata] ||= {}
end

#mutate(override) ⇒ Object



123
124
125
126
127
# File 'lib/webspicy/specification/test_case.rb', line 123

def mutate(override)
  m = self.dup
  m.raw = self.raw.merge(override)
  m
end

#paramsObject



63
64
65
# File 'lib/webspicy/specification/test_case.rb', line 63

def params
  @raw[:params] || {}
end

#seedsObject



42
43
44
# File 'lib/webspicy/specification/test_case.rb', line 42

def seeds
  @raw[:seeds]
end

#specificationObject Also known as: resource



27
28
29
# File 'lib/webspicy/specification/test_case.rb', line 27

def specification
  service.specification
end

#tagsObject



54
55
56
# File 'lib/webspicy/specification/test_case.rb', line 54

def tags
  @raw[:tags] ||= []
end

#to_sObject



129
130
131
# File 'lib/webspicy/specification/test_case.rb', line 129

def to_s
  description
end