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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 87132891a38319e6296f71af99cfb46bb54d9041
4
- data.tar.gz: 2a9700230c057c9894140ffad108f90fb6a314b3
3
+ metadata.gz: 2d1e47b36ab6a2c071d1bd5f4f67cf0fef54d8c8
4
+ data.tar.gz: add1c0cf066275c0545b8d5a02d6ea7488f05960
5
5
  SHA512:
6
- metadata.gz: e7ce5b2e4e7385afbcfc7cd0b3cb2b83a5b8492d4e91d43d0ec4cf79714aca7c3aaffad2e239e22bf2bba68f626182b1510107c7c063cc29144c0e91238a3fb1
7
- data.tar.gz: 489751d27fb8458b88939c3b71e46ebcd89d48fbd7212f39bfc21de8e8e5f41b391020248f5a781e251a2fd847b849ea28a682b8af063ffe93329a00ebde2e06
6
+ metadata.gz: 9ef85788ef1f068ab4175b5935687c291cebebec416f7edcde35a0bb4a9e78c8d24b0fd937d13a45873e8f014277b4cebda436068f19f22505d0c4cb345933ac
7
+ data.tar.gz: adc990f29bdaaacbc531093651bdd0cc990a6230c83fdb72d0f2f4fa4fbaccec7697f87940046e2f7086ac50036aac55fd16ab7e7ac67427b757b395aa8b168d
@@ -1,3 +1,6 @@
1
+ ## 0.1.5
2
+ * Add `specup` executable
3
+
1
4
  ## 0.1.4
2
5
  * Add Rack::Spec::Mock
3
6
  * Prettify response JSON
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 by using example property in JSON schema.
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
@@ -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)
@@ -1,6 +1,7 @@
1
1
  require "json"
2
2
  require "json_schema"
3
3
  require "multi_json"
4
+ require "rack"
4
5
 
5
6
  require "rack/spec/base_request_handler"
6
7
  require "rack/spec/error"
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  module Spec
3
- VERSION = "0.1.4"
3
+ VERSION = "0.1.5"
4
4
  end
5
5
  end
@@ -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
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