fitting 2.16.0 → 2.18.1

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.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +34 -3
  3. data/CHANGELOG.md +19 -0
  4. data/README.md +37 -4
  5. data/fitting.gemspec +9 -9
  6. data/images/example.png +0 -0
  7. data/images/example2.png +0 -0
  8. data/images/logo.png +0 -0
  9. data/lib/fitting/configuration/legacy.rb +6 -5
  10. data/lib/fitting/configuration/yaml.rb +2 -2
  11. data/lib/fitting/cover/json_schema.rb +3 -2
  12. data/lib/fitting/cover/json_schema_enum.rb +1 -1
  13. data/lib/fitting/cover/json_schema_one_of.rb +1 -1
  14. data/lib/fitting/cover/response.rb +1 -5
  15. data/lib/fitting/documentation.rb +0 -2
  16. data/lib/fitting/matchers/response_matcher.rb +2 -1
  17. data/lib/fitting/records/documented/request.rb +1 -0
  18. data/lib/fitting/records/realized_unit.rb +13 -15
  19. data/lib/fitting/records/spherical/request.rb +1 -1
  20. data/lib/fitting/records/spherical/requests.rb +2 -1
  21. data/lib/fitting/records/spherical/response.rb +2 -2
  22. data/lib/fitting/records/test_unit/request.rb +4 -0
  23. data/lib/fitting/records/tested/request.rb +4 -4
  24. data/lib/fitting/records/unit/combination.rb +5 -6
  25. data/lib/fitting/records/unit/json_schema.rb +38 -33
  26. data/lib/fitting/records/unit/request.rb +1 -0
  27. data/lib/fitting/records/unit/response.rb +1 -0
  28. data/lib/fitting/report/action.rb +6 -9
  29. data/lib/fitting/report/actions.rb +7 -5
  30. data/lib/fitting/report/combination.rb +1 -15
  31. data/lib/fitting/report/combinations.rb +4 -5
  32. data/lib/fitting/report/console.rb +1 -0
  33. data/lib/fitting/report/prefix.rb +42 -51
  34. data/lib/fitting/report/prefixes.rb +6 -4
  35. data/lib/fitting/report/response.rb +17 -18
  36. data/lib/fitting/report/responses.rb +9 -8
  37. data/lib/fitting/report/test.rb +9 -11
  38. data/lib/fitting/report/tests.rb +10 -13
  39. data/lib/fitting/request.rb +0 -1
  40. data/lib/fitting/response.rb +4 -3
  41. data/lib/fitting/statistics/cover_error.rb +2 -0
  42. data/lib/fitting/statistics/cover_error_enum.rb +2 -0
  43. data/lib/fitting/statistics/cover_error_one_of.rb +2 -0
  44. data/lib/fitting/statistics/list.rb +5 -4
  45. data/lib/fitting/statistics/not_covered_responses.rb +1 -1
  46. data/lib/fitting/statistics/percent.rb +2 -1
  47. data/lib/fitting/statistics/template.rb +10 -8
  48. data/lib/fitting/storage/responses.rb +2 -2
  49. data/lib/fitting/storage/white_list.rb +7 -0
  50. data/lib/fitting/templates/realized_template.rb +2 -0
  51. data/lib/fitting/tests.rb +1 -1
  52. data/lib/fitting/version.rb +1 -1
  53. data/lib/fitting.rb +9 -6
  54. data/lib/tasks/fitting.rake +62 -54
  55. data/lib/templates/bomboniere/package-lock.json +82 -67
  56. data/lib/templates/bomboniere/src/components/HelloWorld.vue +3 -0
  57. metadata +30 -55
  58. data/example.png +0 -0
  59. data/example2.png +0 -0
@@ -16,14 +16,14 @@ module Fitting
16
16
 
17
17
  def join(tests)
18
18
  tests.to_a.map do |test|
19
- if is_there_a_suitable_action?(test)
19
+ if there_a_suitable_action?(test)
20
20
  cram_into_the_appropriate_action(test)
21
21
  test.mark_action
22
22
  end
23
23
  end
24
24
  end
25
25
 
26
- def is_there_a_suitable_action?(test)
26
+ def there_a_suitable_action?(test)
27
27
  @actions.map do |action|
28
28
  return true if test.method == action.method && action.path_match(test.path)
29
29
  end
