webspicy 0.16.3 → 0.20.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +9 -3
  3. data/bin/webspicy +6 -1
  4. data/doc/1-black-box-scene.md +109 -0
  5. data/doc/2-black-box-testing.md +27 -0
  6. data/doc/3-specification-importance.md +41 -0
  7. data/doc/4-sequence-diagram.md +82 -0
  8. data/lib/webspicy.rb +18 -9
  9. data/lib/webspicy/configuration.rb +57 -8
  10. data/lib/webspicy/configuration/scope.rb +22 -16
  11. data/lib/webspicy/formaldoc.fio +7 -5
  12. data/lib/webspicy/specification.rb +10 -9
  13. data/lib/webspicy/specification/condition.rb +48 -0
  14. data/lib/webspicy/specification/err.rb +18 -0
  15. data/lib/webspicy/specification/oldies.rb +4 -0
  16. data/lib/webspicy/specification/oldies/bridge.rb +29 -0
  17. data/lib/webspicy/specification/oldies/errcondition.rb +22 -0
  18. data/lib/webspicy/specification/{postcondition.rb → oldies/postcondition.rb} +6 -0
  19. data/lib/webspicy/specification/{precondition.rb → oldies/precondition.rb} +6 -2
  20. data/lib/webspicy/specification/post.rb +20 -0
  21. data/lib/webspicy/specification/post/missing_condition_impl.rb +15 -0
  22. data/lib/webspicy/specification/post/unexpected_condition_impl.rb +15 -0
  23. data/lib/webspicy/specification/pre.rb +19 -0
  24. data/lib/webspicy/specification/{precondition → pre}/global_request_headers.rb +4 -4
  25. data/lib/webspicy/specification/{precondition → pre}/robust_to_invalid_input.rb +4 -4
  26. data/lib/webspicy/specification/service.rb +58 -24
  27. data/lib/webspicy/specification/test_case.rb +10 -17
  28. data/lib/webspicy/support.rb +32 -0
  29. data/lib/webspicy/support/data_object.rb +25 -0
  30. data/lib/webspicy/support/hooks.rb +65 -0
  31. data/lib/webspicy/support/world.rb +47 -0
  32. data/lib/webspicy/tester.rb +180 -60
  33. data/lib/webspicy/tester/asserter.rb +9 -4
  34. data/lib/webspicy/tester/assertions.rb +8 -9
  35. data/lib/webspicy/tester/client.rb +4 -50
  36. data/lib/webspicy/tester/failure.rb +6 -0
  37. data/lib/webspicy/tester/fakeses.rb +41 -0
  38. data/lib/webspicy/tester/fakeses/email.rb +38 -0
  39. data/lib/webspicy/tester/fakesmtp.rb +39 -0
  40. data/lib/webspicy/tester/fakesmtp/email.rb +27 -0
  41. data/lib/webspicy/tester/file_checker.rb +22 -0
  42. data/lib/webspicy/tester/invocation.rb +15 -196
  43. data/lib/webspicy/tester/reporter.rb +85 -0
  44. data/lib/webspicy/tester/reporter/composite.rb +38 -0
  45. data/lib/webspicy/tester/reporter/documentation.rb +74 -0
  46. data/lib/webspicy/tester/reporter/error_count.rb +25 -0
  47. data/lib/webspicy/tester/reporter/exceptions.rb +62 -0
  48. data/lib/webspicy/tester/reporter/file_progress.rb +25 -0
  49. data/lib/webspicy/tester/reporter/file_summary.rb +43 -0
  50. data/lib/webspicy/tester/reporter/progress.rb +30 -0
  51. data/lib/webspicy/tester/reporter/summary.rb +63 -0
  52. data/lib/webspicy/tester/result.rb +142 -0
  53. data/lib/webspicy/tester/result/assert_met.rb +29 -0
  54. data/lib/webspicy/tester/result/check.rb +33 -0
  55. data/lib/webspicy/tester/result/errcondition_met.rb +29 -0
  56. data/lib/webspicy/tester/result/error_schema_met.rb +25 -0
  57. data/lib/webspicy/tester/result/invocation_succeeded.rb +13 -0
  58. data/lib/webspicy/tester/result/output_schema_met.rb +25 -0
  59. data/lib/webspicy/tester/result/postcondition_met.rb +29 -0
  60. data/lib/webspicy/tester/result/response_header_met.rb +43 -0
  61. data/lib/webspicy/tester/result/response_status_met.rb +25 -0
  62. data/lib/webspicy/version.rb +2 -2
  63. data/lib/webspicy/web.rb +4 -0
  64. data/lib/webspicy/web/client.rb +15 -0
  65. data/lib/webspicy/{tester → web}/client/http_client.rb +34 -14
  66. data/lib/webspicy/{tester → web}/client/rack_test_client.rb +3 -3
  67. data/lib/webspicy/{tester → web}/client/support.rb +2 -2
  68. data/lib/webspicy/web/invocation.rb +68 -0
  69. data/lib/webspicy/web/mocker.rb +90 -0
  70. data/lib/webspicy/{mocker → web/mocker}/config.ru +3 -2
  71. data/lib/webspicy/{openapi.rb → web/openapi.rb} +0 -0
  72. data/lib/webspicy/web/openapi/generator.rb +129 -0
  73. data/spec/unit/configuration/scope/test_each_service.rb +2 -2
  74. data/spec/unit/configuration/scope/test_each_specification.rb +7 -7
  75. data/spec/unit/specification/{precondition → pre}/test_global_request_headers.rb +9 -4
  76. data/spec/unit/specification/test_condition.rb +44 -0
  77. data/spec/unit/support/hooks/test_fire_after_each.rb +53 -0
  78. data/spec/unit/{tester/client/test_around.rb → support/hooks/test_fire_around.rb} +15 -10
  79. data/spec/unit/support/hooks/test_fire_before_each.rb +53 -0
  80. data/spec/unit/support/world/fixtures/array.json +8 -0
  81. data/spec/unit/support/world/fixtures/queue.rb +1 -0
  82. data/spec/unit/support/world/fixtures/single.json +11 -0
  83. data/spec/unit/support/world/fixtures/yaml.yml +3 -0
  84. data/spec/unit/support/world/test_world.rb +56 -0
  85. data/spec/unit/test_configuration.rb +50 -1
  86. data/spec/unit/tester/fakeses/test_email.rb +40 -0
  87. data/spec/unit/tester/test_asserter.rb +198 -3
  88. data/spec/unit/tester/test_assertions.rb +8 -6
  89. data/spec/unit/web/mocker/test_mocker.rb +35 -0
  90. data/spec/unit/web/openapi/test_generator.rb +31 -0
  91. metadata +90 -67
  92. data/examples/restful/Gemfile +0 -5
  93. data/examples/restful/Gemfile.lock +0 -105
  94. data/examples/restful/Rakefile +0 -25
  95. data/examples/restful/app.rb +0 -180
  96. data/examples/restful/webspicy/config.rb +0 -23
  97. data/examples/restful/webspicy/rack.rb +0 -7
  98. data/examples/restful/webspicy/real.rb +0 -8
  99. data/examples/restful/webspicy/schema.fio +0 -20
  100. data/examples/restful/webspicy/support/must_be_an_admin.rb +0 -20
  101. data/examples/restful/webspicy/support/must_be_authenticated.rb +0 -48
  102. data/examples/restful/webspicy/support/todo_removed.rb +0 -18
  103. data/examples/restful/webspicy/todo/deleteTodo.yml +0 -52
  104. data/examples/restful/webspicy/todo/getTodo.yml +0 -50
  105. data/examples/restful/webspicy/todo/getTodoSingleServiceFormat.yml +0 -46
  106. data/examples/restful/webspicy/todo/getTodos.yml +0 -36
  107. data/examples/restful/webspicy/todo/options.yml +0 -32
  108. data/examples/restful/webspicy/todo/patchTodo.yml +0 -66
  109. data/examples/restful/webspicy/todo/postCsv.yml +0 -43
  110. data/examples/restful/webspicy/todo/postFile.yml +0 -40
  111. data/examples/restful/webspicy/todo/postTodos.yml +0 -51
  112. data/examples/restful/webspicy/todo/putTodo.yml +0 -65
  113. data/examples/restful/webspicy/todo/todos.csv +0 -4
  114. data/examples/single_spec/spec.yml +0 -59
  115. data/examples/website/config.rb +0 -2
  116. data/examples/website/schema.fio +0 -1
  117. data/examples/website/specification/get-http.yml +0 -30
  118. data/examples/website/specification/get-https.yml +0 -30
  119. data/lib/webspicy/checker.rb +0 -25
  120. data/lib/webspicy/mocker.rb +0 -88
  121. data/lib/webspicy/openapi/generator.rb +0 -127
  122. data/lib/webspicy/tester/rspec_asserter.rb +0 -108
  123. data/lib/webspicy/tester/rspec_matchers.rb +0 -104
  124. data/spec/unit/mocker/test_mocker.rb +0 -32
  125. data/spec/unit/openapi/test_generator.rb +0 -28
