Class: Webspicy::Web::Specification::TestCase
Instance Attribute Summary
#counterexample, #service
Class Method Summary
collapse
Instance Method Summary
collapse
#assert, #bind, #counterexample?, #description, #example?, #expected, #expected_error, #has_assertions?, #has_expected_error?, info, #initialize, #input, #metadata, #mutate, #seeds, #specification, #tags, #to_s
#initialize, #method_missing, #to_info
Class Method Details
.v2(info) ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/webspicy/web/specification/test_case.rb', line 6
def self.v2(info)
info = info.dup
if !info.has_key?(:description) && (info.has_key?(:when) || info.has_key?(:it))
info[:description] = "when #{info[:when]}" if info.has_key?(:when)
info[:description] << ", it #{info[:it]}" if info.has_key?(:it)
info.delete_if{|k,v| k == :when || k == :it }
end
if !info.has_key?(:dress_params) && info.has_key?(:validate_input)
info[:dress_params] = info[:validate_input]
info.delete(:validate_input)
end
if !info.has_key?(:params) && info.has_key?(:input)
info[:params] = info[:input]
info.delete(:input)
end
new(info)
end
|
Instance Method Details
#body ⇒ Object
37
38
39
|
# File 'lib/webspicy/web/specification/test_case.rb', line 37
def body
@raw[:body]
end
|
#dress_params ⇒ Object
Also known as:
dress_params?
28
29
30
|
# File 'lib/webspicy/web/specification/test_case.rb', line 28
def dress_params
@raw.fetch(:dress_params){ true }
end
|
#expected_content_type ⇒ Object
49
50
51
|
# File 'lib/webspicy/web/specification/test_case.rb', line 49
def expected_content_type
expected[:content_type]
end
|
70
71
72
|
# File 'lib/webspicy/web/specification/test_case.rb', line 70
def
expected[:headers] || {}
end
|
#expected_status ⇒ Object
53
54
55
|
# File 'lib/webspicy/web/specification/test_case.rb', line 53
def expected_status
expected[:status]
end
|
#file_upload ⇒ Object
41
42
43
|
# File 'lib/webspicy/web/specification/test_case.rb', line 41
def file_upload
@raw[:file_upload]
end
|
74
75
76
|
# File 'lib/webspicy/web/specification/test_case.rb', line 74
def
!.empty?
end
|
#has_expected_status? ⇒ Boolean
61
62
63
|
# File 'lib/webspicy/web/specification/test_case.rb', line 61
def has_expected_status?
not expected[:status].nil?
end
|
24
25
26
|
# File 'lib/webspicy/web/specification/test_case.rb', line 24
def
@raw[:headers] ||= {}
end
|
#is_expected_status?(status) ⇒ Boolean
57
58
59
|
# File 'lib/webspicy/web/specification/test_case.rb', line 57
def is_expected_status?(status)
expected_status === status
end
|
#is_redirect_expected_status? ⇒ Boolean
65
66
67
68
|
# File 'lib/webspicy/web/specification/test_case.rb', line 65
def is_redirect_expected_status?
start = expected_status.to_int
start >= 300 && start < 400
end
|
#located_file_upload ⇒ Object
45
46
47
|
# File 'lib/webspicy/web/specification/test_case.rb', line 45
def located_file_upload
file_upload ? file_upload.locate(specification) : nil
end
|
#params ⇒ Object
33
34
35
|
# File 'lib/webspicy/web/specification/test_case.rb', line 33
def params
@raw[:params] || {}
end
|
#to_v2 ⇒ Object
78
79
80
81
82
83
84
85
86
87
88
89
90
|
# File 'lib/webspicy/web/specification/test_case.rb', line 78
def to_v2
info = to_info
info = info.merge({
validate_input: !!info[:dress_params],
input: info[:params] || {},
}).delete_if{|k,v| k == :dress_params || k == :params }
if info[:description] =~ /^when (.*?), it (.*)$/
info[:when] = $1
info[:it] = $2
info.delete(:description)
end
info
end
|