rspec-document_requests 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bc000344bde08e36293ce8a3baf060288b0302d5
4
- data.tar.gz: 39f6f21bca22ecb1fd529b632efee84b6b5e0966
3
+ metadata.gz: 03e9589029b92f3ada8618b326ff040977a76133
4
+ data.tar.gz: e9716f03981863fd054f918b3a44ef1c81aec23d
5
5
  SHA512:
6
- metadata.gz: c77b38455da8936b95352f125609253061cf44dda9685bfd18d4b4dbd44979a6e466604f365cd2ef38b88bc9e5d4e4a741ffd6c9f45d7b69e4bb301878c3deae
7
- data.tar.gz: 36accade2ab7448c6de009f1c6ad3be70fb1e1a1367fda065fe94afab04573dc46589fc32a9197d59913fb8e5ec687606047b811dfc3bdf61aa267786e86ce75
6
+ metadata.gz: eb10351bf8ef26ecd1a8553e270391dfcde8d0a057331fefcedcce769cd52b03e4e5dc605978886225848427c2e57195b2cf8521a69293413c0a5484faa1e8eb
7
+ data.tar.gz: c37df01da4e7339431a5c5431a1cd65fc1a4d76b8a8ee0c8bdd5aa7d6b8511a80490c09dcd7443ee9f8a9f3cd8ac4515fdda9d4cacf8db78b360be61fb5e264c
@@ -23,7 +23,6 @@ module RSpec
23
23
  )
24
24
  end
25
25
  @document_request_explanation = Explanation.new
26
- DSL.currently_documented_example = nil
27
26
 
28
27
  result
29
28
  end
@@ -57,6 +56,7 @@ RSpec.configure do |config|
57
56
 
58
57
  config.after(:suite) { RSpec::DocumentRequests::Builder.new }
59
58
  config.before { |ex| RSpec::DocumentRequests::DSL.currently_documented_example = ex }
59
+ config.after { |ex| RSpec::DocumentRequests::DSL.currently_documented_example = nil }
60
60
  end
61
61
 
62
62
  config.include RSpec::DocumentRequests::DSL, doc: true
@@ -12,7 +12,7 @@ module RSpec
12
12
  end
13
13
 
14
14
  attr_reader :explanation, :example, :method, :path
15
- attr_reader :request_parameters, :request_headers
15
+ attr_reader :request_body, :request_parameters, :request_headers
16
16
  attr_reader :response, :parsed_response, :response_parameters, :response_headers
17
17
  def initialize(explanation:, example:, method:, path:, request_parameters:, request_headers:, response:)
18
18
  @explanation = explanation
@@ -21,8 +21,12 @@ module RSpec
21
21
  @path = path
22
22
  @response = response
23
23
 
24
- process_request_parameters(request_parameters)
25
- process_request_headers(request_headers)
24
+ if request_parameters.is_a?(Hash)
25
+ process_request_parameters(request_parameters)
26
+ else
27
+ @request_body = request_parameters
28
+ end
29
+ process_request_headers(request_headers || {})
26
30
  process_response_parameters
27
31
  process_response_headers
28
32
  end
@@ -1,5 +1,5 @@
1
1
  module RSpec
2
2
  module DocumentRequests
3
- VERSION = "1.0.0"
3
+ VERSION = "1.0.1"
4
4
  end
5
5
  end
@@ -36,12 +36,19 @@ module RSpec
36
36
 
37
37
  FILE
38
38
 
39
- if request.request_parameters.any?
39
+ if request.request_parameters and request.request_parameters.any?
40
40
  @file.write <<FILE
41
41
  #### Parameters
42
42
 
43
43
  FILE
44
44
  parameters_table(request.request_parameters)
45
+ elsif request.request_body
46
+ @file.write <<FILE
47
+ #### Body
48
+
49
+ #{request.request_body}
50
+
51
+ FILE
45
52
  end
46
53
 
47
54
  if request.request_headers.any?
@@ -97,7 +104,7 @@ FILE
97
104
  |------|------|-----------|-------|---|
98
105
  FILE
99
106
 
100
- parameters.sort.each do |name, parameter|
107
+ parameters.each do |name, parameter|
101
108
  @file.puts "| #{name} | #{parameter.type} | #{"Required" if parameter.required} | #{parameter.value} | #{parameter.message} |"
102
109
  end
103
110
  @file.puts
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-document_requests
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oded Niv