defmastership 1.0.17 → 1.0.19

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.gitlab-ci.yml +37 -11
  4. data/Gemfile +71 -1
  5. data/Guardfile +44 -0
  6. data/Rakefile +16 -61
  7. data/bin/defmastership +9 -6
  8. data/config/cucumber.yml +3 -0
  9. data/config/mutant.yml +27 -3
  10. data/config/reek.yml +129 -105
  11. data/config/rubocop.yml +72 -28
  12. data/defmastership.gemspec +5 -13
  13. data/features/changeref.feature +0 -8
  14. data/features/definition_checksum.feature +30 -10
  15. data/features/definition_version.feature +168 -10
  16. data/features/export.feature +64 -17
  17. data/features/modify.feature +1 -5
  18. data/features/rename_included_files.feature +27 -4
  19. data/features/step_definitions/git_steps.rb +19 -0
  20. data/lib/defmastership/batch_modifier.rb +17 -12
  21. data/lib/defmastership/change_ref_modifier.rb +88 -6
  22. data/lib/defmastership/comment_filter.rb +1 -1
  23. data/lib/defmastership/constants.rb +10 -7
  24. data/lib/defmastership/csv_formatter.rb +16 -12
  25. data/lib/defmastership/csv_formatter_body.rb +18 -15
  26. data/lib/defmastership/csv_formatter_header.rb +1 -1
  27. data/lib/defmastership/definition.rb +59 -20
  28. data/lib/defmastership/document.rb +101 -74
  29. data/lib/defmastership/matching_line.rb +17 -0
  30. data/lib/defmastership/modifier.rb +42 -0
  31. data/lib/defmastership/modifier_factory.rb +12 -0
  32. data/lib/defmastership/parsing_state.rb +15 -9
  33. data/lib/defmastership/rename_included_files_modifier.rb +172 -5
  34. data/lib/defmastership/set_join_hack.rb +11 -0
  35. data/lib/defmastership/update_def_checksum_modifier.rb +8 -13
  36. data/lib/defmastership/update_def_modifier.rb +49 -0
  37. data/lib/defmastership/update_def_version_modifier.rb +81 -15
  38. data/lib/defmastership/version.rb +1 -1
  39. data/lib/defmastership.rb +1 -6
  40. data/spec/spec_helper.rb +3 -1
  41. data/spec/unit/def_mastership/batch_modifier_spec.rb +40 -36
  42. data/spec/unit/def_mastership/change_ref_modifier_spec.rb +196 -51
  43. data/spec/unit/def_mastership/csv_formatter_body_spec.rb +60 -31
  44. data/spec/unit/def_mastership/csv_formatter_header_spec.rb +1 -1
  45. data/spec/unit/def_mastership/csv_formatter_spec.rb +79 -87
  46. data/spec/unit/def_mastership/definition_parser_spec.rb +1 -1
  47. data/spec/unit/def_mastership/definition_spec.rb +16 -6
  48. data/spec/unit/def_mastership/document_spec.rb +81 -38
  49. data/spec/unit/def_mastership/matching_line_spec.rb +37 -0
  50. data/spec/unit/def_mastership/modifier_factory_spec.rb +38 -0
  51. data/spec/unit/def_mastership/modifier_spec.rb +85 -0
  52. data/spec/unit/def_mastership/parsing_state_spec.rb +1 -1
  53. data/spec/unit/def_mastership/rename_included_files_modifier_spec.rb +219 -47
  54. data/spec/unit/def_mastership/string_spec.rb +1 -1
  55. data/spec/unit/def_mastership/update_def_checksum_modifier_spec.rb +82 -50
  56. data/spec/unit/def_mastership/update_def_modifier_spec.rb +121 -0
  57. data/spec/unit/def_mastership/update_def_version_modifier_spec.rb +327 -56
  58. data/tasks/code_quality.rake +74 -0
  59. data/tasks/console.rake +8 -0
  60. data/tasks/package.task +9 -0
  61. data/tasks/test.rake +30 -0
  62. metadata +33 -145
  63. data/.rubocop.yml +0 -76
  64. data/config/devtools.yml +0 -2
  65. data/config/flay.yml +0 -3
  66. data/config/flog.yml +0 -2
  67. data/config/yardstick.yml +0 -2
  68. data/cucumber.yml +0 -2
  69. data/lib/defmastership/change_ref_line_modifier.rb +0 -85
  70. data/lib/defmastership/line_modifier_base.rb +0 -29
  71. data/lib/defmastership/modifier_base.rb +0 -36
  72. data/lib/defmastership/rename_included_files_line_modifier.rb +0 -126
  73. data/lib/defmastership/update_def_checksum_line_modifier.rb +0 -38
  74. data/lib/defmastership/update_def_version_line_modifier.rb +0 -58
  75. data/spec/unit/def_mastership/change_ref_line_modifier_spec.rb +0 -250
  76. data/spec/unit/def_mastership/rename_included_files_line_modifier_spec.rb +0 -207
  77. data/spec/unit/def_mastership/update_def_checksum_line_modifier_spec.rb +0 -82
  78. data/spec/unit/def_mastership/update_def_version_line_modifier_spec.rb +0 -131
  79. /data/{.rspec → config/rspec} +0 -0
