fitting 2.15.0 → 2.18.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +3 -3
  3. data/.rubocop.yml +31 -3
  4. data/CHANGELOG.md +21 -0
  5. data/README.md +96 -281
  6. data/fitting.gemspec +10 -10
  7. data/images/example.png +0 -0
  8. data/images/example2.png +0 -0
  9. data/images/logo.png +0 -0
  10. data/lib/fitting/configuration/legacy.rb +6 -5
  11. data/lib/fitting/configuration/yaml.rb +2 -2
  12. data/lib/fitting/cover/json_schema.rb +3 -2
  13. data/lib/fitting/cover/json_schema_enum.rb +1 -1
  14. data/lib/fitting/cover/json_schema_one_of.rb +1 -1
  15. data/lib/fitting/cover/response.rb +1 -5
  16. data/lib/fitting/documentation.rb +0 -2
  17. data/lib/fitting/matchers/response_matcher.rb +2 -1
  18. data/lib/fitting/records/documented/request.rb +1 -0
  19. data/lib/fitting/records/realized_unit.rb +13 -15
  20. data/lib/fitting/records/spherical/request.rb +1 -1
  21. data/lib/fitting/records/spherical/requests.rb +2 -1
  22. data/lib/fitting/records/spherical/response.rb +2 -2
  23. data/lib/fitting/records/test_unit/request.rb +4 -0
  24. data/lib/fitting/records/tested/request.rb +1 -1
  25. data/lib/fitting/records/unit/combination.rb +5 -6
  26. data/lib/fitting/records/unit/json_schema.rb +38 -33
  27. data/lib/fitting/records/unit/request.rb +1 -0
  28. data/lib/fitting/records/unit/response.rb +1 -0
  29. data/lib/fitting/report/action.rb +6 -9
  30. data/lib/fitting/report/actions.rb +8 -10
  31. data/lib/fitting/report/combination.rb +1 -15
  32. data/lib/fitting/report/combinations.rb +5 -6
  33. data/lib/fitting/report/console.rb +5 -4
  34. data/lib/fitting/report/prefix.rb +46 -20
  35. data/lib/fitting/report/prefixes.rb +17 -5
  36. data/lib/fitting/report/response.rb +19 -20
  37. data/lib/fitting/report/responses.rb +9 -8
  38. data/lib/fitting/report/test.rb +9 -11
  39. data/lib/fitting/report/tests.rb +10 -13
  40. data/lib/fitting/request.rb +0 -1
  41. data/lib/fitting/response.rb +4 -3
  42. data/lib/fitting/statistics/cover_error.rb +2 -0
  43. data/lib/fitting/statistics/cover_error_enum.rb +2 -0
  44. data/lib/fitting/statistics/cover_error_one_of.rb +2 -0
  45. data/lib/fitting/statistics/list.rb +5 -4
  46. data/lib/fitting/statistics/not_covered_responses.rb +1 -1
  47. data/lib/fitting/statistics/percent.rb +2 -1
  48. data/lib/fitting/statistics/template.rb +10 -8
  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 +5 -2
  54. data/lib/tasks/fitting.rake +62 -54
  55. data/lib/templates/bomboniere/package-lock.json +91 -70
  56. data/lib/templates/bomboniere/package.json +2 -1
  57. data/lib/templates/bomboniere/src/components/HelloWorld.vue +3 -0
  58. metadata +34 -56
@@ -1,5 +1,3 @@
1
- require 'multi_json'
2
-
3
1
  module Fitting
4
2
  class Documentation
5
3
  def initialize(tomogram, white_list)
@@ -39,7 +39,8 @@ module Fitting
39
39
  if response.within_prefix?(config.prefix)
40
40
  @response = response
41
41
  return true if @response.ignored?(config.ignore_list)
42
- return @response.fully_validates.valid?
42
+
43
+ @response.fully_validates.valid?
43
44
  else
44
45
  true
45
46
  end
@@ -35,6 +35,7 @@ module Fitting
35
35
  return false if @white_list[path.to_s] == nil
36
36
  return true if @white_list[path.to_s] == []
37
37
  return true if @white_list[path.to_s].include?(method)
38
+
38
39
  false
39
40
  end
40
41
 
@@ -9,27 +9,25 @@ module Fitting
9
9
  end
10
10
 
11
11
  def fully_covered?