@@ -35,15 +35,17 @@ module Fitting
35
35
  @actions.map do |action|
36
36
  if test.method == action.method && action.path_match(test.path)
37
37
  action.add_test(test)
38
- return
38
+ break
39
39
  end
40
40
  end
41
41
  end
42
42
 
43
43
  def details(prefix)
44
44
  {
45
- tests_without_actions: prefix.tests.without_actions,
46
- actions_details: @actions.map { |a| {method: a.method, path: a.path, tests_size: a.tests.size, responses: a.details} }
45
+ tests_without_actions: prefix.tests.without_actions,
46
+ actions_details: @actions.map do |a|
47
+ { method: a.method, path: a.path, tests_size: a.tests.size, responses: a.details }
48
+ end
47
49
  }
48
50
  end
49
51
  end
@@ -9,26 +9,12 @@ module Fitting
9
9
  @id = SecureRandom.hex
10
10
  end
11
11
 
12
- def json_schema
13
- @json_schema
14
- end
15
-
16
- def id
17
- @id
18
- end
19
-
20
- def type
21
- @type
22
- end
12
+ attr_reader :json_schema, :id, :type, :tests
23
13
 
24
14
  def name
25
15
  @combination
26
16
  end
27
17
 
28
- def tests
29
- @tests
30
- end
31
-
32
18
  def add_test(test)
33
19
  @tests.push(test)
34
20
  end
@@ -19,15 +19,16 @@ module Fitting
19
19
 
20
20
  def join(tests)
21
21
  tests.to_a.map do |test|
22
- if is_there_a_suitable_combination?(test)
22
+ if there_a_suitable_combination?(test)
23
23
  cram_into_the_appropriate_combinations(test)
24
24
  test.mark_combination
25
25
  end
26
26
  end
27
27
  end
28
28
 
29
- def is_there_a_suitable_combination?(test)
29
+ def there_a_suitable_combination?(test)
30
30
  return false if @combinations.nil?
31
+
31
32
  @combinations.map do |combination|
32
33
  return true if JSON::Validator.fully_validate(combination.json_schema, test.body) == []
33
34
  end
@@ -37,9 +38,7 @@ module Fitting
37
38
 
38
39
  def cram_into_the_appropriate_combinations(test)
39
40
  @combinations.map do |combination|
40
- if JSON::Validator.fully_validate(combination.json_schema, test.body) == []
41
- combination.add_test(test)
42
- end
41
+ combination.add_test(test) if JSON::Validator.fully_validate(combination.json_schema, test.body) == []
43
42
  end
44
43
  end
45
44
  end
@@ -34,6 +34,7 @@ module Fitting
34
34
  return false if @tests_without_prefixes.size != 0
35
35
  return false if @tests_without_actions.size != 0
36
36
  return false if @tests_without_responses.size != 0
37
+
37
38
  @good
38
39
  end
39
40
  end
@@ -3,79 +3,70 @@ 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, drafter_yaml_path: nil, tomogram_json_path: nil, crafter_yaml_path: nil, skip: false)
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)
7
8
  @name = name
8
9
  @tomogram_json_path = tomogram_json_path
9
10
  @tests = Fitting::Report::Tests.new([])
10
11
  @skip = skip
11
- unless skip
12
- @actions = if openapi2_json_path
13
- Fitting::Report::Actions.new(
14
- Tomograph::Tomogram.new(
15
- prefix: name,
16
- openapi2_json_path: openapi2_json_path
17
- )
12
+ return if skip
13
+
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
18
19
  )
19
- elsif openapi3_yaml_path
20
- Fitting::Report::Actions.new(
21
- Tomograph::Tomogram.new(
22
- prefix: name,
23
- openapi3_yaml_path: openapi3_yaml_path
24
- )
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
25
26
  )
26
- elsif drafter_yaml_path
27
- Fitting::Report::Actions.new(
28
- Tomograph::Tomogram.new(
29
- prefix: name,
30
- drafter_yaml_path: drafter_yaml_path
31
- )
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
32
33
  )
33
- elsif crafter_yaml_path
34
- Fitting::Report::Actions.new(
35
- Tomograph::Tomogram.new(
36
- prefix: name,
37
- crafter_yaml_path: crafter_yaml_path
38
- )
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
39
40
  )
