defmastership 1.0.5 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/bin/defmastership +21 -15
  4. data/cucumber.yml +1 -1
  5. data/defmastership.gemspec +12 -6
  6. data/features/changeref.feature +82 -129
  7. data/features/export.feature +88 -34
  8. data/features/modify.feature +143 -0
  9. data/features/rename_included_files.feature +121 -0
  10. data/lib/defmastership.rb +11 -3
  11. data/lib/defmastership/batch_modifier.rb +33 -0
  12. data/lib/defmastership/{ref_changer.rb → change_ref_line_modifier.rb} +18 -35
  13. data/lib/defmastership/change_ref_modifier.rb +15 -0
  14. data/lib/defmastership/constants.rb +14 -1
  15. data/lib/defmastership/csv_formatter.rb +15 -16
  16. data/lib/defmastership/csv_formatter_body.rb +11 -6
  17. data/lib/defmastership/csv_formatter_header.rb +11 -10
  18. data/lib/defmastership/definition.rb +11 -0
  19. data/lib/defmastership/definition_parser.rb +46 -0
  20. data/lib/defmastership/document.rb +43 -75
  21. data/lib/defmastership/filters.rb +30 -0
  22. data/lib/defmastership/line_modifier_base.rb +29 -0
  23. data/lib/defmastership/modifier_base.rb +29 -0
  24. data/lib/defmastership/rename_included_files_line_modifier.rb +126 -0
  25. data/lib/defmastership/rename_included_files_modifier.rb +30 -0
  26. data/lib/defmastership/version.rb +1 -1
  27. data/spec/spec_helper.rb +1 -0
  28. data/spec/unit/defmastership/batch_modifier_spec.rb +115 -0
  29. data/spec/unit/defmastership/{ref_changer_spec.rb → change_ref_line_modifier_spec.rb} +48 -26
  30. data/spec/unit/defmastership/change_ref_modifier_spec.rb +76 -0
  31. data/spec/unit/defmastership/comment_filter_spec.rb +8 -4
  32. data/spec/unit/defmastership/csv_formatter_body_spec.rb +61 -37
  33. data/spec/unit/defmastership/csv_formatter_header_spec.rb +46 -22
  34. data/spec/unit/defmastership/csv_formatter_spec.rb +65 -104
  35. data/spec/unit/defmastership/definition_parser_spec.rb +63 -0
  36. data/spec/unit/defmastership/definition_spec.rb +30 -4
  37. data/spec/unit/defmastership/document_spec.rb +112 -35
  38. data/spec/unit/defmastership/rename_included_files_line_modifier_spec.rb +203 -0
  39. data/spec/unit/defmastership/rename_included_files_modifier_spec.rb +67 -0
  40. metadata +34 -9
  41. data/lib/defmastership/batch_changer.rb +0 -41
  42. data/lib/defmastership/project_ref_changer.rb +0 -28
  43. data/spec/unit/defmastership/batch_changer_spec.rb +0 -109
  44. data/spec/unit/defmastership/project_ref_changer_spec.rb +0 -80
@@ -1,80 +0,0 @@
1
- # Copyright (c) 2020 Jerome Arbez-Gindre
2
- # frozen_string_literal: true
3
-
4
- require('defmastership')
5
- require('yaml')
6
-
7
- RSpec.describe(DefMastership::ProjectRefChanger) do
8
- subject(:projectrefchanger) do
9
- described_class.new(
10
- 'fake yaml config',
11
- {
12
- 'file1.adoc' => "file1 line1\nfile1 line2",
13
- 'file2.adoc' => "file2 line1\nfile2 line2"
14
- }
15
- )
16
- end
17
-
18
- describe '.new' do
19
- it { is_expected.not_to(be(nil)) }
20
- it { is_expected.to(have_attributes(yaml_config: 'fake yaml config')) }
21
-
22
- it do
23
- expect(projectrefchanger).to(have_attributes(adoc_texts:
24
- {
25
- 'file1.adoc' => "file1 line1\nfile1 line2",
26
- 'file2.adoc' => "file2 line1\nfile2 line2"
27
- }))
28
- end
29
-
30
- it { is_expected.to(have_attributes(changes: nil)) }
31
- end
32
-
33
- describe '#replace_all' do
34
- let(:batch_changer) { instance_double(DefMastership::BatchChanger, 'batch_changer') }
35
- let(:config_hash) { instance_double(Hash, 'config_hash') }
36
-
37
- before do
38
- allow(DefMastership::BatchChanger).to(receive(:from_h).with('fake yaml config').and_return(batch_changer))
39
- allow(batch_changer).to(receive(:replace).with(:refdef, "file1 line1\n").and_return("new file1 line1\n"))
40
- allow(batch_changer).to(receive(:replace).with(:refdef, 'file1 line2').and_return('new file1 line2'))
41
- allow(batch_changer).to(receive(:replace).with(:refdef, "file2 line1\n").and_return("new file2 line1\n"))
42
- allow(batch_changer).to(receive(:replace).with(:refdef, 'file2 line2').and_return('new file2 line2'))
43
- allow(batch_changer).to(receive(:replace).with(:irefs, "new file1 line1\n").and_return("new2 file1 line1\n"))
44
- allow(batch_changer).to(receive(:replace).with(:irefs, 'new file1 line2').and_return('new2 file1 line2'))
45
- allow(batch_changer).to(receive(:replace).with(:irefs, "new file2 line1\n").and_return("new2 file2 line1\n"))
46
- allow(batch_changer).to(receive(:replace).with(:irefs, 'new file2 line2').and_return('new2 file2 line2'))
47
- allow(batch_changer).to(receive(:to_h).and_return(config_hash))
48
- allow(batch_changer).to(receive(:changes).and_return('pouet'))
49
- allow(config_hash).to(receive(:to_yaml).with(no_args).and_return('new fake yaml config'))
50
- projectrefchanger.replace_all
51
- end
52
-
53
- it { expect(DefMastership::BatchChanger).to(have_received(:from_h).with('fake yaml config')) }
54
-
55
- it { expect(batch_changer).to(have_received(:replace).with(:refdef, "file1 line1\n")) }
56
- it { expect(batch_changer).to(have_received(:replace).with(:refdef, 'file1 line2')) }
57
- it { expect(batch_changer).to(have_received(:replace).with(:refdef, "file2 line1\n")) }
58
- it { expect(batch_changer).to(have_received(:replace).with(:refdef, 'file2 line2')) }
59
- it { expect(batch_changer).to(have_received(:replace).with(:irefs, "new file1 line1\n")) }
60
- it { expect(batch_changer).to(have_received(:replace).with(:irefs, 'new file1 line2')) }
61
- it { expect(batch_changer).to(have_received(:replace).with(:irefs, "new file2 line1\n")) }
62
- it { expect(batch_changer).to(have_received(:replace).with(:irefs, 'new file2 line2')) }
63
-
64
- it { expect(batch_changer).to(have_received(:to_h)) }
65
-
66
- it { expect(config_hash).to(have_received(:to_yaml).with(no_args)) }
67
-
68
- it { expect(projectrefchanger).to(have_attributes(yaml_config: 'new fake yaml config')) }
69
-
70
- it do
71
- expect(projectrefchanger).to(have_attributes(adoc_texts: {
72
- 'file1.adoc' => "new2 file1 line1\nnew2 file1 line2",
73
- 'file2.adoc' => "new2 file2 line1\nnew2 file2 line2"
74
- }))
75
- end
76
-
77
- it { expect(batch_changer).to(have_received(:changes)) }
78
- it { expect(projectrefchanger).to(have_attributes(changes: 'pouet')) }
79
- end
80
- end