12
+ all_good_documented = false
13
+ all_good_response_documented = false
14
+ all_good_response_json_schemas = false
15
+ all_good_valid_json_schemas = false
16
+
12
17
  test_file_paths.each do |_key, requests|
13
- all_good = requests.all?(&:documented?)
14
- return false unless all_good
15
- end
16
- test_file_paths.each do |_key, requests|
17
- all_good = requests.all?(&:response_documented?)
18
- return false unless all_good
19
- end
20
- test_file_paths.each do |_key, requests|
21
- all_good = requests.all?(&:response_json_schemas?)
22
- return false unless all_good
23
- end
24
- test_file_paths.each do |_key, requests|
25
- all_good = requests.all?(&:valid_json_schemas?)
26
- return false unless all_good
18
+ all_good_documented = requests.all?(&:documented?)
19
+ all_good_response_documented = requests.all?(&:response_documented?)
20
+ all_good_response_json_schemas = requests.all?(&:response_json_schemas?)
21
+ all_good_valid_json_schemas = requests.all?(&:valid_json_schemas?)
27
22
  end
28
- true
23
+
24
+ all_good_documented && all_good_response_documented &&
25
+ all_good_response_json_schemas && all_good_valid_json_schemas
29
26
  end
30
27
 
31
28
  def test_file_paths
32
29
  return @test_file_paths if @test_file_paths
30
+
33
31
  @test_file_paths = {}
34
32
  white_unit.map do |request|
35
33
  @test_file_paths[request.test_file_path] ||= []
@@ -27,7 +27,7 @@ module Fitting
27
27
  }
28
28
  end
29
29
 
30
- def to_json
30
+ def to_json(*_args)
31
31
  JSON.dump(to_hash)
32
32
  end
33
33
 
@@ -10,11 +10,12 @@ module Fitting
10
10
 
11
11
  array = []
12
12
  Dir['fitting_tests/*.json'].each do |file|
13
- array += JSON.load(File.read(file))
13
+ array += JSON.parse(File.read(file))
14
14
  end
15
15
  @to_a = array.inject([]) do |res, tested_request|
16
16
  request = Fitting::Records::Spherical::Request.load(tested_request)
17
17
  next res unless request.path.to_s.start_with?(Fitting.configuration.prefix)
18
+
18
19
  res.push(request)
19
20
  end
20
21
  end
@@ -14,7 +14,7 @@ module Fitting
14
14
  def to_hash
15
15
  {
16
16
  status: status,
17
- body: JSON.load(body)
17
+ body: JSON.parse(body)
18
18
  }
19
19
  rescue JSON::ParserError
20
20
  {
@@ -23,7 +23,7 @@ module Fitting
23
23
  }
24
24
  end
25
25
 
26
- def to_json
26
+ def to_json(*_args)
27
27
  JSON.dump(to_hash)
28
28
  end
29
29
 
@@ -37,6 +37,7 @@ module Fitting
37
37
  @documented_requests ||= @all_documented_requests.inject([]) do |res, documented_request|
38
38
  next res unless @tested_request.method == documented_request.method &&
39
39
  documented_request.path.match(@tested_request.path.to_s)
40
+
40
41
  res.push(documented_request)
41
42
  end
42
43
  end
@@ -49,6 +50,7 @@ module Fitting
49
50
  @documented_responses ||= documented_requests.inject([]) do |res, documented_request|
50
51
  documented_request.responses.map do |documented_response|
51
52
  next unless documented_response['status'] == response.status.to_s
53
+
52
54
  res.push(documented_response)
53
55
  end
54
56
  end.flatten.compact
@@ -71,6 +73,7 @@ module Fitting
71
73
  def valid_json_schemas
72
74
  @valid_json_schemas ||= response_json_schemas.inject([]) do |res, json_schema|
73
75
  next res unless JSON::Validator.validate(json_schema, response.body)
76
+
74
77
  res.push(json_schema)
75
78
  end.flatten
76
79
  end
@@ -78,6 +81,7 @@ module Fitting
78
81
  def invalid_json_schemas
79
82
  @invalid_json_schemas ||= response_json_schemas.inject([]) do |res, json_schema|
80
83
  next res if JSON::Validator.validate(json_schema, response.body)