40
- else
41
- Fitting::Report::Actions.new(
42
- Tomograph::Tomogram.new(
43
- prefix: name,
44
- tomogram_json_path: tomogram_json_path
45
- )
41
+ )
42
+ else
43
+ Fitting::Report::Actions.new(
44
+ Tomograph::Tomogram.new(
45
+ prefix: name,
46
+ tomogram_json_path: tomogram_json_path
46
47
  )
47
- end
48
- end
48
+ )
49
+ end
49
50
  end
50
51
 
51
- def name
52
- @name
53
- end
54
-
55
- def tests
56
- @tests
57
- end
52
+ attr_reader :name, :tests, :actions
58
53
 
59
54
  def skip?
60
55
  @skip
61
56
  end
62
57
 
63
- def actions
64
- @actions
65
- end
66
-
67
58
  def details
68
59
  if @skip
69
60
  {
70
- name: @name,
71
- tests_size: @tests.size,
72
- actions: {tests_without_actions: [], actions_details: []}
61
+ name: @name,
62
+ tests_size: @tests.size,
63
+ actions: { tests_without_actions: [], actions_details: [] }
73
64
  }
74
65
  else
75
66
  {
76
- name: @name,
77
- tests_size: @tests.size,
78
- actions: @actions.details(self)
67
+ name: @name,
68
+ tests_size: @tests.size,
69
+ actions: @actions.details(self)
79
70
  }
80
71
  end
81
72
  end
@@ -20,8 +20,10 @@ module Fitting
20
20
  end
21
21
  end
22
22
 
23
- def is_there_a_suitable_prefix?(test_path)
23
+ def there_a_suitable_prefix?(test_path)
24
24
  @prefixes.map do |prefix|
25
+ return true if prefix.name.nil?
26
+ return true if prefix.name == ''
25
27
  return true if test_path[0..prefix.name.size - 1] == prefix.name
26
28
  end
27
29
 
@@ -30,16 +32,16 @@ module Fitting
30
32
 
31
33
  def cram_into_the_appropriate_prefix(test)
32
34
  @prefixes.map do |prefix|
33
- if test.path[0..prefix.name.size - 1] == prefix.name
35
+ if prefix.name.nil? || prefix.name == '' || test.path[0..prefix.name.size - 1] == prefix.name
34
36
  prefix.add_test(test)
35
- return
37
+ break
36
38
  end
37
39
  end
38
40
  end
39
41
 
40
42
  def join(tests)
41
43
  tests.to_a.map do |test|
42
- if is_there_a_suitable_prefix?(test.path)
44
+ if there_a_suitable_prefix?(test.path)
43
45
  cram_into_the_appropriate_prefix(test)
44
46
  test.mark_prefix
45
47
  end
@@ -21,31 +21,27 @@ module Fitting
21
21
  @response['body'] || @response[:body]
22
22
  end
23
23
 
24
- def id
25
- @id
26
- end
24
+ attr_reader :id, :tests
27
25
 
28
26
  def add_test(test)
29
27
  @tests.push(test)
30
28
  end
31
29
 
32
- def tests
33
- @tests
34
- end
35
-
36
30
  def combinations
37
31
  return @combinations if @combinations
38
32
 
39
33
  cmbntns = []
40
- combinations = Fitting::Cover::JSONSchema.new(body).combi + Fitting::Cover::JSONSchemaEnum.new(body).combi + Fitting::Cover::JSONSchemaOneOf.new(body).combi
34
+ combinations = Fitting::Cover::JSONSchema.new(body).combi +
35
+ Fitting::Cover::JSONSchemaEnum.new(body).combi +
36
+ Fitting::Cover::JSONSchemaOneOf.new(body).combi
41
37
  if combinations != []
42
38
  combinations.map do |combination|
43
39
  cmbntns.push(
44
- Fitting::Report::Combination.new(
45
- json_schema: combination[0],
46
- type: combination[1][0],
47
- combination: combination[1][1]
48
- )
40
+ Fitting::Report::Combination.new(
41
+ json_schema: combination[0],
42
+ type: combination[1][0],
43
+ combination: combination[1][1]
44
+ )
49
45
  )
50
46
  end
51
47
  end
@@ -54,16 +50,19 @@ module Fitting
54
50
  end
55
51
 
56
52
  def cover_percent