@@ -0,0 +1,142 @@
1
+ module Webspicy
2
+ class Tester
3
+ class Result
4
+ extend Forwardable
5
+
6
+ def initialize(tester)
7
+ @tester = tester
8
+ @scope = tester.scope
9
+ @client = tester.client
10
+ @specification = tester.specification
11
+ @service = tester.service
12
+ @test_case = tester.test_case
13
+ @invocation = tester.invocation
14
+ @assertions = []
15
+ @failures = []
16
+ @errors = []
17
+ if @invocation
18
+ check!
19
+ else
20
+ @errors << [InvocationSuceeded.new(self), tester.invocation_error]
21
+ end
22
+ end
23
+ attr_reader :tester, :scope, :client
24
+ attr_reader :specification, :service, :test_case, :invocation
25
+ attr_reader :assertions, :failures, :errors
26
+
27
+ def_delegators :@tester, *[
28
+ :config,
29
+ :reporter
30
+ ]
31
+
32
+ def self.from(tester)
33
+ new(tester)
34
+ end
35
+
36
+ def success?
37
+ failures.empty? && errors.empty?
38
+ end
39
+
40
+ def failure?
41
+ errors.empty? && !failures.empty?
42
+ end
43
+
44
+ def error?
45
+ !errors.empty?
46
+ end
47
+
48
+ def assertions_count
49
+ assertions.size
50
+ end
51
+
52
+ def failures_count
53
+ failures.size
54
+ end
55
+
56
+ def errors_count
57
+ errors.size
58
+ end
59
+
60
+ private
61
+
62
+ def check!
63
+ check_response!
64
+ check_output! if success? && test_case.example?
65
+ check_error! if success? && test_case.counterexample?
66
+ check_assertions! if success?
67
+ check_postconditions! if success? && test_case.example?
68
+ check_errconditions! if success? && test_case.counterexample?
69
+ end
70
+
71
+ private
72
+
73
+ def check_response!
74
+ check_one! Result::ResponseStatusMet
75
+ if ect = test_case.expected_content_type
76
+ check_one! Result::ResponseHeaderMet.new(self, "Content-Type", ect, :start_with)
77
+ end
78
+ test_case.expected_headers.each_pair do |k,v|
79
+ check_one! Result::ResponseHeaderMet.new(self, k, v)
80
+ end
81
+ end
82
+
83
+ def check_output!
84
+ check_one! Result::OutputSchemaMet
85
+ end
86
+
87
+ def check_error!
88
+ check_one! Result::ErrorSchemaMet
89
+ end
90
+
91
+ def check_assertions!
92
+ test_case.assert.each do |a|
93
+ check_one! Result::AssertMet.new(self, a)
94
+ end
95
+ end
96
+
97
+ def check_postconditions!
98
+ service.postconditions.each do |c|
99
+ check_one! Result::PostconditionMet.new(self, c.bind(tester))
100
+ end
101
+ end
102
+
103
+ def check_errconditions!
104
+ service.errconditions.each do |c|
105
+ check_one! Result::ErrconditionMet.new(self, c.bind(tester))
106
+ end
107
+ end
108
+
109
+ def check_one!(check)
110
+ if check.is_a?(Class)
111
+ check_one!(check.new(self))
112
+ else
113
+ return unless check.must?
114
+ begin
115
+ check.call
116
+ reporter.check_success(check)
117
+ rescue *PASSTHROUGH_EXCEPTIONS
118
+ raise
119
+ rescue Failure => e
120
+ self.failures << [check, e]
121
+ reporter.check_failure(check, e)
122
+ rescue Exception => e
123
+ self.errors << [check, e]
124
+ reporter.check_error(check, e)
125
+ ensure
126
+ self.assertions << check
127
+ end
128
+ end
129
+ end
130
+
131
+ end # class Result
132
+ end # class Tester
133
+ end # module Webspicy
134
+ require_relative "result/check"
135
+ require_relative "result/invocation_succeeded"
136
+ require_relative "result/response_status_met"
137
+ require_relative "result/response_header_met"
138
+ require_relative "result/output_schema_met"
139
+ require_relative "result/error_schema_met"
140
+ require_relative "result/assert_met"
141
+ require_relative "result/postcondition_met"
142
+ require_relative "result/errcondition_met"
@@ -0,0 +1,29 @@
1
+ module Webspicy
2
+ class Tester
3
+ class Result
4
+ class AssertMet < Check
5
+
6
+ def initialize(result, assertion)
7
+ super(result)
8
+ @assertion = assertion
9
+ end
10
+ attr_reader :assertion
11
+
12
+ def behavior
13
+ "Assert #{assertion}"
14
+ end
15
+
16
+ def must?
17
+ true
18
+ end
19
+
20
+ def call
21
+ on = invocation.dressed_body
22
+ asserter = Tester::Asserter.new(on)
23
+ asserter.instance_eval(assertion)
24
+ end
25
+
26
+ end # class AssertMet
27
+ end # class Result
28
+ end # class Tester
29
+ end # module error
@@ -0,0 +1,33 @@
1
+ module Webspicy
2
+ class Tester
3
+ class Result
4
+ class Check
5
+ extend Forwardable
6
+
7
+ def initialize(result)
8
+ @result = result
9
+ end
10
+ attr_reader :result
11
+
12
+ def_delegators :@result, *[
13
+ :config,
14
+ :scope,
15
+ :client,
16
+ :specification,
17
+ :service,
18
+ :test_case,
19
+ :invocation
20
+ ]
21
+
22
+ def_delegators :invocation, *[
23
+ :response
24
+ ]
25
+
26
+ def _!(msg)
27
+ raise Failure, msg
28
+ end
29
+
30
+ end # class Check
31
+ end # class Result
32
+ end # class Tester
33
+ end # module Webspicy
@@ -0,0 +1,29 @@
1
+ module Webspicy
2
+ class Tester
3
+ class Result
4
+ class ErrconditionMet < Check
5
+
6
+ def initialize(result, post)
7
+ super(result)
8
+ @post = post
9
+ end
10
+ attr_reader :post
11
+
12
+ def behavior
13
+ post.to_s
14
+ end
15
+
16
+ def must?
17
+ true
18
+ end
19
+
20
+ def call
21
+ if err = post.check!
22
+ _! err
23
+ end
24
+ end
25
+
26
+ end # class ErrconditionMet
27
+ end # class Result
28
+ end # class Tester
29
+ end # module Webspicy
@@ -0,0 +1,25 @@
1
+ module Webspicy
2
+ class Tester
3
+ class Result
4
+ class ErrorSchemaMet < Check
5
+
6
+ def behavior
7
+ "Error data meets the expected error schema"
8
+ end
9
+
10
+ def must?
11
+ !test_case.is_expected_status?(204)
12
+ end
13
+
14
+ def call
15
+ return unless invocation.is_structured_output?
16
+ output = invocation.loaded_body
17
+ service.error_schema.dress(output)
18
+ rescue Finitio::TypeError => ex
19
+ _! "Invalid error: #{ex.message}"
20
+ end
21
+
22
+ end # class ErrorSchemaMet
23
+ end # class Result
24
+ end # class Tester
25
+ end # module error
@@ -0,0 +1,13 @@
1
+ module Webspicy
2
+ class Tester
3
+ class Result
4
+ class InvocationSuceeded < Check
5
+
6
+ def initialize(result)
7
+ super(result)
8
+ end
9
+
10
+ end # class InvocationSuceeded
11
+ end # class Result
12
+ end # class Tester
13
+ end # module Webspicy
@@ -0,0 +1,25 @@
1
+ module Webspicy
2
+ class Tester
3
+ class Result
4
+ class OutputSchemaMet < Check
5
+
6
+ def behavior
7
+ "Its output meets the expected data schema"
8
+ end
9
+
10
+ def must?
11
+ !test_case.is_expected_status?(204)
12
+ end
13
+
14
+ def call
15
+ return unless invocation.is_structured_output?
16
+ output = invocation.loaded_body
17
+ service.output_schema.dress(output)
18
+ rescue Finitio::TypeError => ex
19
+ _! "Invalid output: #{ex.message}"
20
+ end
21
+
22
+ end # class OutputSchemaMet
23
+ end # class Result
24
+ end # class Tester
25
+ end # module Webspicy
@@ -0,0 +1,29 @@
1
+ module Webspicy
2
+ class Tester
3
+ class Result
4
+ class PostconditionMet < Check
5
+
6
+ def initialize(result, post)
7
+ super(result)
8
+ @post = post
9
+ end
10
+ attr_reader :post
11
+
12
+ def behavior
13
+ post.to_s
14
+ end
15
+
16
+ def must?
17
+ true
18
+ end
19
+
20
+ def call
21
+ if err = post.check!
22
+ _! err
23
+ end
24
+ end
25
+
26
+ end # class PostconditionMet
27
+ end # class Result
28
+ end # class Tester
29
+ end # module Webspicy
@@ -0,0 +1,43 @@
1
+ module Webspicy
2
+ class Tester
3
+ class Result
4
+ class ResponseHeaderMet < Check
5
+
6
+ def initialize(result, header, expected, strategy = :eq)
7
+ unless [:eq, :start_with].include?(strategy)
8
+ raise ArgumentError, "Invalid strategy `#{strategy.inspect}`"
9
+ end
10
+ super(result)
11
+ @header = header
12
+ @expected = expected
13
+ @strategy = strategy
14
+ end
15
+ attr_reader :header, :expected, :strategy
16
+
17
+ def behavior
18
+ "It has a `#{header}: #{expected}` response header"
19
+ end
20
+
21
+ def must?
22
+ true
23
+ end
24
+
25
+ def call
26
+ got = response.headers[header]
27
+ if got.nil?
28
+ _! "Expected response header `#{header}` to be set"
29
+ else
30
+ msg = "Expected response header `#{header}` to be `#{expected}`, got `#{got}`"
31
+ case strategy
32
+ when :eq
33
+ _!(msg) unless expected == got
34
+ when :start_with
35
+ _!(msg) unless got.start_with?(expected)
36
+ end
37
+ end
38
+ end
39
+
40
+ end # class ResponseHeaderMet
41
+ end # class Result
42
+ end # class Tester
43
+ end # module Webspicy
@@ -0,0 +1,25 @@
1
+ module Webspicy
2
+ class Tester
3
+ class Result
4
+ class ResponseStatusMet < Check
5
+
6
+ def behavior
7
+ "It has a %d response status" % [ test_case.expected_status ]
8
+ end
9
+
10
+ def must?
11
+ test_case.has_expected_status?
12
+ end
13
+
14
+ def call
15
+ actual = response.status
16
+ expected = test_case.expected_status
17
+ unless expected === actual
18
+ _!("Expected response status to be #{expected}, got #{actual}")
19
+ end
20
+ end
21
+
22
+ end # class ResponseStatusMet
23
+ end # class Result
24
+ end # class Tester
25
+ end # module Webspicy
@@ -1,8 +1,8 @@
1
1
  module Webspicy
