rack-spec 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +11 -1
- data/bin/specup +22 -0
- data/lib/rack/spec.rb +1 -0
- data/lib/rack/spec/version.rb +1 -1
- data/rack-spec.gemspec +1 -0
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d1e47b36ab6a2c071d1bd5f4f67cf0fef54d8c8
|
4
|
+
data.tar.gz: add1c0cf066275c0545b8d5a02d6ea7488f05960
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ef85788ef1f068ab4175b5935687c291cebebec416f7edcde35a0bb4a9e78c8d24b0fd937d13a45873e8f014277b4cebda436068f19f22505d0c4cb345933ac
|
7
|
+
data.tar.gz: adc990f29bdaaacbc531093651bdd0cc990a6230c83fdb72d0f2f4fa4fbaccec7697f87940046e2f7086ac50036aac55fd16ab7e7ac67427b757b395aa8b168d
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -67,7 +67,7 @@ $ curl http://localhost:9292/apps
|
|
67
67
|
```
|
68
68
|
|
69
69
|
### Rack::Spec::Mock
|
70
|
-
Generates dummy response
|
70
|
+
Generates dummy response from JSON schema.
|
71
71
|
|
72
72
|
```sh
|
73
73
|
$ curl http://localhost:9292/apps/1
|
@@ -97,11 +97,21 @@ $ curl http://localhost:9292/recipes
|
|
97
97
|
}
|
98
98
|
```
|
99
99
|
|
100
|
+
Note: `specup` executable command is bundled to rackup dummy API server.
|
101
|
+
|
102
|
+
```sh
|
103
|
+
$ specup schema.json
|
104
|
+
[2014-06-06 23:01:35] INFO WEBrick 1.3.1
|
105
|
+
[2014-06-06 23:01:35] INFO ruby 2.0.0 (2013-06-27) [x86_64-darwin12.5.0]
|
106
|
+
[2014-06-06 23:01:35] INFO WEBrick::HTTPServer#start: pid=24303 port=8080
|
107
|
+
```
|
108
|
+
|
100
109
|
### Rack::Spec::ErrorHandler
|
101
110
|
Returns appropriate error response including following properties when RequestValidation raises error.
|
102
111
|
|
103
112
|
* message: Human readable message
|
104
113
|
* id: Error type identifier listed below
|
114
|
+
* example_not_found
|
105
115
|
* invalid_content_type
|
106
116
|
* invalid_json
|
107
117
|
* invalid_parameter
|
data/bin/specup
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
|
3
|
+
require "rack"
|
4
|
+
require "rack/spec"
|
5
|
+
|
6
|
+
begin
|
7
|
+
path = ARGV.shift or raise
|
8
|
+
str = File.read(path)
|
9
|
+
rescue
|
10
|
+
puts "Usage: #{$0} schema.json [rack options]"
|
11
|
+
exit
|
12
|
+
end
|
13
|
+
|
14
|
+
schema = JSON.parse(str)
|
15
|
+
app = Rack::Builder.new do
|
16
|
+
use Rack::Spec::ErrorHandler
|
17
|
+
use Rack::Spec::Mock, schema: schema
|
18
|
+
run ->(env) { [404, {}, ["Not found"]] }
|
19
|
+
end
|
20
|
+
|
21
|
+
options = Rack::Server::Options.new.parse!(ARGV).merge(app: app)
|
22
|
+
Rack::Server.start(options)
|
data/lib/rack/spec.rb
CHANGED
data/lib/rack/spec/version.rb
CHANGED
data/rack-spec.gemspec
CHANGED
@@ -19,6 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
|
20
20
|
spec.add_dependency "json_schema"
|
21
21
|
spec.add_dependency "multi_json"
|
22
|
+
spec.add_dependency "rack"
|
22
23
|
spec.add_development_dependency "bundler", "~> 1.5"
|
23
24
|
spec.add_development_dependency "pry"
|
24
25
|
spec.add_development_dependency "rack-test"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-spec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryo Nakamura
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rack
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: bundler
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -139,7 +153,8 @@ dependencies:
|
|
139
153
|
description:
|
140
154
|
email:
|
141
155
|
- r7kamura@gmail.com
|
142
|
-
executables:
|
156
|
+
executables:
|
157
|
+
- specup
|
143
158
|
extensions: []
|
144
159
|
extra_rdoc_files: []
|
145
160
|
files:
|
@@ -149,6 +164,7 @@ files:
|
|
149
164
|
- LICENSE.txt
|
150
165
|
- README.md
|
151
166
|
- Rakefile
|
167
|
+
- bin/specup
|
152
168
|
- lib/rack-spec.rb
|
153
169
|
- lib/rack/spec.rb
|
154
170
|
- lib/rack/spec/base_request_handler.rb
|