committee-rails 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -4
- data/committee-rails.gemspec +1 -1
- data/lib/committee/rails/test/methods.rb +39 -12
- data/lib/committee/rails/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 89064ee81b1800d5ae8770a4cd6cdb2a286df8e8
|
4
|
+
data.tar.gz: b275fccf8926680cb347b105aa14ed6cb4d4d554
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 823dc012fbf74036300bb0b90417ca0dc984275e87a59cc2c86b73181959cc91298dec780b3a46150c14ca10e90c113f87d1554c3f911c3479ee8233c1beb34e
|
7
|
+
data.tar.gz: ae936d832f006c4b097495e40f078f575631b96cbdb79730885482877387e67aa566d80f9b2e8f8ecf968b54fae703a9cbbbbe2dfc43d4511c64c0226f8b9978
|
data/README.md
CHANGED
@@ -17,9 +17,10 @@ And then execute:
|
|
17
17
|
|
18
18
|
$ bundle
|
19
19
|
|
20
|
-
|
20
|
+
If you use committee prior to 2.0, you have to use committee-rails 0.1.x. Please see below.
|
21
|
+
|
22
|
+
[0.1 (0-1-stable) documentation](https://github.com/willnet/committee-rails/tree/0-1-stable)
|
21
23
|
|
22
|
-
$ gem install committee-rails
|
23
24
|
|
24
25
|
## Usage
|
25
26
|
|
@@ -27,8 +28,12 @@ Or install it yourself as:
|
|
27
28
|
describe 'request spec' do
|
28
29
|
include Committee::Rails::Test::Methods
|
29
30
|
|
30
|
-
def
|
31
|
-
|
31
|
+
def committee_schema
|
32
|
+
@committee_schema ||= begin
|
33
|
+
driver = Committee::Drivers::HyperSchema.new
|
34
|
+
schema_hash = JSON.parse(File.read(Rails.root.join('schema', 'schema.json'))) # default to docs/schema/schema.json
|
35
|
+
driver.parse(schema_hash)
|
36
|
+
end
|
32
37
|
end
|
33
38
|
|
34
39
|
describe 'GET /' do
|
data/committee-rails.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.bindir = 'exe'
|
19
19
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
20
|
spec.require_paths = ['lib']
|
21
|
-
spec.add_dependency 'committee', '
|
21
|
+
spec.add_dependency 'committee', '~> 2.0.0.pre6'
|
22
22
|
spec.add_dependency 'activesupport'
|
23
23
|
spec.add_dependency 'actionpack'
|
24
24
|
spec.add_dependency 'railties'
|
@@ -3,24 +3,51 @@ module Committee::Rails
|
|
3
3
|
module Methods
|
4
4
|
include Committee::Test::Methods
|
5
5
|
|
6
|
-
def
|
7
|
-
|
6
|
+
def committee_schema
|
7
|
+
@committee_schema ||= begin
|
8
|
+
driver = Committee::Drivers::HyperSchema.new
|
9
|
+
schema_hash = JSON.parse(File.read(Rails.root.join('docs', 'schema', 'schema.json')))
|
10
|
+
driver.parse(schema_hash)
|
11
|
+
end
|
8
12
|
end
|
9
13
|
|
10
14
|
def assert_schema_conform
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
+
@committee_schema ||= begin
|
16
|
+
# The preferred option. The user has already parsed a schema elsewhere
|
17
|
+
# and we therefore don't have to worry about any performance
|
18
|
+
# implications of having to do it for every single test suite.
|
19
|
+
if committee_schema
|
20
|
+
committee_schema
|
21
|
+
else
|
22
|
+
schema = schema_contents
|
23
|
+
|
24
|
+
if schema.is_a?(String)
|
25
|
+
warn_string_deprecated
|
26
|
+
elsif schema.is_a?(Hash)
|
27
|
+
warn_hash_deprecated
|
28
|
+
end
|
29
|
+
|
30
|
+
if schema.is_a?(String)
|
31
|
+
schema = JSON.parse(schema)
|
32
|
+
end
|
15
33
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
34
|
+
if schema.is_a?(Hash) || schema.is_a?(JsonSchema::Schema)
|
35
|
+
driver = Committee::Drivers::HyperSchema.new
|
36
|
+
|
37
|
+
# The driver itself has its own special cases to be able to parse
|
38
|
+
# either a hash or JsonSchema::Schema object.
|
39
|
+
schema = driver.parse(schema)
|
40
|
+
end
|
41
|
+
|
42
|
+
schema
|
43
|
+
end
|
20
44
|
end
|
21
|
-
@router ||= Committee::Router.new(@schema, prefix: schema_url_prefix)
|
22
45
|
|
23
|
-
|
46
|
+
@committee_router ||= Committee::Router.new(@committee_schema,
|
47
|
+
prefix: schema_url_prefix)
|
48
|
+
|
49
|
+
link, _ = @committee_router.find_request_link(request)
|
50
|
+
unless link
|
24
51
|
invalid_response = "`#{request.request_method} #{request.path_info}` undefined in schema."
|
25
52
|
raise Committee::InvalidResponse.new(invalid_response)
|
26
53
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: committee-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- willnet
|
@@ -14,16 +14,16 @@ dependencies:
|
|
14
14
|
name: committee
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.0.0
|
19
|
+
version: 2.0.0.pre6
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.0.0
|
26
|
+
version: 2.0.0.pre6
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activesupport
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|