2
2
  module Version
3
3
  MAJOR = 0
4
- MINOR = 16
5
- TINY = 3
4
+ MINOR = 20
5
+ TINY = 1
6
6
  end
7
7
  VERSION = "#{Version::MAJOR}.#{Version::MINOR}.#{Version::TINY}"
8
8
  end
@@ -0,0 +1,4 @@
1
+ require_relative 'web/client'
2
+ require_relative 'web/invocation'
3
+ require_relative 'web/mocker'
4
+ require_relative 'web/openapi'
@@ -0,0 +1,15 @@
1
+ module Webspicy
2
+ module Web
3
+ class Client < Tester::Client
4
+
5
+ def call(test_case)
6
+ response = _call(test_case)
7
+ Invocation.new(test_case, response, self)
8
+ end
9
+
10
+ end # class Client
11
+ end # module Web
12
+ end # module Webspicy
13
+ require_relative 'client/support'
14
+ require_relative 'client/http_client'
15
+ require_relative 'client/rack_test_client'
@@ -1,5 +1,5 @@
1
1
  module Webspicy
2
- class Tester
2
+ module Web
3
3
  class HttpClient < Client
4
4
 
5
5
  class ::HTTP::Request
@@ -19,7 +19,7 @@ module Webspicy
19
19
  end
