goodall 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -1
- data/changelog.txt +7 -0
- data/lib/goodall.rb +7 -2
- data/lib/goodall/version.rb +1 -1
- data/spec/lib/goodall_spec.rb +11 -0
- metadata +3 -2
data/README.md
CHANGED
@@ -320,11 +320,12 @@ Document a request.
|
|
320
320
|
* :path - a string of the path (URL/URI) of the request
|
321
321
|
* :payload - the parameters sent, e.g. post body. Usually a hash. For things with no payload, like a GET, it can be nil.
|
322
322
|
|
323
|
-
#### Goodalldocument_response(payload)
|
323
|
+
#### Goodalldocument_response(payload, status=nil)
|
324
324
|
|
325
325
|
Document a response.
|
326
326
|
|
327
327
|
* :payload - the data returned from the request, e.g. response.body. "payload" will be run through the current handler and be pretty-printed to the output file.
|
328
|
+
* :status - the http status of the response. Can be a string, symbol or integer. (e.g. 404, 500, :ok, "success", etc)
|
328
329
|
|
329
330
|
## Contributing
|
330
331
|
|
data/changelog.txt
ADDED
data/lib/goodall.rb
CHANGED
@@ -74,14 +74,19 @@ class Goodall
|
|
74
74
|
# Document a response.
|
75
75
|
#
|
76
76
|
# * +:payload - the data returned from the request, e.g. response.body. `payload` will be run through the current handler and be pretty-printed to the output file.
|
77
|
-
def self.document_response(payload)
|
77
|
+
def self.document_response(payload, status=nil)
|
78
78
|
return unless enabled?
|
79
79
|
|
80
80
|
if payload
|
81
81
|
payload = current_handler.parse_payload(payload)
|
82
82
|
end
|
83
83
|
|
84
|
-
str =
|
84
|
+
str = if status
|
85
|
+
"RESPONSE: #{status}"
|
86
|
+
else
|
87
|
+
"RESPONSE:"
|
88
|
+
end
|
89
|
+
str << "\n#{payload}\n"
|
85
90
|
|
86
91
|
writer.write(str)
|
87
92
|
end
|
data/lib/goodall/version.rb
CHANGED
data/spec/lib/goodall_spec.rb
CHANGED
@@ -155,11 +155,22 @@ describe Goodall do
|
|
155
155
|
"RESPONSE:\n#{formatted_payload}\n"
|
156
156
|
end
|
157
157
|
|
158
|
+
let(:expected_write_with_status) do
|
159
|
+
"RESPONSE: ok\n#{formatted_payload}\n"
|
160
|
+
end
|
161
|
+
|
162
|
+
|
158
163
|
it "must send a formatted response to the writer" do
|
159
164
|
expect(mock_writer).to receive(:write).with(expected_write)
|
160
165
|
|
161
166
|
klass.document_response(mock_payload)
|
162
167
|
end
|
168
|
+
|
169
|
+
it "must optionally accept a status code argument" do
|
170
|
+
expect(mock_writer).to receive(:write).with(expected_write_with_status)
|
171
|
+
|
172
|
+
klass.document_response(mock_payload, :ok)
|
173
|
+
end
|
163
174
|
end
|
164
175
|
|
165
176
|
context "Goodall is not enabled" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: goodall
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-09-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: multi_json
|
@@ -108,6 +108,7 @@ files:
|
|
108
108
|
- LICENSE.txt
|
109
109
|
- README.md
|
110
110
|
- Rakefile
|
111
|
+
- changelog.txt
|
111
112
|
- goodall.gemspec
|
112
113
|
- lib/goodall.rb
|
113
114
|
- lib/goodall/command_line_enable.rb
|