fitting 2.18.2 → 3.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +2 -11
  3. data/CHANGELOG.md +21 -0
  4. data/README.md +46 -6
  5. data/fitting.gemspec +3 -1
  6. data/lib/fitting/configuration.rb +12 -6
  7. data/lib/fitting/cover/json_schema.rb +4 -2
  8. data/lib/fitting/cover/json_schema_enum.rb +4 -2
  9. data/lib/fitting/cover/json_schema_one_of.rb +4 -2
  10. data/lib/fitting/railtie.rb +1 -0
  11. data/lib/fitting/records/documented/request.rb +1 -15
  12. data/lib/fitting/records/spherical/requests.rb +1 -1
  13. data/lib/fitting/records/tested/request.rb +11 -11
  14. data/lib/fitting/records/tested/response.rb +4 -4
  15. data/lib/fitting/report/actions.rb +4 -0
  16. data/lib/fitting/report/console.rb +32 -12
  17. data/lib/fitting/report/prefix.rb +20 -41
  18. data/lib/fitting/report/prefixes.rb +7 -8
  19. data/lib/fitting/report/response.rb +0 -3
  20. data/lib/fitting/report/tests.rb +23 -10
  21. data/lib/fitting/storage/responses.rb +5 -9
  22. data/lib/fitting/tests.rb +12 -4
  23. data/lib/fitting/version.rb +1 -1
  24. data/lib/fitting.rb +38 -43
  25. data/lib/tasks/fitting.rake +3 -186
  26. data/lib/tasks/fitting_outgoing.rake +91 -0
  27. metadata +25 -41
  28. data/lib/fitting/configuration/yaml.rb +0 -89
  29. data/lib/fitting/cover/response.rb +0 -37
  30. data/lib/fitting/documentation.rb +0 -56
  31. data/lib/fitting/matchers/response_matcher.rb +0 -88
  32. data/lib/fitting/records/realized_unit.rb +0 -52
  33. data/lib/fitting/records/test_unit/request.rb +0 -98
  34. data/lib/fitting/records/unit/combination.rb +0 -27
  35. data/lib/fitting/records/unit/json_schema.rb +0 -111
  36. data/lib/fitting/records/unit/request.rb +0 -37
  37. data/lib/fitting/records/unit/response.rb +0 -32
  38. data/lib/fitting/request.rb +0 -38
  39. data/lib/fitting/response/fully_validates.rb +0 -34
  40. data/lib/fitting/response.rb +0 -88
  41. data/lib/fitting/statistics/analysis.rb +0 -25
  42. data/lib/fitting/statistics/cover_error.rb +0 -29
  43. data/lib/fitting/statistics/cover_error_enum.rb +0 -29
  44. data/lib/fitting/statistics/cover_error_one_of.rb +0 -29
  45. data/lib/fitting/statistics/great.rb +0 -13
  46. data/lib/fitting/statistics/list.rb +0 -55
  47. data/lib/fitting/statistics/lists.rb +0 -53
  48. data/lib/fitting/statistics/measurement.rb +0 -92
  49. data/lib/fitting/statistics/measurement_cover.rb +0 -92
  50. data/lib/fitting/statistics/measurement_cover_enum.rb +0 -92
  51. data/lib/fitting/statistics/measurement_cover_one_of.rb +0 -92
  52. data/lib/fitting/statistics/not_covered_responses.rb +0 -13
  53. data/lib/fitting/statistics/percent.rb +0 -20
  54. data/lib/fitting/statistics/requests_stats.rb +0 -40
  55. data/lib/fitting/statistics/responses_stats.rb +0 -32
  56. data/lib/fitting/statistics/template.rb +0 -117
  57. data/lib/fitting/statistics/template_cover_error.rb +0 -50
  58. data/lib/fitting/statistics/template_cover_error_enum.rb +0 -50
  59. data/lib/fitting/statistics/template_cover_error_one_of.rb +0 -50
  60. data/lib/fitting/statistics.rb +0 -25
  61. data/lib/fitting/storage/white_list.rb +0 -158
  62. data/lib/fitting/templates/realized_template.rb +0 -49
  63. data/lib/fitting/view/report.html.haml +0 -16
  64. data/lib/fitting/view/style.css +0 -47
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4939d5e53f11ac3b5f28fa3088b20acefd5613b3c7ea8b075917ce9fa5703acd
4
- data.tar.gz: 694aadc94e89341395c72cf1f26baeb065f7e10f6d0a7e305f4190ddc3e50d22
3
+ metadata.gz: af3cbf8a5fa59f9d3f9e38008397af27d784ca682cbe9a25b33b17bf671cabc1
4
+ data.tar.gz: fbee4660c1c6e26e85420c76ea7c924fcc9aa5b0eadea53beacead3f3c00a44e
5
5
  SHA512:
