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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 68a3f68dc9ba8e438ce54582ea99d45e64371adc7d5a264d68004a6408a67782
4
- data.tar.gz: edd5b6a33ba746b5693ae42c6e0c7381a216de4b4287a48d66f5e58429b20875
3
+ metadata.gz: b640c3b77a994b7172de11d4d3cc0e207d869d11576bb2747ff6b6530be792d3
4
+ data.tar.gz: f6ba370310d7fbb0cdc5e60f67cea8e99eafb99b1970d2bd3649046aca60c7ae
5
5
  SHA512:
6
- metadata.gz: 69292ca6e1c5dddc9a0473aab8418fc20d5fcd8e517cfd989bda4cb262000fc373c903f4ac024e82981d26351caa65e3b329124e875f09b489479081b14933ae
7
- data.tar.gz: 0566b55c0fdc9d6403effb7a9816fb5feafe9cfb939a6c2525bfeba8a63313312afc4bd87361272cd5e9a40fa5333670792e036ab672dc7bfce925413adc50bf
6
+ metadata.gz: 6df47e899656d8a8d397d74a1548ddc1106e73806508ed01469afca839dfe4f0c9fc0252a6a89780da3511e07bbc35b1197b380a1035efaa3d0767d38fba093d
7
+ data.tar.gz: 47d2ff2e4d8ea5a343d08223c994cefb3298e30596b9b7b298a69e85549ccf85185975d4e717cf7bcfb577a758011d6832a87d88416869e90a60ab603db69840
@@ -4,4 +4,7 @@ rvm:
4
4
  - 2.3
5
5
  - 2.4
6
6
  - 2.5
7
- before_install: gem install bundler
7
+ - 2.6
8
+ before_install:
9
+ - gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true
10
+ - gem install bundler -v '< 2'
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 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
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.
@@ -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.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
- @committee_schema = committee_options[:schema]
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
- end
20
-
21
- def assert_schema_conform
22
- @committee_schema ||= begin
23
- # The preferred option. The user has already parsed a schema elsewhere
24
- # and we therefore don't have to worry about any performance
25
- # implications of having to do it for every single test suite.
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
- @committee_router ||= Committee::Router.new(@committee_schema,
54
- prefix: schema_url_prefix)
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
- link, _ = @committee_router.find_request_link(request)
57
- unless link
58
- invalid_response = "`#{request.request_method} #{request.path_info}` undefined in schema."
59
- raise Committee::InvalidResponse.new(invalid_response)
60
- end
27
+ def request_object
28
+ request
29
+ end
61
30
 
62
- if validate_response?(response.response_code)
63
- data = JSON.parse(response.body)
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
@@ -1,5 +1,5 @@
1
1
  module Committee
2
2
  module Rails
3
- VERSION = "0.3.0"
3
+ VERSION = "0.4.0"
4
4
  end
5
5
  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.3.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: 2018-11-26 00:00:00.000000000 Z
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.0.0
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.0.0
26
+ version: 2.4.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activesupport
29
29
  requirement: !ruby/object:Gem::Requirement