84
+
81
85
  res.push(
82
86
  json_schema: json_schema,
83
87
  fully_validate: JSON::Validator.fully_validate(json_schema, response.body)
@@ -28,7 +28,7 @@ module Fitting
28
28
  end
29
29
 
30
30
  def test_path
31
- @test_path ||= @test_title[/#{'\(\.'}(.*?)#{'\)'}/m, 1] || @test_title[/#{'\.'}(.*?)#{'\"'}/m, 1]
31
+ @test_path ||= @test_title[/\\(\\.(.*?)\\)/m, 1] || @test_title[/\\.(.*?)\\"/m, 1]
32
32
  end
33
33
 
34
34
  def test_file_path
@@ -14,12 +14,11 @@ module Fitting
14
14
 
15
15
  def valid_bodies
16
16
  @valid_bodies ||= @bodies.inject([]) do |res, tested_body|
17
- begin
18
- next res unless JSON::Validator.validate(@json_schema, tested_body)
19
- res.push(tested_body)
20
- rescue JSON::Schema::UriError
21
- res.push(tested_body)
22
- end
17
+ next res unless JSON::Validator.validate(@json_schema, tested_body)
18
+
19
+ res.push(tested_body)
20
+ rescue JSON::Schema::UriError
21
+ res.push(tested_body)
23
22
  end
24
23
  end
25
24
  end
@@ -17,50 +17,55 @@ module Fitting
17
17
 
18
18
  def bodies
19
19
  @bodies ||= @tested_bodies.inject([]) do |res, tested_body|
20
- begin
21
- next res unless JSON::Validator.validate(@json_schema, tested_body)
22
- res.push(tested_body)
23
- rescue JSON::Schema::UriError
24
- res.push(tested_body)
25
- end
20
+ next res unless JSON::Validator.validate(@json_schema, tested_body)
21
+
22
+ res.push(tested_body)
23
+ rescue JSON::Schema::UriError
24
+ res.push(tested_body)
26
25
  end
27
26
  end
28
27
 
29
28
  def combinations
30
29
  return @combinations if @combinations
30
+
31
31
  @combinations = []
32
32
  cover_json_schema = Fitting::Cover::JSONSchema.new(@json_schema)
33
33
  cover_json_schema.combi.map do |comb|
34
34
  @combinations.push(Fitting::Records::Unit::Combination.new(
35
- comb,
36
- bodies
37
- ))
35
+ comb,
36
+ bodies
37
+ ))
38
38
  end
39
39
  @combinations
40
40
  end
41
41
 
42
42
  def combinations_with_enum
43
43
  return @combinations_with_enum if @combinations_with_enum
44
+
44
45
  @combinations_with_enum = []
45
- qwe = Fitting::Cover::JSONSchema.new(@json_schema).combi + Fitting::Cover::JSONSchemaEnum.new(@json_schema).combi
46
+ qwe = Fitting::Cover::JSONSchema.new(@json_schema).combi +
47
+ Fitting::Cover::JSONSchemaEnum.new(@json_schema).combi
46
48
  qwe.map do |comb|
47
49
  @combinations_with_enum.push(Fitting::Records::Unit::Combination.new(
48
- comb,
49
- bodies
50
- ))
50
+ comb,
51
+ bodies
52
+ ))
51
53
  end
52
54
  @combinations_with_enum
53
55
  end
54
56
 
55
57
  def combinations_with_one_of
56
58
  return @combinations_with_one_of if @combinations_with_one_of
59
+
57
60
  @combinations_with_one_of = []
58
- qwe = Fitting::Cover::JSONSchema.new(@json_schema).combi + Fitting::Cover::JSONSchemaEnum.new(@json_schema).combi + Fitting::Cover::JSONSchemaOneOf.new(@json_schema).combi
61
+ qwe = Fitting::Cover::JSONSchema.new(@json_schema).combi +
62
+ Fitting::Cover::JSONSchemaEnum.new(@json_schema).combi +
63
+ Fitting::Cover::JSONSchemaOneOf.new(@json_schema).combi
59
64
  qwe.map do |comb|
60
65
  @combinations_with_one_of.push(Fitting::Records::Unit::Combination.new(
61
- comb,
62
- bodies
63
- ))
66
+ comb,
67
+ bodies
68
+ ))
64
69
  end
65
70
  @combinations_with_one_of
66
71
  end
@@ -79,26 +84,26 @@ module Fitting
79
84
 
80
85
  def cover_enum
81
86
  @cover_enum ||= if bodies == []