6
- metadata.gz: bd7f9bfe0f22b4110e304e80daf8f843d6eba3bdf32598767b6da1e294ff83867593402eaaaa9665649162789aa3485f64ee3af066688dec0af0e96edb52caf8
7
- data.tar.gz: 4ebe7ebf8d3f629b66f0378016fbd99a42d9d9907e911fe754732cb0c25761ebfe16cb095b4b76d11f24261b1f5213a6800e433998f225fd20b6bf9d7c0974e6
6
+ metadata.gz: afdbc7965db9bd5dcfe8267ddbb69e6bddb1229baa66a6ed723a4fac7468a35ff1ec5766b6ef1f9ae511d5e08b10f72efaa60237fb29da2c174e172ff4b3b7f6
7
+ data.tar.gz: 2567a2ec55744422f59979b67cf94ff0deb32740ed69001f47c28634bf851a77df41c4a1499b9bc5f1365456cd483851dff44e9deedb0df31265386ba6470063
data/.rubocop.yml CHANGED
@@ -13,27 +13,18 @@ Style/FrozenStringLiteralComment:
13
13
  Metrics/BlockLength:
14
14
  Enabled: false
15
15
 
16
- Style/CaseEquality:
17
- Enabled: false
18
-
19
- Style/NilComparison:
20
- Enabled: false
21
-
22
16
  Naming/MemoizedInstanceVariableName:
23
17
  Enabled: false
24
18
 
25
- Lint/UnreachableCode:
26
- Enabled: false
27
-
28
19
  Metrics/MethodLength:
29
- Max: 50
20
+ Max: 60
30
21
 
31
22
  # FIXME
32
23
  Metrics/AbcSize:
33
24
  Max: 50
34
25
 
35
26
  Metrics/PerceivedComplexity:
36
- Max: 20
27
+ Max: 30
37
28
 
38
29
  Metrics/CyclomaticComplexity:
39
30
  Max: 20
data/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # Change log
2
2
 
