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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a4a2263a61bd5a5f7c2d8bff36a09af540921266
4
- data.tar.gz: e2eaab13de294adc2d25e384d71987c0520fba74
3
+ metadata.gz: 89064ee81b1800d5ae8770a4cd6cdb2a286df8e8
4
+ data.tar.gz: b275fccf8926680cb347b105aa14ed6cb4d4d554
5
5
  SHA512:
6
- metadata.gz: 7f46e87c5c1c8081b48f16fe48ccb83b2dc1f32c3cb3227ec7fa2a24dbdbf15745ead93be66ab44e14f94a825205a27e049b38c748d616bb13392b2efb9a00ad
7
- data.tar.gz: 23c169a420bd3f2eeae9eed570b2978bafad5ec37b0f162374696540e0c03bffed1f34d95c4b037ef73ef87876971740e67f793a5695017f673b795db651870b
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
- Or install it yourself as:
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 schema_path
31
- Rails.root.join('path', 'to', 'schema.json') # default to docs/schema/schema.json
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
@@ -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', '< 2.0.0'
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 schema_path
7
- Rails.root.join('docs', 'schema', 'schema.json')
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
- if (data = schema_contents).is_a?(String)
12
- warn_string_deprecated
13
- data = JSON.parse(data)
14
- end
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
- @schema ||= begin
17
- schema = JsonSchema.parse!(data)
18
- schema.expand_references!
19
- schema
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
- unless link = @router.find_request_link(request)
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
@@ -1,5 +1,5 @@
1
1
  module Committee
2
2
  module Rails
3
- VERSION = "0.1.1"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  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.1.1
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