20
20
  attr_reader :api
21
21
 
22
- def call(test_case)
22
+ def _call(test_case)
23
23
  service, specification = test_case.service, test_case.specification
24
24
 
25
25
  # Instantiate the parameters
@@ -43,11 +43,10 @@ module Webspicy
43
43
  class Api
44
44
  include Client::Support
45
45
 
46
- attr_reader :last_response
47
-
48
46
  def initialize(scope)
49
47
  @scope = scope
50
48
  end
49
+ attr_reader :last_response
51
50
 
52
51
  def config
53
52
  @scope.config
@@ -57,7 +56,8 @@ module Webspicy
57
56
  info_request("OPTIONS", url, params, headers, body)
58
57
 
59
58
  params = querystring_params(params)
60
- @last_response = HTTP[headers || {}].options(url, params: params)
59
+ http_opts = http_options(params: params)
60
+ @last_response = HTTP[headers || {}].options(url, http_opts)
61
61
 
62
62
  debug_response(@last_response)
63
63
 
@@ -68,7 +68,8 @@ module Webspicy
68
68
  info_request("GET", url, params, headers, body)
69
69
 
70
70
  params = querystring_params(params)
71
- @last_response = HTTP[headers || {}].get(url, params: params)
71
+ http_opts = http_options(params: params)
72
+ @last_response = HTTP[headers || {}].get(url, http_opts)
72
73
 