3
+ ### 3.0.2 - 2022-01-25
4
+
5
+ * patch
6
+ * fix require
7
+
8
+ ### 3.0.1 - 2021-12-09
9
+
10
+ * patch
11
+ * fix init prefixes
12
+
13
+ ### 3.0.0 - 2021-12-09
14
+
15
+ * features
16
+ * update configuration
17
+ * support outgoing WebMock request
18
+
19
+ ### 2.18.3 - 2021-11-12
20
+
21
+ * patch
22
+ * added print table console [#121](https://github.com/funbox/fitting/issues/121)
23
+
3
24
  ### 2.18.2 - 2021-11-09
4
25
 
5
26
  * patch
data/README.md CHANGED
@@ -48,7 +48,9 @@ Also Swagger
48
48
  ```yaml
49
49
  prefixes:
50
50
  - name: /api/v1
51
- openapi2_json_path: doc.json
51
+ type: openapi2
52
+ schema_paths:
53
+ - doc.json
52
54
  ```
53
55
 
54
56
  ### OpenAPI 3.0
@@ -57,7 +59,9 @@ Also OpenAPI
57
59
  ```yaml
58
60
  prefixes:
59
61
  - name: /api/v1
60
- openapi3_yaml_path: doc.yaml
62
+ type: openapi3
63
+ schema_paths:
64
+ - doc.yaml
61
65
  ```
62
66
 
63
67
  ### API Blueprint
@@ -75,7 +79,9 @@ and then
75
79
  ```yaml
76
80
  prefixes:
77
81
  - name: /api/v1
78
- drafter_yaml_path: doc.yaml
82
+ type: drafter
83
+ schema_paths:
84
+ - doc.yaml
79
85
  ```
80
86
 
81
87
  ### Tomograph
@@ -85,7 +91,9 @@ To use additional features of the pre-converted [tomograph](https://github.com/f
85
91
  ```yaml
86
92
  prefixes:
87
93
  - name: /api/v1
88
- tomogram_json_path: doc.json
94
+ type: tomogram
95
+ schema_paths:
96
+ - doc.json
89
97
  ```
90
98
 
91
99
  ## Run
@@ -99,6 +107,11 @@ and then
99
107
  bundle e rake fitting:report
100
108
  ```
101
109
 
110
+ Run tests by outgoing request first to get run artifacts
111
+ ```bash
112
+ bundle e rake fitting_out:report
113
+ ```
114
+
102
115
  Console ouptut
103
116
 
104
117
  ```text
@@ -144,7 +157,9 @@ Setting the prefix name is optional. For example, you can do this:
144
157
 
145
158
  ```yaml
146
159
  prefixes:
147
- - openapi2_json_path: doc.json
160
+ - type: openapi2
161
+ schema_paths:
162
+ - doc.json
148
163
  ```
149
164
 
150
165
  ## prefix skip
@@ -153,11 +168,36 @@ It is not necessary to immediately describe each prefix in detail, you can only
153
168
  ```yaml
154
169
  prefixes:
155
170
  - name: /api/v1
156
- openapi2_json_path: doc.json
171
+ type: openapi2
172
+ schema_paths:
173
+ - doc.json
174
+ - name: /api/v3
175
+ skip: true
176
+ ```
177
+
178
+ For work with WebMock outgoing request, you should set up outgoing prefixes
179
+ ```yaml
180
+ outgoing_prefixes:
181
+ - name: /api/v1
182
+ type: openapi2
183
+ schema_paths:
184
+ - doc.json
157
185
  - name: /api/v3
158
186
  skip: true
159
187
  ```
160
188
 
189
+ You can choose location that must be teste
190
+
191
+ ```yaml
192
+ prefixes:
193
+ - type: openapi2
194
+ schema_paths:
195
+ - doc.json
196
+ only:
197
+ - POST /api/v1/users
198
+ - GET /api/v1/user/{id}
199
+ ```
200
+
161
201
  ## Contributing
162
202
 
163
203
  Bug reports and pull requests are welcome on GitHub at [github.com/funbox/fitting](https://github.com/funbox/fitting).
data/fitting.gemspec CHANGED
@@ -20,11 +20,13 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.required_ruby_version = '>= 2.6.0'
22
22
  spec.add_runtime_dependency 'json-schema', '~> 2.6', '>= 2.6.2'
23
+ spec.add_runtime_dependency 'terminal-table', '~> 3.0', '>= 3.0.2'
23
24
  spec.add_runtime_dependency 'tomograph', '~> 3.1', '>= 3.1.0'
25
+
24
26
  spec.add_development_dependency 'bundler', '~> 2.0'
25
27
  spec.add_development_dependency 'byebug', '~> 11.1', '>= 11.1.3'
26
28
  spec.add_development_dependency 'rake', '~> 13.0', '>= 13.0.6'
27
29
  spec.add_development_dependency 'rspec', '~> 3.10'
28
- spec.add_development_dependency 'rubocop', '~> 1.22.0'
30
+ spec.add_development_dependency 'rubocop', '>= 1.22.0'
29
31
  spec.add_development_dependency 'simplecov', '~> 0.21'
30
32
  end
@@ -1,11 +1,17 @@
1
- require 'fitting/configuration/yaml'
2
- require 'yaml'
3
-
4
1
  module Fitting
5
2
  class Configuration
6
- def self.craft
7
- yaml = YAML.safe_load(File.read('.fitting.yml'))
8
- Fitting::Configuration::Yaml.new(yaml)
3
+ attr_accessor :rspec_json_path,
4
+ :webmock_json_path,
5
+ :fitting_report_path,
6
+ :prefixes,
7
+ :outgoing_prefixes
8
+
9
+ def initialize(config)
10
+ @rspec_json_path = config['rspec_json_path'] || './fitting_tests'
11
+ @fitting_report_path = config['fitting_report_path'] || './fitting'
12
+ @prefixes = config['prefixes'] || []
13
+ @webmock_json_path = config['webmock_json_path'] || './outgoing_request_tests'
14
+ @outgoing_prefixes = config['outgoing_prefixes'] || []
9
15
  end
10
16
  end
11
17
  end
@@ -1,14 +1,16 @@
1
1
  module Fitting
2
2
  class Cover
3
3
  class JSONSchema
4
+ attr_reader :json_schema, :combinations
5
+
4
6
  def initialize(json_schema)
5
7
  @json_schema = json_schema
6
8
  @combinations = []
7
9
  end
8
10
 
9
11
  def combi
10
- inception(@json_schema, @combinations).each do |combination|
11
- combination[0] = @json_schema.merge(combination[0])
12
+ inception(json_schema, combinations).each do |combination|
13
+ combination[0] = json_schema.merge(combination[0])
12
14
  combination[1] = ['required', combination[1]]
13
15
  end
14
16
  end
@@ -1,14 +1,16 @@
1
1
  module Fitting
2
2
  class Cover
3
3
  class JSONSchemaEnum
4
+ attr_reader :json_schema, :combinations
5
+
4
6
  def initialize(json_schema)
5
7
  @json_schema = json_schema
6
8
  @combinations = []
7
9
  end
8
10
 
9
11
  def combi
10
- inception(@json_schema, @combinations).each do |combination|
11
- combination[0] = @json_schema.merge(combination[0])
12
+ inception(json_schema, combinations).each do |combination|
13
+ combination[0] = json_schema.merge(combination[0])
12
14
  combination[1] = ['enum', combination[1]]
13
15
  end
14
16
  end
@@ -1,14 +1,16 @@
1
1
  module Fitting
2
2
  class Cover
3
3
  class JSONSchemaOneOf
4
+ attr_reader :json_schema, :combinations
5
+
4
6
  def initialize(json_schema)
5
7
  @json_schema = json_schema
6
8
  @combinations = []
7
9
  end
8
10
 
9
11
  def combi
10
- inception(@json_schema, @combinations).each do |combination|
11
- combination[0] = @json_schema.merge(combination[0])
12
+ inception(json_schema, combinations).each do |combination|
13
+ combination[0] = json_schema.merge(combination[0])
12
14
  combination[1] = ['one_of', combination[1]]
13
15
  end
14
16
  end
@@ -4,6 +4,7 @@ module Fitting
4
4
  class MyRailtie < Rails::Railtie
5
5
  rake_tasks do
6
6
  load 'tasks/fitting.rake'
7
+ load 'tasks/fitting_outgoing.rake'
7
8
  end
8
9
  end
9
10
  end
@@ -2,9 +2,8 @@ module Fitting
2
2
  class Records
3
3
  class Documented
4
4
  class Request
5
- def initialize(tomogram_request, white_list)
5
+ def initialize(tomogram_request)
6
6
  @tomogram_request = tomogram_request
7
- @white_list = white_list
8
7
  end
9
8
 
10
9
  def method
@@ -24,21 +23,8 @@ module Fitting
24
23
  end
25
24
  end
26
25
 
27
- def white
28
- @white ||= white?
29
- end
30
-
31
26
  private
32
27
 
33
- def white?
34
- return true if @white_list == nil
35
- return false if @white_list[path.to_s] == nil
36
- return true if @white_list[path.to_s] == []
37
- return true if @white_list[path.to_s].include?(method)
38
-
39
- false
40
- end
41
-
42
28
  def groups
43
29
  @groups ||= @tomogram_request.responses.group_by do |tomogram_response|
44
30
  tomogram_response['status']
@@ -10,7 +10,7 @@ module Fitting
10
10
 
11
11
  array = []
12
12
  Dir['fitting_tests/*.json'].each do |file|
13
- array += JSON.parse(File.read(file))
13
+ array += JSON.parse(file)
14
14
  end
15
15
  @to_a = array.inject([]) do |res, tested_request|
16
16
  request = Fitting::Records::Spherical::Request.load(tested_request)
@@ -6,33 +6,33 @@ module Fitting
6
6
  class Records
7
7
  class Tested
8
8
  class Request
9
- def initialize(env_response, metadata)
10
- @env_response = env_response
11
- @metadata = metadata
9
+ def initialize(response, example)
10
+ @example = example
11
+ @response = response
12
12
  end
13
13
 
14
14
  def method
15
- @method ||= @env_response.request.request_method
15
+ @method ||= @response.request.request_method
16
16
  end
17
17
 
18
18
  def path
19
- @path ||= Tomograph::Path.new(@env_response.request.env['PATH_INFO'] || @env_response.request.fullpath)
19
+ @path ||= Tomograph::Path.new(@response.request.fullpath)
20
20
  end
21
21
 
22
22
  def body
23
- @body ||= @env_response.request.env['action_dispatch.request.request_parameters']
23
+ @body ||= @response.request.request_parameters
24
24
  end
25
25
 
26
- def response
27
- @response ||= Fitting::Records::Tested::Response.new(@env_response)
26
+ def fitting_response
27
+ @fitting_response ||= Fitting::Records::Tested::Response.new(@response)
28
28
  end
29
29
 
30
30
  def test_path
31
- @test_path ||= @metadata.fetch(:location)
31
+ @test_path ||= @example.location
32
32
  end
33
33
 
34
34
  def test_file_path
35
- @test_file_path ||= @metadata.fetch(:file_path)
35
+ @test_file_path ||= @example.file_path
36
36
  end
37
37
 
38
38
  def to_spherical
@@ -40,7 +40,7 @@ module Fitting
40
40
  method: method,
41
41
  path: path,
42
42
  body: body,
43
- response: response.to_spherical,
43
+ response: fitting_response.to_spherical,
44
44
  title: test_path,
45
45
  group: test_file_path
46
46
  )
@@ -4,16 +4,16 @@ module Fitting
4
4
  class Records
5
5
  class Tested
6
6
  class Response
7
- def initialize(env_response)
8
- @env_response = env_response
7
+ def initialize(response)
8
+ @response = response
9
9
  end
10
10
 
11
11
  def status
12
- @status ||= @env_response.status
12
+ @status ||= @response.status
13
13
  end
14
14
 
15
15
  def body
16
- @body ||= @env_response.body
16
+ @body ||= @response.body
17
17
  end
18
18
 
19
19
  def to_spherical
@@ -14,6 +14,10 @@ module Fitting
14
14
  @actions
15
15
  end
16
16
 
17
+ def push(actions)
18
+ @actions += actions.to_a
19
+ end
20
+
17
21
  def join(tests)
18
22
  tests.to_a.map do |test|
19
23
  if there_a_suitable_action?(test)
@@ -1,30 +1,50 @@
1
+ require 'terminal-table'
2
+
1
3
  module Fitting
2
4
  module Report
3
5
  class Console
4
6
  def initialize(tests_without_prefixes, prefixes_details)
5
7
  @tests_without_prefixes = tests_without_prefixes
6
8
  @prefixes_details = prefixes_details
9
+
7
10
  @good = true
8
11
  @tests_without_actions = []
9
12
  @tests_without_responses = []
10
13
  end
11
14
 
12
15
  def output
13
- doc_res = @prefixes_details.inject('') do |res, prefix_details|
14
- res += "#{prefix_details[:name]}\n"
15
- @tests_without_actions += prefix_details[:actions][:tests_without_actions]
16
- res += prefix_details[:actions][:actions_details].inject('') do |res_actions, action|
17
- res_actions += "#{action[:method]}\t#{action[:path]}"
18
- tab = "\t" * (8 - action[:path].size / 8)
19
- @tests_without_responses += action[:responses][:tests_without_responses]
20
- res_actions += tab + action[:responses][:responses_details].inject('') do |res_responses, response|
21
- @good = false if response[:combinations][:cover_percent] != '100%'
22
- res_responses += " #{response[:combinations][:cover_percent]} #{response[:method]}"
16
+ tables = []
17
+
18
+ @prefixes_details.each do |prefix_details|
19
+ title = prefix_details[:name]
20
+ @tests_without_actions += prefix_details[:actions][:tests_without_actions] # непонятно что такое
21
+
22
+ next if prefix_details[:actions][:actions_details].count.zero?
23
+
24
+ tables << Terminal::Table.new do |t|
25
+ t.title = title
26
+ t.headings = %w[method path cover]
27
+
28
+ prefix_details[:actions][:actions_details].each do |action|
29
+ @tests_without_responses += action[:responses][:tests_without_responses]
30
+
31
+ path_details = action[:responses][:responses_details].map do |responses_detail|
32
+ @good = false if responses_detail[:combinations][:cover_percent] != '100%'
33
+ [responses_detail[:combinations][:cover_percent], responses_detail[:method]]
34
+ end.join(' ')
35
+
36
+ t.add_row [action[:method], action[:path], path_details]
23
37
  end
24
- res_actions += "\n"
38
+
39
+ t.style = { all_separators: true, border: :unicode }
25
40
  end
26
41
  end
27
- doc_res += "\n"
42
+
43
+ tables
44
+ end
45
+
46
+ def output_sum
47
+ doc_res = ''
28
48
  doc_res += "tests_without_prefixes: #{@tests_without_prefixes.size}\n"
29
49
  doc_res += "tests_without_actions: #{@tests_without_actions.size}\n"
30
50
  doc_res += "tests_without_responses: #{@tests_without_responses.size}\n"
@@ -3,53 +3,32 @@ require 'fitting/report/actions'
3
3
  module Fitting
4
4
  module Report
5
5
  class Prefix
6
- def initialize(name: '', openapi2_json_path: nil, openapi3_yaml_path: nil,
7
- drafter_yaml_path: nil, tomogram_json_path: nil, crafter_yaml_path: nil, skip: false)
6
+ KEYS = {
7
+ 'openapi2' => :openapi2_json_path,
8
+ 'openapi3' => :openapi3_yaml_path,
9
+ 'drafter' => :drafter_yaml_path,
10
+ 'crafter' => :crafter_yaml_path,
11
+ 'tomogram' => :tomogram_json_path
12
+ }.freeze
13
+
14
+ attr_reader :name, :tests, :actions
15
+
16
+ def initialize(schema_paths: nil, type: nil, name: '', skip: false, only: [])
8
17
  @name = name
9
- @tomogram_json_path = tomogram_json_path
10
18
  @tests = Fitting::Report::Tests.new([])
11
19
  @skip = skip
12
20
  return if skip
13
21
 
14
- @actions = if openapi2_json_path
15
- Fitting::Report::Actions.new(
16
- Tomograph::Tomogram.new(
17
- prefix: name,
18
- openapi2_json_path: openapi2_json_path
19
- )
20
- )
21
- elsif openapi3_yaml_path
22
- Fitting::Report::Actions.new(
23
- Tomograph::Tomogram.new(
24
- prefix: name,
25
- openapi3_yaml_path: openapi3_yaml_path
26
- )
27
- )
28
- elsif drafter_yaml_path
29
- Fitting::Report::Actions.new(
30
- Tomograph::Tomogram.new(
31
- prefix: name,
32
- drafter_yaml_path: drafter_yaml_path
33
- )
34
- )
35
- elsif crafter_yaml_path
36
- Fitting::Report::Actions.new(
37
- Tomograph::Tomogram.new(
38
- prefix: name,
39
- crafter_yaml_path: crafter_yaml_path
40
- )
41
- )
42
- else
43
- Fitting::Report::Actions.new(
44
- Tomograph::Tomogram.new(
45
- prefix: name,
46
- tomogram_json_path: tomogram_json_path
47
- )
48
- )
49
- end
50
- end
22
+ @actions = Fitting::Report::Actions.new([])
51
23
 
52
- attr_reader :name, :tests, :actions
24
+ schema_paths.each do |path|
25
+ tomogram = Tomograph::Tomogram.new(prefix: name, KEYS[type] => path)
26
+
27
+ tomogram.to_a.filter! { |action| only.include?("#{action.method} #{action.path}") } if only.present?
28
+
29
+ @actions.push(Fitting::Report::Actions.new(tomogram))
30
+ end
31
+ end
53
32
 
54
33
  def skip?
55
34
  @skip
@@ -3,18 +3,17 @@ require 'fitting/report/prefix'
3
3
  module Fitting
4
4
  module Report
5
5
  class Prefixes
6
- def initialize(config_path)
6
+ def initialize(configuration_prefixes)
7
7
  @prefixes = []
8
- YAML.safe_load(File.read(config_path))['prefixes'].map do |prefix|
8
+
9
+ configuration_prefixes.map do |prefix|
9
10
  @prefixes.push(
10
11
  Fitting::Report::Prefix.new(
12
+ schema_paths: prefix['schema_paths'],
13
+ type: prefix['type'],
11
14
  name: prefix['name'],
12
- openapi2_json_path: prefix['openapi2_json_path'],
13
- openapi3_yaml_path: prefix['openapi3_yaml_path'],
14
- drafter_yaml_path: prefix['drafter_yaml_path'],
15
- tomogram_json_path: prefix['tomogram_json_path'],
16
- crafter_yaml_path: prefix['crafter_yaml_path'],
17
- skip: prefix['skip']
15
+ skip: prefix['skip'],
16
+ only: prefix['only']
18
17
  )
19
18
  )
20
19
  end
@@ -1,6 +1,3 @@
1
- require 'fitting/statistics/template_cover_error'
2
- require 'fitting/statistics/template_cover_error_enum'
3
- require 'fitting/statistics/template_cover_error_one_of'
4
1
  require 'fitting/report/combinations'
5
2
  require 'fitting/report/combination'
6
3
 
@@ -3,13 +3,26 @@ require 'fitting/report/test'
3
3
  module Fitting
4
4
  module Report
5
5
  class Tests
6
+ attr_reader :tests
7
+
6
8
  def initialize(tests)
7
9
  @tests = tests
8
10
  end
9
11
 
10
- def self.new_from_config(tests_path)
12
+ def self.new_from_config
13
+ tests = []
14
+ Dir["#{Fitting.configuration.rspec_json_path}/*.json"].each do |file|
15
+ JSON.parse(File.read(file)).map do |test|
16
+ tests.push(Fitting::Report::Test.new(test))
17
+ end
18
+ end
19
+ tests.sort { |a, b| b.path <=> a.path }
20
+ new(tests)
21
+ end
22
+
23
+ def self.new_from_outgoing_config
11
24
  tests = []
12
- Dir[tests_path].each do |file|
25
+ Dir["#{Fitting.configuration.webmock_json_path}/*.json"].each do |file|
13
26
  JSON.parse(File.read(file)).map do |test|
14
27
  tests.push(Fitting::Report::Test.new(test))
15
28
  end
@@ -19,45 +32,45 @@ module Fitting
19
32
  end
20
33
 
21
34
  def without_prefixes
22
- @tests.each_with_object([]) do |test, result|
35
+ tests.each_with_object([]) do |test, result|
23
36
  result.push(test.path) unless test.there_a_prefix?
24
37
  end
25
38
  end
26
39
 
27
40
  def without_actions
28
- @tests.each_with_object([]) do |test, result|
41
+ tests.each_with_object([]) do |test, result|
29
42
  result.push("#{test.method} #{test.path}") unless test.there_an_actions?
30
43
  end
31
44
  end
32
45
 
33
46
  def without_responses
34
- @tests.each_with_object([]) do |test, result|
47
+ tests.each_with_object([]) do |test, result|
35
48
  result.push(test.id) unless test.there_an_responses?
36
49
  end
37
50
  end
38
51
 
39
52
  def without_combinations
40
- @tests.each_with_object([]) do |test, result|
53
+ tests.each_with_object([]) do |test, result|
41
54
  result.push(test.path) unless test.there_an_combinations?
42
55
  end
43
56
  end
44
57
 
45
58
  def push(test)
46
- @tests.push(test)
59
+ tests.push(test)
47
60
  end
48
61
 
49
62
  def size
50
- @tests.size
63
+ tests.size
51
64
  end
52
65
 
53
66
  def to_a
54
- @tests
67
+ tests
55
68
  end
56
69
 
57
70
  def to_h
58
71
  return @hash if @hash
59
72
 
60
- @hash = @tests.inject({}) do |res, test|
73
+ @hash = tests.inject({}) do |res, test|
61
74
  res.merge!(test.id => test.to_h)
62
75
  end
63
76
  end