82
- 0
83
- else
84
- count = 0
85
- combinations_with_enum.map do |combination|
86
- count += 1 unless combination.valid_bodies == []
87
- end
88
- (count + 1) * 100 / (combinations_with_enum.size + 1)
89
- end
87
+ 0
88
+ else
89
+ count = 0
90
+ combinations_with_enum.map do |combination|
91
+ count += 1 unless combination.valid_bodies == []
92
+ end
93
+ (count + 1) * 100 / (combinations_with_enum.size + 1)
94
+ end
90
95
  end
91
96
 
92
97
  def cover_one_of
93
98
  @cover_one_of ||= if bodies == []
94
- 0
95
- else
96
- count = 0
97
- combinations_with_one_of.map do |combination|
98
- count += 1 unless combination.valid_bodies == []
99
- end
100
- (count + 1) * 100 / (combinations_with_one_of.size + 1)
101
- end
99
+ 0
100
+ else
101
+ count = 0
102
+ combinations_with_one_of.map do |combination|
103
+ count += 1 unless combination.valid_bodies == []
104
+ end
105
+ (count + 1) * 100 / (combinations_with_one_of.size + 1)
106
+ end
102
107
  end
103
108
  end
104
109
  end
@@ -27,6 +27,7 @@ module Fitting
27
27
  @tested_responses ||= @tested_requests.to_a.inject([]) do |res, tested_request|
28
28
  next res unless @documented_request.method == tested_request.method &&
29
29
  @documented_request.path.match(tested_request.path.to_s)
30
+
30
31
  res.push(tested_request.response)
31
32
  end
32
33
  end
@@ -22,6 +22,7 @@ module Fitting
22
22
  def tested_bodies
23
23
  @tested_bodies ||= @tested_responses.inject([]) do |res, tested_response|
24
24
  next res unless status == tested_response.status.to_s
25
+
25
26
  res.push(tested_response.body)
26
27
  end
27
28
  end
@@ -17,9 +17,7 @@ module Fitting
17
17
  @action.path.to_s
18
18
  end
19
19
 
20
- def responses
21
- @responses
22
- end
20
+ attr_reader :responses, :tests
23
21
 
24
22
  def add_test(test)
25
23
  @tests.push(test)
@@ -38,14 +36,13 @@ module Fitting
38
36
  @regexp = Regexp.new(str)
39
37
  end
40
38
 
41
- def tests
42
- @tests
43
- end
44
-
45
39
  def details
46
40
  {
47
- tests_without_responses: @tests.without_responses,
48
- responses_details: @responses.to_a.map { |r| {method: r.status, tests_size: r.tests.size, json_schema: r.id, combinations: r.details} }
41
+ tests_without_responses: @tests.without_responses,
42
+ responses_details: @responses.to_a.map do |r|
43
+ { method: r.status, tests_size: r.tests.size, json_schema: r.id,
44
+ combinations: r.details }
45
+ end
49
46
  }
50
47
  end
51
48
  end
@@ -3,11 +3,7 @@ require 'fitting/report/action'
3
3
  module Fitting
4
4
  module Report
5
5
  class Actions
6
- def initialize(prefix, tomogram_json_path)
7
- actions = Tomograph::Tomogram.new(
8
- prefix: prefix,
9
- tomogram_json_path: tomogram_json_path
10
- )
6
+ def initialize(actions)
11
7
  @actions = []
12
8
  actions.to_a.map do |action|
13
9
  @actions.push(Fitting::Report::Action.new(action))
@@ -20,14 +16,14 @@ module Fitting
20
16
 
21
17
  def join(tests)
22
18
  tests.to_a.map do |test|
23
- if is_there_a_suitable_action?(test)
19
+ if there_a_suitable_action?(test)
24
20
  cram_into_the_appropriate_action(test)
25
21
  test.mark_action
26
22
  end
27
23
  end
28
24
  end
29
25
 
30
- def is_there_a_suitable_action?(test)
26
+ def there_a_suitable_action?(test)
31
27
  @actions.map do |action|
32
28
  return true if test.method == action.method && action.path_match(test.path)
33
29
  end
@@ -39,15 +35,17 @@ module Fitting
39
35
  @actions.map do |action|
40
36
  if test.method == action.method && action.path_match(test.path)
41
37
  action.add_test(test)
42
- return
38
+ break
43
39
  end
44
40
  end
45
41
  end
46
42
 
47
43
  def details(prefix)
48
44
  {
49
- tests_without_actions: prefix.tests.without_actions,
50
- 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
51
49
  }
