rspec-document_requests 0.1.1 → 1.0.0

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: f6b543a04a752abc10e26ff44cbafc7c123d2669
4
- data.tar.gz: 171d4df08329b57b1459ddca59e3e39411a02509
3
+ metadata.gz: bc000344bde08e36293ce8a3baf060288b0302d5
4
+ data.tar.gz: 39f6f21bca22ecb1fd529b632efee84b6b5e0966
5
5
  SHA512:
6
- metadata.gz: 564517fff40607173e540b7452c6d7ba359500ace2d09f377c355d0dc07371e187683cced4b94a4d3d8c842b9a80031964567dd1334ac4bff52b89c385c56180
7
- data.tar.gz: ce6f282549317f61d99d049def1dd73af432610aea25eabaa72f8ea2129fb78bcad8155fc150bb32171473c4daeb1b1c7b60e3c463848b8c17f040d080963e83
6
+ metadata.gz: c77b38455da8936b95352f125609253061cf44dda9685bfd18d4b4dbd44979a6e466604f365cd2ef38b88bc9e5d4e4a741ffd6c9f45d7b69e4bb301878c3deae
7
+ data.tar.gz: 36accade2ab7448c6de009f1c6ad3be70fb1e1a1367fda065fe94afab04573dc46589fc32a9197d59913fb8e5ec687606047b811dfc3bdf61aa267786e86ce75
data/README.md CHANGED
@@ -102,8 +102,8 @@ RSpec.describe "Session resource", type: :request, doc: true do
102
102
  before do
103
103
  explain do # No request explanation
104
104
  request do
105
- parameter 'session[username]', "The username", required: true, type: :string
106
- parameter 'session[password]', required: true, type: :string # No explanation
105
+ parameter 'session[username]', "The username", required: true, type: 'string'
106
+ parameter 'session[password]', required: true, type: 'string' # No explanation
107
107
  header 'Content-Type', ... # you get the point
108
108
  end
109
109
  response do
@@ -30,7 +30,7 @@ module RSpec
30
30
  end
31
31
 
32
32
  def explain(message = nil, &block)
33
- document_request_explanation.message = message
33
+ document_request_explanation.message = message if message
34
34
  document_request_explanation.instance_eval(&block) if block_given?
35
35
  end
36
36
 
@@ -26,13 +26,13 @@ module RSpec
26
26
  end
27
27
 
28
28
  def request(&block)
29
- return @request if not block_given?
30
- @request.instance_eval(&block)
29
+ @request.instance_eval(&block) if block_given?
30
+ @request
31
31
  end
32
32
 
33
33
  def response(&block)
34
- return @request if not block_given?
35
- @response.instance_eval(&block)
34
+ @response.instance_eval(&block) if block_given?
35
+ @response
36
36
  end
37
37
  end
38
38
  end
@@ -59,7 +59,7 @@ module RSpec
59
59
 
60
60
  def process_request_parameters(parameters, prefix: nil)
61
61
  @request_parameters = {}
62
- process_parameters(request_parameters, @request_parameters, explanation: @explanation.request.parameters)
62
+ process_parameters(parameters, @request_parameters, explanation: @explanation.request.parameters)
63
63
  end
64
64
 
65
65
  def process_request_headers(headers)
@@ -1,5 +1,5 @@
1
1
  module RSpec
2
2
  module DocumentRequests
3
- VERSION = "0.1.1"
3
+ VERSION = "1.0.0"
4
4
  end
5
5
  end
@@ -30,7 +30,7 @@ module RSpec
30
30
 
31
31
  def request(request, missing_levels:)
32
32
  @file.write <<FILE
33
- ### Request #{"(#{request.explanation.message})" if request.explanation.message}
33
+ ### Request#{" (#{request.explanation.message})" if request.explanation.message}
34
34
 
35
35
  #{request.method} #{request.path}
36
36
 
@@ -38,7 +38,6 @@ FILE
38
38
 
39
39
  if request.request_parameters.any?
40
40
  @file.write <<FILE
41
-
42
41
  #### Parameters
43
42
 
44
43
  FILE
@@ -47,7 +46,6 @@ FILE
47
46
 
48
47
  if request.request_headers.any?
49
48
  @file.write <<FILE
50
-
51
49
  #### Headers
52
50
 
53
51
  FILE
@@ -55,13 +53,16 @@ FILE
55
53
  end
56
54
 
57
55
  @file.write <<FILE
58
-
59
56
  ### Response
60
57
 
61
58
  #### Status
62
59
 
63
60
  #{request.response.status} #{request.response.status_message}
64
61
 
62
+ #### Content-Type
63
+
64
+ #{request.response.content_type}
65
+
65
66
  FILE
66
67
 
67
68
  if request.response_parameters and request.response_parameters.any?
@@ -73,7 +74,6 @@ FILE
73
74
  end
74
75
 
75
76
  @file.write <<FILE
76
-
77
77
  #### Body
78
78
 
79
79
  #{request.response.body}
@@ -82,7 +82,6 @@ FILE
82
82
 
83
83
  if request.response_headers.any?
84
84
  @file.write <<FILE
85
-
86
85
  #### Headers
87
86
 
88
87
  FILE
@@ -94,13 +93,14 @@ FILE
94
93
 
95
94
  def parameters_table(parameters)
96
95
  @file.write <<FILE
97
- | Name | Type | Required? | Value | Explanation |
98
- |------|------|-----------|-------|-------------|
96
+ | Name | Type | Required? | Value | |
97
+ |------|------|-----------|-------|---|
99
98
  FILE
100
99
 
101
100
  parameters.sort.each do |name, parameter|
102
101
  @file.puts "| #{name} | #{parameter.type} | #{"Required" if parameter.required} | #{parameter.value} | #{parameter.message} |"
103
102
  end
103
+ @file.puts
104
104
  end
105
105
  end
106
106
  end
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: 0.1.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oded Niv