73
74
  debug_response(@last_response)
74
75
 
@@ -85,18 +86,21 @@ module Webspicy
85
86
  case body
86
87
  when NilClass
87
88
  headers['Content-Type'] ||= 'application/json'
88
- @last_response = HTTP[headers].post(url, body: params.to_json)
89
+ http_opts = http_options(body: params.to_json)
90
+ @last_response = HTTP[headers].post(url, http_opts)
89
91
  when FileUpload
90
92
  file = HTTP::FormData::File.new(body.path.to_s, {
91
93
  content_type: body.content_type,
92
94
  filename: body.path.basename.to_s
93
95
  })
94
- @last_response = HTTP[headers].post(url, form: {
96
+ http_opts = http_options(form: {
95
97
  body.param_name.to_sym => file
96
98
  })
99
+ @last_response = HTTP[headers].post(url, http_opts)
97
100
  else
98
101
  headers['Content-Type'] ||= 'application/json'
99
- @last_response = HTTP[headers].post(url, body: body)
102
+ http_opts = http_options(body: body)
103
+ @last_response = HTTP[headers].post(url, http_opts)
100
104
  end
101
105
 
102
106
  debug_response(@last_response)
@@ -109,7 +113,8 @@ module Webspicy
109
113
 
110
114
  headers ||= {}
111
115
  headers['Content-Type'] ||= 'application/json'
112
- @last_response = HTTP[headers].patch(url, body: params.to_json)
116
+ http_opts = http_options(body: params.to_json)
117
+ @last_response = HTTP[headers].patch(url, http_opts)
113
118
 
114
119
  debug_response(@last_response)
115
120
 
@@ -121,7 +126,8 @@ module Webspicy
121
126
 
122
127
  headers ||= {}
123
128
  headers['Content-Type'] ||= 'application/json'
124
- @last_response = HTTP[headers].put(url, body: params.to_json)
129
+ http_opts = http_options(body: params.to_json)
130
+ @last_response = HTTP[headers].put(url, http_opts)
125
131
 
126
132
  debug_response(@last_response)
127
133
 
@@ -131,7 +137,8 @@ module Webspicy
131
137
  def post_form(url, params = {}, headers = nil, body = nil)
132
138
  info_request("POST", url, params, headers, body)
133
139
 
134
- @last_response = HTTP[headers || {}].post(url, form: params)
140
+ http_opts = http_options(form: params)
141
+ @last_response = HTTP[headers || {}].post(url, http_opts)
135
142
 
136
143
  debug_response(@last_response)
137
144
 
@@ -141,14 +148,27 @@ module Webspicy
141
148
  def delete(url, params = {}, headers = nil, body = nil)
142
149
  info_request("DELETE", url, params, headers, body)
143
150
 
144
- @last_response = HTTP[headers || {}].delete(url, body: params.to_json)
151
+ http_opts = http_options(body: params.to_json)
152
+ @last_response = HTTP[headers || {}].delete(url, http_opts)
145
153
 
146
154
  debug_response(@last_response)
147
155
 
148
156
  @last_response
149
157
  end
158
+
159
+ def http_options(extra)
160
+ if config.insecure
161
+ ctx = OpenSSL::SSL::SSLContext.new
162
+ ctx.verify_mode = OpenSSL::SSL::VERIFY_NONE
163
+ {
164
+ :ssl_context => ctx
165
+ }.merge(extra)
166
+ else
167
+ extra
168
+ end
169
+ end
150
170
  end # class Api
151
171
 
152
172
  end # class HttpClient
153
- end # class Tester
173
+ end # module Web
154
174
  end # module Webspicy