52
50
  end
53
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
@@ -14,20 +14,21 @@ module Fitting
14
14
  end
15
15
 
16
16
  def size_with_tests
17
- @combinations.count { |c| c.tests.size != 0 }
17
+ @combinations.count { |c| !c.tests.empty? }
18
18
  end
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
@@ -15,7 +15,7 @@ module Fitting
15
15
  @tests_without_actions += prefix_details[:actions][:tests_without_actions]
16
16
  res += prefix_details[:actions][:actions_details].inject('') do |res_actions, action|
17
17
  res_actions += "#{action[:method]}\t#{action[:path]}"
18
- tab = "\t" * ((3 - action[:path].size / 8) + 3)
18
+ tab = "\t" * (8 - action[:path].size / 8)
19
19
  @tests_without_responses += action[:responses][:tests_without_responses]
20
20
  res_actions += tab + action[:responses][:responses_details].inject('') do |res_responses, response|
21
21
  @good = false if response[:combinations][:cover_percent] != '100%'
@@ -31,9 +31,10 @@ module Fitting
31
31
  end
32
32
 
33
33
  def good?
34
- return false if @tests_without_prefixes.size != 0
35
- return false if @tests_without_actions.size != 0
36
- return false if @tests_without_responses.size != 0
34
+ return false unless @tests_without_prefixes.empty?
35
+ return false unless @tests_without_actions.empty?
36
+ return false unless @tests_without_responses.empty?
37
+
37
38
  @good
38
39
  end
39
40
  end
@@ -3,44 +3,70 @@ require 'fitting/report/actions'
3
3
  module Fitting
4
4
  module Report
5
5
  class Prefix
6
- def initialize(name, tomogram_json_path, 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 = Fitting::Report::Actions.new(name, tomogram_json_path)
13
- end
14
- end
12
+ return if skip
15
13
 
16
- def name
17
- @name
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
18
50
  end
19
51
 
20
- def tests
21
- @tests
22
- end
52
+ attr_reader :name, :tests, :actions
23
53
 
24
54
  def skip?
25
55
  @skip
26
56
  end
27
57
 
28
- def actions
29
- @actions
30
- end
31
-
32
58
  def details
33
59
  if @skip
34
60
  {
35
- name: @name,
36
- tests_size: @tests.size,
37
- actions: {tests_without_actions: [], actions_details: []}
61
+ name: @name,
62
+ tests_size: @tests.size,
63
+ actions: { tests_without_actions: [], actions_details: [] }
38
64
  }
39
65
  else
40
66
  {
41
- name: @name,
42
- tests_size: @tests.size,
43
- actions: @actions.details(self)
67
+ name: @name,
68
+ tests_size: @tests.size,
69
+ actions: @actions.details(self)
44
70
  }
45
71
  end
46
72
  end
@@ -6,12 +6,24 @@ module Fitting
6
6
  def initialize(config_path)
7
7
  @prefixes = []
8
8
  YAML.safe_load(File.read(config_path))['prefixes'].map do |prefix|
9
- @prefixes.push(Fitting::Report::Prefix.new(prefix['name'], prefix['tomogram_json_path'], prefix['skip']))
9
+ @prefixes.push(
10
+ Fitting::Report::Prefix.new(
11
+ 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']
18
+ )
19
+ )
10
20
  end
11
21
  end
12
22
 
13
- def is_there_a_suitable_prefix?(test_path)
23
+ def there_a_suitable_prefix?(test_path)
14
24
  @prefixes.map do |prefix|
25
+ return true if prefix.name.nil?
26
+ return true if prefix.name == ''
15
27
  return true if test_path[0..prefix.name.size - 1] == prefix.name
16
28
  end
17
29
 
@@ -20,16 +32,16 @@ module Fitting
20
32
 
21
33
  def cram_into_the_appropriate_prefix(test)
22
34
  @prefixes.map do |prefix|
23
- 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
24
36
  prefix.add_test(test)
25
- return
37
+ break
26
38
  end
27
39
  end
28
40
  end
29
41
 
30
42
  def join(tests)
31
43
  tests.to_a.map do |test|
32
- if is_there_a_suitable_prefix?(test.path)
44
+ if there_a_suitable_prefix?(test.path)
33
45
  cram_into_the_appropriate_prefix(test)
34
46
  test.mark_prefix
35
47
  end