57
- return '0%' if @tests.size == 0
58
- return '100%' if @combinations.size == 0
53
+ return '0%' if @tests.size.zero?
54
+ return '100%' if @combinations.size.zero?
55
+
59
56
  "#{(@combinations.size_with_tests + 1) * 100 / (@combinations.size + 1)}%"
60
57
  end
61
58
 
62
59
  def details
63
60
  {
64
- cover_percent: cover_percent,
65
- tests_without_combinations: @tests.without_combinations,
66
- combinations_details: @combinations.to_a.map { |c| {json_schema: c.id, tests_size: c.tests.size, type: c.type, name: c.name} }
61
+ cover_percent: cover_percent,
62
+ tests_without_combinations: @tests.without_combinations,
63
+ combinations_details: @combinations.to_a.map do |c|
64
+ { json_schema: c.id, tests_size: c.tests.size, type: c.type, name: c.name }
65
+ end
67
66
  }
68
67
  end
69
68
  end
@@ -17,18 +17,19 @@ module Fitting
17
17
 
18
18
  def join(tests)
19
19
  tests.to_a.map do |test|
20
- if is_there_a_suitable_response?(test)
20
+ if there_a_suitable_response?(test)
21
21
  cram_into_the_appropriate_response(test)
22
22
  test.mark_response
23
23
  end
24
24
  end
25
25
  end
26
26
 
27
- def is_there_a_suitable_response?(test)
27
+ def there_a_suitable_response?(test)
28
28
  return false if @responses.nil?
29
+
29
30
  @responses.map do |response|
30
31
  return true if response.status.to_s == test.status &&
31
- JSON::Validator.fully_validate(response.body, test.body) == []
32
+ JSON::Validator.fully_validate(response.body, test.body) == []
32
33
  end
33
34
 
34
35
  false
@@ -36,11 +37,11 @@ module Fitting
36
37
 
37
38
  def cram_into_the_appropriate_response(test)
38
39
  @responses.map do |response|
39
- if response.status.to_s == test.status &&
40
- JSON::Validator.fully_validate(response.body, test.body) == []
41
- response.add_test(test)
42
- return
43
- end
40
+ next unless response.status.to_s == test.status &&
41
+ JSON::Validator.fully_validate(response.body, test.body) == []
42
+
43
+ response.add_test(test)
44
+ break
44
45
  end
45
46
  end
46
47
  end
@@ -10,16 +10,14 @@ module Fitting
10
10
  @id = SecureRandom.hex
11
11
  end
12
12
 
13
- def id
14
- @id
15
- end
13
+ attr_reader :id
16
14
 
17
15
  def to_h
18
16
  {
19
- path: path,
20
- method: method,
21
- status: status,
22
- body: body
17
+ path: path,
18
+ method: method,
19
+ status: status,
20
+ body: body
23
21
  }
24
22
  end
25
23
 
@@ -55,19 +53,19 @@ module Fitting
55
53
  @combination = true
56
54
  end
57
55
 
58
- def is_there_a_prefix?
56
+ def there_a_prefix?
59
57
  @prefix
60
58
  end
61
59
 
62
- def is_there_an_actions?
60
+ def there_an_actions?
63
61
  @action
64
62
  end
65
63
 
66
- def is_there_an_responses?
64
+ def there_an_responses?
67
65
  @response
68
66
  end
69
67
 
70
- def is_there_an_combinations?
68
+ def there_an_combinations?
71
69
  @combination
72
70
  end
73
71
  end
@@ -10,7 +10,7 @@ module Fitting
10
10
  def self.new_from_config(tests_path)
11
11
  tests = []
12
12
  Dir[tests_path].each do |file|
13
- JSON.load(File.read(file)).map do |test|
13
+ JSON.parse(File.read(file)).map do |test|
14
14
  tests.push(Fitting::Report::Test.new(test))
15
15
  end
16
16
  end
@@ -19,30 +19,26 @@ module Fitting
19
19
  end
20
20
 
21
21
  def without_prefixes
22
- @tests.inject([]) do |result, test|
23
- result.push(test.path) unless test.is_there_a_prefix?
24
- result
22
+ @tests.each_with_object([]) do |test, result|
23
+ result.push(test.path) unless test.there_a_prefix?
25
24
  end
26
25
  end
27
26
 
28
27
  def without_actions
