dredd-rack 0.8.1 → 0.8.2

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: 4278e4bc0587b5ed694817be28ab765e3460f7c1
4
- data.tar.gz: ed36921e13d44511dd2e07a7f42fffae50cb5e1c
3
+ metadata.gz: 18df818e221d674ff9790acfbccc8cb2324fcab3
4
+ data.tar.gz: 6631de46a43a5dc77506c7b42de90d7ad383142e
5
5
  SHA512:
6
- metadata.gz: d05bc71fd49b22d448da2051089c9dd285365264c6b208590d5d19468c05777dd2a2ad6396e57601546b5c5a3918d5f84c11689d7241e1b8f27f1da33bbf6318
7
- data.tar.gz: 0b2c37756677d31608eaa57a18dd0b3c6ad45dc612ee76fcf9402111cc2e88d3acd0169257e58c52d8be71cea338ece227996c3422cc0775c65f242e5be30665
6
+ metadata.gz: cc4009ccc1e08a1ae033edb244ec1a8db6e50dff78686ea96d249859a9a70ae3fd7225dfb460cbc757add66c77f0a6f7f15dd6eeb8a1a4f666edde24e3a70422
7
+ data.tar.gz: 6c940aef0d478e172e73455516944bff12b6de3a5001b674a12ac2238c782bff9df04d02bf9f1415036aca34f2de4816c7de4327f8466f2ed95c4b0328b0de0d
data/CHANGELOG.md CHANGED
@@ -3,6 +3,13 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  This project adheres to [Semantic Versioning](http://semver.org/).
5
5
 
6
+ ## [0.8.2] - 2016-06-08
7
+
8
+ ### Fixed
9
+
10
+ - Fix inaccurate counting of command arguments for local API
11
+ - Minor fix missing documentation for Dredd v1.0.8 options
12
+
6
13
  ## [0.8.1] - 2016-05-07
7
14
 
8
15
  ### Added
@@ -65,6 +72,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
65
72
  The original implementation of the Rake task was shared in this [gist][gist].
66
73
 
67
74
  [gist]: https://gist.github.com/gonzalo-bulnes/eec3f73cc7d6605add21
75
+ [0.8.2]: https://github.com/gonzalo-bulnes/dredd-rack/compare/v0.8.1...v0.8.2
68
76
  [0.8.1]: https://github.com/gonzalo-bulnes/dredd-rack/compare/v0.7.1...v0.8.1
69
77
  [0.8.0]: https://github.com/gonzalo-bulnes/dredd-rack/compare/v0.7.1...v0.8.0
70
78
  [0.7.1]: https://github.com/gonzalo-bulnes/dredd-rack/compare/v0.7.0...v0.7.1
data/README.md CHANGED
@@ -28,7 +28,7 @@ Add the gem to your `Gemfile`:
28
28
  ```ruby
29
29
  # Gemfile
30
30
 
31
- gem 'dredd-rack', '0.8.1' # see semver.org
31
+ gem 'dredd-rack', '0.8.2' # see semver.org
32
32
  ```
33
33
 
34
34
  Define which application Dredd::Rack must serve automatically:
data/doc/runner.md CHANGED
@@ -82,6 +82,15 @@ dredd = Dredd::Rack::Runner.new do |options|
82
82
 
83
83
  options.method('POST').method('PUT')
84
84
 
85
+ options.hooks_worker_timeout 5000
86
+ options.hooks_worker_connect_timeout 1500
87
+ options.hooks_worker_connect_retry 500
88
+ options.hooks_worker_after_connect_wait 100
89
+ options.hooks_worker_term_timeout 5000
90
+ options.hooks_worker_term_retry 500
91
+ options.hooks_worker_handler_host 'localhost'
92
+ options.hooks_worker_handler_port 61321
93
+
85
94
  options.dry_run! # no_dry_run!
86
95
  options.sandbox! # no_sandbox!
87
96
  options.names! # no_names!
@@ -117,7 +117,11 @@ module Dredd
117
117
  end
118
118
 
119
119
  def command_valid?
120
- command.has_at_least_two_arguments?
120
+ if api_remote?
121
+ command.has_at_least_two_arguments?
122
+ else
123
+ command.has_at_least_one_argument?
124
+ end
121
125
  end
122
126
 
123
127
  def start_server!
@@ -151,6 +155,34 @@ end
151
155
 
152
156
  class String
153
157
 
158
+ # Verify that a command has at least one argument (excluding options)
159
+ #
160
+ # Examples:
161
+ #
162
+ # "dredd doc/*.apib".valid? # => true
163
+ # "dredd doc/*.apib doc/*apib.md".valid? # => true
164
+ # "dredd doc/*.apib --level verbose".valid? # => true
165
+ # "dredd".valid? # => false
166
+ # "dredd --dry-run".valid? # => false
167
+ # "dredd --dry-run --level verbose".valid? # => false
168
+ #
169
+ # Known limitations:
170
+ #
171
+ # Does not support short flags. (e.g. using `-l` instead of `--level`).
172
+ # Requires options to be specified after the last argument.
173
+ #
174
+ # Note:
175
+ #
176
+ # The known limitations imply that there may be false negatives: this method
177
+ # can return false for commands that do have two arguments or more. But there
178
+ # should not be false positives: if the method returns true, then the command
179
+ # does have at least two arguments.
180
+ #
181
+ # Returns true if the command String has at least one arguments, false otherwise.
182
+ def has_at_least_one_argument?
183
+ split('--').first.split(' ').length >= 2
184
+ end
185
+
154
186
  # Verify that a command has at least two arguments (excluding options)
155
187
  #
156
188
  # Examples:
@@ -1,5 +1,5 @@
1
1
  module Dredd
2
2
  module Rack
3
- VERSION = '0.8.1'
3
+ VERSION = '0.8.2'
4
4
  end
5
5
  end
@@ -74,13 +74,33 @@ describe Dredd::Rack::Runner do
74
74
 
75
75
  describe '#command_valid?', private: true do
76
76
 
77
- context 'when the generated command has less than two arguments' do
77
+
78
+ context 'when the command has less than one argument' do
78
79
 
79
80
  it 'returns false' do
81
+ allow(subject).to receive_message_chain(:command, :has_at_least_one_argument?).and_return(false)
80
82
  allow(subject).to receive_message_chain(:command, :has_at_least_two_arguments?).and_return(false)
83
+
81
84
  expect(subject.send(:command_valid?)).not_to be_truthy
82
85
  end
83
86
  end
87
+
88
+ context 'when the API to test is remote' do
89
+
90
+ before(:each) do
91
+ allow(subject).to receive(:api_remote?).and_return(true)
92
+ end
93
+
94
+ context 'when the command has less than two arguments' do
95
+
96
+ it 'returns false' do
97
+ allow(subject).to receive_message_chain(:command, :has_at_least_one_argument?).and_return(true)
98
+ allow(subject).to receive_message_chain(:command, :has_at_least_two_arguments?).and_return(false)
99
+
100
+ expect(subject.send(:command_valid?)).not_to be_truthy
101
+ end
102
+ end
103
+ end
84
104
  end
85
105
 
86
106
  describe '#configure', public: true do
@@ -252,6 +272,10 @@ end
252
272
 
253
273
  describe String, public: true do
254
274
 
275
+ it 'responds to :has_at_least_one_argument?' do
276
+ expect(subject).to respond_to :has_at_least_one_argument?
277
+ end
278
+
255
279
  it 'responds to :has_at_least_two_arguments?' do
256
280
  expect(subject).to respond_to :has_at_least_two_arguments?
257
281
  end
@@ -260,6 +284,37 @@ describe String, public: true do
260
284
  expect(subject).to respond_to :quote!
261
285
  end
262
286
 
287
+ describe '#has_at_least_one_argument?' do
288
+
289
+ context 'when the String can be interpreted as a command with at least one argument' do
290
+ context 'returns true (reliable)' do
291
+
292
+ ['dredd doc/*.apib',
293
+ 'dredd doc/*.apib doc/*apib.md',
294
+ 'dredd doc/*.apib --level verbose'].each do |subject|
295
+
296
+ it "e.g. '#{subject}'" do
297
+ expect(subject.has_at_least_one_argument?).to be_truthy
298
+ end
299
+ end
300
+ end
301
+ end
302
+
303
+ context 'when the String can be interpreted as a command with no arguments' do
304
+ context 'returns false (unreliable)' do
305
+
306
+ ['dredd',
307
+ 'dredd --dry-run',
308
+ 'dredd --dry-run --level verbose'].each do |subject|
309
+
310
+ it "e.g. '#{subject}'" do
311
+ expect(subject.has_at_least_one_argument?).to be_falsey
312
+ end
313
+ end
314
+ end
315
+ end
316
+ end
317
+
263
318
  describe '#has_at_least_two_arguments?' do
264
319
 
265
320
  context 'when the String can be interpreted as a command with at least two arguments' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dredd-rack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gonzalo Bulnes Guilpain
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-07 00:00:00.000000000 Z
11
+ date: 2016-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capybara
@@ -130,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
130
130
  version: '0'
131
131
  requirements: []
132
132
  rubyforge_project:
133
- rubygems_version: 2.4.5
133
+ rubygems_version: 2.6.1
134
134
  signing_key:
135
135
  specification_version: 4
136
136
  summary: Convenient API blueprint testing with Apiary Dredd for Rack applications.