committee-rails 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +4 -1
- data/README.md +19 -7
- data/committee-rails.gemspec +1 -1
- data/lib/committee/rails/test/methods.rb +19 -52
- data/lib/committee/rails/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b640c3b77a994b7172de11d4d3cc0e207d869d11576bb2747ff6b6530be792d3
|
4
|
+
data.tar.gz: f6ba370310d7fbb0cdc5e60f67cea8e99eafb99b1970d2bd3649046aca60c7ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6df47e899656d8a8d397d74a1548ddc1106e73806508ed01469afca839dfe4f0c9fc0252a6a89780da3511e07bbc35b1197b380a1035efaa3d0767d38fba093d
|
7
|
+
data.tar.gz: 47d2ff2e4d8ea5a343d08223c994cefb3298e30596b9b7b298a69e85549ccf85185975d4e717cf7bcfb577a758011d6832a87d88416869e90a60ab603db69840
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -17,23 +17,25 @@ And then execute:
|
|
17
17
|
|
18
18
|
$ bundle
|
19
19
|
|
20
|
+
|
21
|
+
If you use committee prior to 2.4, you have to use committee-rails 0.3.x. Please see below.
|
22
|
+
|
23
|
+
[0.3 (0-3-stable) documentation](https://github.com/willnet/committee-rails/tree/0-3-stable)
|
24
|
+
|
20
25
|
If you use committee prior to 2.0, you have to use committee-rails 0.1.x. Please see below.
|
21
26
|
|
22
27
|
[0.1 (0-1-stable) documentation](https://github.com/willnet/committee-rails/tree/0-1-stable)
|
23
28
|
|
24
|
-
|
25
29
|
## Usage
|
26
30
|
|
31
|
+
### normal usage
|
32
|
+
|
27
33
|
```ruby
|
28
34
|
describe 'request spec' do
|
29
35
|
include Committee::Rails::Test::Methods
|
30
36
|
|
31
|
-
def
|
32
|
-
@
|
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
|
37
|
+
def committee_options
|
38
|
+
@committee_options ||= { schema_path: Rails.root.join('schema', 'schema.json').to_s }
|
37
39
|
end
|
38
40
|
|
39
41
|
describe 'GET /' do
|
@@ -45,6 +47,16 @@ describe 'request spec' do
|
|
45
47
|
end
|
46
48
|
```
|
47
49
|
|
50
|
+
### rspec setting
|
51
|
+
If you use rspec, you can use very simple.
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
RSpec.configure do |config|
|
55
|
+
config.add_setting :committee_options
|
56
|
+
config.committee_options = { schema_path: Rails.root.join('schema', 'schema.json').to_s }
|
57
|
+
end
|
58
|
+
```
|
59
|
+
|
48
60
|
## Development
|
49
61
|
|
50
62
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
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', '>= 2.
|
21
|
+
spec.add_dependency 'committee', '>= 2.4.0'
|
22
22
|
spec.add_dependency 'activesupport'
|
23
23
|
spec.add_dependency 'actionpack'
|
24
24
|
spec.add_dependency 'railties'
|
@@ -4,65 +4,32 @@ module Committee::Rails
|
|
4
4
|
include Committee::Test::Methods
|
5
5
|
|
6
6
|
def committee_schema
|
7
|
-
|
8
|
-
|
9
|
-
@committee_schema ||= begin
|
10
|
-
|
11
|
-
driver = Committee::Drivers::HyperSchema.new
|
12
|
-
schema_hash = JSON.parse(File.read(Rails.root.join('docs', 'schema', 'schema.json')))
|
13
|
-
driver.parse(schema_hash)
|
14
|
-
end
|
7
|
+
# this code for 2.4.0, committee 3.x use committee_options
|
8
|
+
@committee_schema ||= Committee::Middleware::Base.new(nil, committee_options).send(:get_schema, committee_options)
|
15
9
|
end
|
16
10
|
|
17
11
|
def committee_options
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
#
|
24
|
-
#
|
25
|
-
|
26
|
-
if committee_schema
|
27
|
-
committee_schema
|
28
|
-
else
|
29
|
-
schema = schema_contents
|
30
|
-
|
31
|
-
if schema.is_a?(String)
|
32
|
-
warn_string_deprecated
|
33
|
-
elsif schema.is_a?(Hash)
|
34
|
-
warn_hash_deprecated
|
35
|
-
end
|
36
|
-
|
37
|
-
if schema.is_a?(String)
|
38
|
-
schema = JSON.parse(schema)
|
39
|
-
end
|
40
|
-
|
41
|
-
if schema.is_a?(Hash) || schema.is_a?(JsonSchema::Schema)
|
42
|
-
driver = Committee::Drivers::HyperSchema.new
|
43
|
-
|
44
|
-
# The driver itself has its own special cases to be able to parse
|
45
|
-
# either a hash or JsonSchema::Schema object.
|
46
|
-
schema = driver.parse(schema)
|
47
|
-
end
|
48
|
-
|
49
|
-
schema
|
50
|
-
end
|
12
|
+
if defined?(RSpec) && (options = RSpec.try(:configuration).try(:committee_options))
|
13
|
+
options
|
14
|
+
elsif !defined?(@committee_schema)
|
15
|
+
{ schema: default_schema }
|
16
|
+
else
|
17
|
+
# schema_url_prefix method call this but the user overrite comittee_schema, we got error
|
18
|
+
# we can remove in comittee 3.x
|
19
|
+
{ schema: committee_schema }
|
51
20
|
end
|
21
|
+
end
|
52
22
|
|
53
|
-
|
54
|
-
|
23
|
+
def default_schema
|
24
|
+
@default_schema ||= Committee::Drivers.load_from_file(Rails.root.join('docs', 'schema', 'schema.json').to_s)
|
25
|
+
end
|
55
26
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
raise Committee::InvalidResponse.new(invalid_response)
|
60
|
-
end
|
27
|
+
def request_object
|
28
|
+
request
|
29
|
+
end
|
61
30
|
|
62
|
-
|
63
|
-
|
64
|
-
Committee::ResponseValidator.new(link).call(response.response_code, response.headers, data)
|
65
|
-
end
|
31
|
+
def response_data
|
32
|
+
[response.status, response.headers, response.body]
|
66
33
|
end
|
67
34
|
end
|
68
35
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: committee-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- willnet
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: committee
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.
|
19
|
+
version: 2.4.0
|
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.
|
26
|
+
version: 2.4.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activesupport
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|