29
- @tests.inject([]) do |result, test|
30
- result.push("#{test.method} #{test.path}") unless test.is_there_an_actions?
31
- result
28
+ @tests.each_with_object([]) do |test, result|
29
+ result.push("#{test.method} #{test.path}") unless test.there_an_actions?
32
30
  end
33
31
  end
34
32
 
35
33
  def without_responses
36
- @tests.inject([]) do |result, test|
37
- result.push(test.id) unless test.is_there_an_responses?
38
- result
34
+ @tests.each_with_object([]) do |test, result|
35
+ result.push(test.id) unless test.there_an_responses?
39
36
  end
40
37
  end
41
38
 
42
39
  def without_combinations
43
- @tests.inject([]) do |result, test|
44
- result.push(test.path) unless test.is_there_an_combinations?
45
- result
40
+ @tests.each_with_object([]) do |test, result|
41
+ result.push(test.path) unless test.there_an_combinations?
46
42
  end
47
43
  end
48
44
 
@@ -60,6 +56,7 @@ module Fitting
60
56
 
61
57
  def to_h
62
58
  return @hash if @hash
59
+
63
60
  @hash = @tests.inject({}) do |res, test|
64
61
  res.merge!(test.id => test.to_h)
65
62
  end
@@ -7,7 +7,6 @@ module Fitting
7
7
  @path = env_request.env['PATH_INFO'] || env_request.fullpath
8
8
  @body = env_request.env['action_dispatch.request.request_parameters']
9
9
  @schema = tomogram.find_request(method: @method, path: @path)
10
- self
11
10
  end
12
11
 
13
12
  def route
@@ -1,7 +1,6 @@
1
1
  require 'fitting/request'
2
2
  require 'fitting/response/fully_validates'
3
3
  require 'json'
4
- require 'multi_json'
5
4
 
6
5
  module Fitting
7
6
  class Response
@@ -27,7 +26,7 @@ module Fitting
27
26
  end
28
27
 
29
28
  def documented?
30
- @schemas && @schemas.present?
29
+ @schemas&.present?
31
30
  end
32
31
 
33
32
  def route
@@ -47,7 +46,7 @@ module Fitting
47
46
  end
48
47
 
49
48
  def got
50
- JSON.pretty_generate(MultiJson.load(@body))
49
+ JSON.pretty_generate(JSON.parse(@body))
51
50
  end
52
51
 
53
52
  def expected
@@ -68,6 +67,7 @@ module Fitting
68
67
 
69
68
  def index
70
69
  return @index_res if @index_res
70
+
71
71
  @index_res = []
72
72
  @schemas.size.times do |i|
73
73
  @index_res.push(i) if fully_validates[i] == []
@@ -77,6 +77,7 @@ module Fitting
77
77
 
78
78
  def strict_index
79
79
  return @strict_index_res if @strict_index_res
80
+
80
81
  @strict_index_res = []
81
82
  @schemas.size.times do |i|
82
83
  @strict_index_res.push(i) if strict_fully_validates[i] == []
@@ -10,9 +10,11 @@ module Fitting
10
10
  @request_unit.map do |request|
11
11
  request.responses.map do |response|
12
12
  next unless response.tested_bodies != []
13
+
13
14
  response.json_schemas.map do |json_schema|
14
15
  json_schema.combinations.map do |combination|
15
16
  next unless combination.valid_bodies == []
17
+
16
18
  res += "request method: #{request.method}\nrequest path: #{request.path}\n"\
17
19
  "response status: #{response.status}\nsource json-schema: #{json_schema.json_schema}\n"\
18
20
  "combination: #{combination.description}\nnew json-schema: #{combination.json_schema}\n\n"
@@ -10,9 +10,11 @@ module Fitting
10
10
  @request_unit.map do |request|
11
11
  request.responses.map do |response|
12
12
  next unless response.tested_bodies != []
13
+
13
14
  response.json_schemas.map do |json_schema|
14
15
  json_schema.combinations_with_enum.map do |combination|
15
16
  next unless combination.valid_bodies == []
17
+
16
18
  res += "request method: #{request.method}\nrequest path: #{request.path}\n"\
17
19
  "response status: #{response.status}\nsource json-schema: #{json_schema.json_schema}\n"\
18
20
  "combination: #{combination.description}\nnew json-schema: #{combination.json_schema}\n\n"