@@ -1,131 +0,0 @@
1
- # Copyright (c) 2020 Jerome Arbez-Gindre
2
- # frozen_string_literal: true
3
-
4
- require('defmastership')
5
-
6
- RSpec.describe(DefMastership::UpdateDefVersionLineModifier) do
7
- subject(:linemodifier) { described_class.new }
8
-
9
- describe '.new' do
10
- it { is_expected.not_to(be_nil) }
11
- it { is_expected.to(have_attributes(def_type: '')) }
12
- it { is_expected.to(have_attributes(changes: [])) }
13
-
14
- it do
15
- expect { linemodifier.user_defined_attribute }
16
- .to(raise_error(NoMethodError))
17
- end
18
- end
19
-
20
- describe '.from_config' do
21
- subject(:linemodifier) do
22
- described_class.from_config(
23
- def_type: 'requirement',
24
- first_version: 'a'
25
- )
26
- end
27
-
28
- it { is_expected.not_to(be_nil) }
29
- it { is_expected.to(have_attributes(def_type: 'requirement')) }
30
- it { is_expected.to(have_attributes(first_version: 'a')) }
31
- it { is_expected.to(have_attributes(document: nil)) }
32
- it { is_expected.to(have_attributes(ref_document: nil)) }
33
- end
34
-
35
- describe '#replace' do
36
- subject(:linemodifier) do
37
- described_class.from_config(
38
- def_type: 'requirement',
39
- first_version: 'a'
40
- )
41
- end
42
-
43
- let(:document) { instance_double(DefMastership::Document, 'document') }
44
- let(:ref_document) { instance_double(DefMastership::Document, 'ref_document') }
45
- let(:definition) { instance_double(DefMastership::Definition, 'definition') }
46
- let(:ref_definition) { instance_double(DefMastership::Definition, 'ref_definitions') }
47
-
48
- before do
49
- linemodifier.document = document
50
- linemodifier.ref_document = ref_document
51
- allow(File).to(receive(:rename))
52
- end
53
-
54
- context 'when definition has not the good type' do
55
- it do
56
- expect(linemodifier.replace('[define,req,REFERENCE]'))
57
- .to(eq('[define,req,REFERENCE]'))
58
- end
59
- end
60
-
61
- context 'when definition has the good type' do
62
- before do
63
- allow(document).to(receive(:ref_to_def).with('REFERENCE').and_return(definition))
64
- allow(definition).to(receive(:sha256).and_return('~abcd1234'))
65
- end
66
-
67
- context 'when definition has NOT changed' do
68
- before do
69
- allow(ref_document).to(receive(:ref_to_def).with('REFERENCE').and_return(ref_definition))
70
- allow(ref_definition).to(receive(:sha256).and_return('~abcd1234'))
71
- end
72
-
73
- it do
74
- allow(ref_definition).to(receive(:explicit_version).and_return(nil))
75
- expect(linemodifier.replace('[define,requirement,REFERENCE]'))
76
- .to(eq('[define,requirement,REFERENCE]'))
77
- end
78
-
79
- it do
80
- allow(ref_definition).to(receive(:explicit_version).and_return('c'))
81
- expect(linemodifier.replace('[define,requirement,REFERENCE]'))
82
- .to(eq('[define,requirement,REFERENCE(c)]'))
83
- end
84
-
85
- it do
86
- allow(ref_definition).to(receive(:explicit_version).and_return('c'))
87
- expect(linemodifier.replace('[define,requirement,REFERENCE(tyty~1234)]'))
88
- .to(eq('[define,requirement,REFERENCE(c~1234)]'))
89
- end
90
- end
91
-
92
- context 'when definition has changed' do
93
- before do
94
- allow(ref_document).to(receive(:ref_to_def).with('REFERENCE').and_return(ref_definition))
95
- allow(ref_definition).to(receive(:sha256).and_return('~4321aaaa'))
96
- end
97
-
98
- [
99
- [nil, '', '(a)'],
100
- ['c', '', '(d)'],
101
- ['c', '(tyty~1234)', '(d~1234)'],
102
- ['2', '', '(3)'],
103
- ['1222', '', '(1223)'],
104
- ['abb', '', '(abc)']
105
- ].each do |ref, from, to|
106
- it do
107
- allow(ref_definition).to(receive(:explicit_version).and_return(ref))
108
- expect(linemodifier.replace("[define,requirement,REFERENCE#{from}]"))
109
- .to(eq("[define,requirement,REFERENCE#{to}]"))
110
- end
111
- end
112
- end
113
-
114
- context 'when definition is new' do
115
- before do
116
- allow(ref_document).to(receive(:ref_to_def).with('REFERENCE').and_return(nil))
117
- end
118
-
119
- it do
120
- expect(linemodifier.replace('[define,requirement,REFERENCE(whatever)]'))
121
- .to(eq('[define,requirement,REFERENCE]'))
122
- end
123
-
124
- it do
125
- expect(linemodifier.replace('[define,requirement,REFERENCE(~1234)]'))
126
- .to(eq('[define,requirement,REFERENCE(~1234)]'))
127
- end
128
- end
129
- end
130
- end
131
- end
File without changes