@@ -10,9 +10,11 @@ module Fitting
10
10
  @request_unit.map do |request|
11
11
  request.responses.map do |response|
12
12
  next unless response.tested_bodies != []
13
+
13
14
  response.json_schemas.map do |json_schema|
14
15
  json_schema.combinations_with_one_of.map do |combination|
15
16
  next unless combination.valid_bodies == []
17
+
16
18
  res += "request method: #{request.method}\nrequest path: #{request.path}\n"\
17
19
  "response status: #{response.status}\nsource json-schema: #{json_schema.json_schema}\n"\
18
20
  "combination: #{combination.description}\nnew json-schema: #{combination.json_schema}\n\n"
@@ -35,17 +35,18 @@ module Fitting
35
35
  end
36
36
 
37
37
  def json_schema_stat(res, json_schema, response)
38
- if @depth == 'valid'
38
+ case @depth
39
+ when 'valid'
39
40
  if json_schema.bodies == []
40
41
  res.push("✖ #{response.status}")
41
42
  else
42
43
  res.push("✔ #{response.status}")
43
44
  end
44
- elsif @depth == 'cover'
45
+ when 'cover'
45
46
  res.push("#{json_schema.cover}% #{response.status}")
46
- elsif @depth == 'cover_enum'
47
+ when 'cover_enum'
47
48
  res.push("#{json_schema.cover_enum}% #{response.status}")
48
- elsif @depth == 'cover_one_of'
49
+ when 'cover_one_of'
49
50
  res.push("#{json_schema.cover_one_of}% #{response.status}")
50
51
  end
51
52
  end
@@ -6,7 +6,7 @@ module Fitting
6
6
  end
7
7
 
8
8
  def to_s
9
- @measurement.not_covered_responses.join("\n") + "\n"
9
+ "#{@measurement.not_covered_responses.join("\n")}\n"
10
10
  end
11
11
  end
12
12
  end
@@ -8,7 +8,8 @@ module Fitting
8
8
 
9
9
  def to_f
10
10
  return 0.to_f if @divider.zero?
11
- (@dividend.to_f / @divider.to_f * 100.0).round(2)
11
+
12
+ (@dividend.to_f / @divider * 100.0).round(2)
12
13
  end
13
14
 
14
15
  def to_s
@@ -48,26 +48,28 @@ module Fitting
48
48
 
49
49
  def white_measurement
50
50
  @white_measurement ||=
51
- if @depth == 'valid'
51
+ case @depth
52
+ when 'valid'
52
53
  Fitting::Statistics::Measurement.new(white_unit)
53
- elsif @depth == 'cover'
54
+ when 'cover'
54
55
  Fitting::Statistics::MeasurementCover.new(white_unit)
55
- elsif @depth == 'cover_enum'
56
+ when 'cover_enum'
56
57
  Fitting::Statistics::MeasurementCoverEnum.new(white_unit)
57
- elsif @depth == 'cover_one_of'
58
+ when 'cover_one_of'
58
59
  Fitting::Statistics::MeasurementCoverOneOf.new(white_unit)
59
60
  end
60
61
  end
61
62
 
62
63
  def black_measurement
63
64
  @black_measurement ||=
64
- if @depth == 'valid'
65
+ case @depth
66
+ when 'valid'
65
67
  Fitting::Statistics::Measurement.new(black_unit)
66
- elsif @depth == 'cover'
68
+ when 'cover'
67
69
  Fitting::Statistics::MeasurementCover.new(black_unit)
68
- elsif @depth == 'cover_enum'
70
+ when 'cover_enum'
69
71
  Fitting::Statistics::MeasurementCoverEnum.new(black_unit)
70
- elsif @depth == 'cover_one_of'
72
+ when 'cover_one_of'
71
73
  Fitting::Statistics::MeasurementCoverOneOf.new(black_unit)
72
74
  end
73
75
  end
@@ -9,8 +9,8 @@ module Fitting
9
9
  @tested_requests = []
10
10
  end
11
11
 
12
- def add(env_response, test_title = '')
13
- @tested_requests.push(Fitting::Records::Tested::Request.new(env_response, test_title))
12
+ def add(env_response, metadata = {})
13
+ @tested_requests.push(Fitting::Records::Tested::Request.new(env_response, metadata))
14
14
  end
15
15
 
16
16
  def statistics