defmastership 1.3.6 → 1.3.7
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.
- checksums.yaml +4 -4
- data/features/definition_version.feature +41 -0
- data/features/step_definitions/git_steps.rb +30 -0
- data/lib/defmastership/modifier/update_def_version.rb +27 -1
- data/lib/defmastership/version.rb +1 -1
- data/spec/unit/defmastership/modifier/update_def_version_spec.rb +182 -3
- data/spec/unit/defmastership/modifier/update_iref_checksum_spec.rb +11 -8
- data/spec/unit/defmastership/modifier/update_iref_version_spec.rb +11 -8
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1e4fb0225a55bdddfb2c4f0c3dbca650f991c9c018ea1d80bd9f6b7481b9e8b2
|
|
4
|
+
data.tar.gz: d70ae41ef99b5437241cec107f99ed924be71419c3c2c704e52035367c06c8bd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b698312e2bd57eab8331876ec1b4284a682e319d870c037b21272467c1b6e0e44e822eb49228dbc8edfe34c1916c3593eebc294c5611b49605cebb1fc3eb0336
|
|
7
|
+
data.tar.gz: f24030b68f490ebe51fe60d0573876e3e9388c077ef7f1ee02561341db96a22955cd3071ffe2c33857e43b330f08fb19aa7d0b3bc0f413486b765499550cffcb
|
|
@@ -221,6 +221,47 @@ Feature: definitions version
|
|
|
221
221
|
:ref_tag: THE_TAG
|
|
222
222
|
"""
|
|
223
223
|
|
|
224
|
+
Scenario: Update explicit version based on git tag with definitions inside a git submodule
|
|
225
|
+
Given I initialize a git repo in "submodule_origin"
|
|
226
|
+
And a file named "submodule_origin/ref_doc.adoc" with:
|
|
227
|
+
"""
|
|
228
|
+
[define, requirement, TOTO-0001]
|
|
229
|
+
--
|
|
230
|
+
initial text.
|
|
231
|
+
--
|
|
232
|
+
"""
|
|
233
|
+
And I add and commit the changes in repo "submodule_origin"
|
|
234
|
+
And I initialize a git repo
|
|
235
|
+
And I set the environment variable "GIT_ALLOW_PROTOCOL" to "file"
|
|
236
|
+
And I add the repo "submodule_origin" as a submodule "submodule"
|
|
237
|
+
And I set the "THE_TAG" tag
|
|
238
|
+
And a file named "submodule/ref_doc.adoc" with:
|
|
239
|
+
"""
|
|
240
|
+
[define, requirement, TOTO-0001(whatever)]
|
|
241
|
+
--
|
|
242
|
+
modified text.
|
|
243
|
+
--
|
|
244
|
+
"""
|
|
245
|
+
And a file named "modifications.yml" with:
|
|
246
|
+
"""
|
|
247
|
+
---
|
|
248
|
+
:update_requirement_version:
|
|
249
|
+
:type: update_def_version
|
|
250
|
+
:config:
|
|
251
|
+
:def_type: requirement
|
|
252
|
+
:first_version: a
|
|
253
|
+
:ref_tag: 'THE_TAG'
|
|
254
|
+
"""
|
|
255
|
+
And I set the environment variable "GIT_ALLOW_PROTOCOL" to "file"
|
|
256
|
+
When I successfully run `defmastership modify --modifications update_requirement_version submodule/ref_doc.adoc`
|
|
257
|
+
Then the file "submodule/ref_doc.adoc" should contain:
|
|
258
|
+
"""
|
|
259
|
+
[define, requirement, TOTO-0001(a)]
|
|
260
|
+
--
|
|
261
|
+
modified text.
|
|
262
|
+
--
|
|
263
|
+
"""
|
|
264
|
+
|
|
224
265
|
Scenario: Update explicit version based on git tag on a different git repo
|
|
225
266
|
And a file named "defmastership-example.adoc" with:
|
|
226
267
|
"""
|
|
@@ -20,3 +20,33 @@ Given('I set the {string} tag') do |tag_name|
|
|
|
20
20
|
git = Git.open(Aruba.config.home_directory)
|
|
21
21
|
git.add_tag(tag_name)
|
|
22
22
|
end
|
|
23
|
+
|
|
24
|
+
Given('I initialize a git repo in {string}') do |repo_dir|
|
|
25
|
+
require 'fileutils'
|
|
26
|
+
repo_path = File.join(Aruba.config.home_directory, repo_dir)
|
|
27
|
+
FileUtils.mkdir_p(repo_path)
|
|
28
|
+
|
|
29
|
+
git = Git.init(repo_path)
|
|
30
|
+
git.config('user.name', 'Bob Léponge')
|
|
31
|
+
git.config('user.email', 'bob.léponge@example.com')
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
Given('I add and commit the changes in repo {string}') do |repo_dir|
|
|
35
|
+
repo_path = File.join(Aruba.config.home_directory, repo_dir)
|
|
36
|
+
git = Git.open(repo_path)
|
|
37
|
+
|
|
38
|
+
git.config('user.name', 'Bob Léponge')
|
|
39
|
+
git.config('user.email', 'bob.léponge@example.com')
|
|
40
|
+
git.add(all: true)
|
|
41
|
+
git.commit('Commit changes')
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
Given('I add the repo {string} as a submodule {string}') do |remote_dir, submodule_dir|
|
|
45
|
+
run_command("git submodule add ./#{remote_dir} #{submodule_dir}")
|
|
46
|
+
last_command_started.wait
|
|
47
|
+
|
|
48
|
+
main_git = Git.open(Aruba.config.home_directory)
|
|
49
|
+
main_git.add('.gitmodules')
|
|
50
|
+
main_git.add(submodule_dir)
|
|
51
|
+
main_git.commit("Add submodule #{submodule_dir}")
|
|
52
|
+
end
|
|
@@ -49,8 +49,14 @@ module Defmastership
|
|
|
49
49
|
private
|
|
50
50
|
|
|
51
51
|
def parse_ref_files_from_git(adoc_sources, tmpdir)
|
|
52
|
-
|
|
52
|
+
repo_url = Helper.resolve_remote_url(ref_repo)
|
|
53
|
+
|
|
54
|
+
Git.clone(repo_url, tmpdir, branch: ref_tag, recursive: true)
|
|
53
55
|
ref_sources = ref_document.empty? ? adoc_sources.keys : ref_document
|
|
56
|
+
parse_tmpdir_files(tmpdir, ref_sources)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def parse_tmpdir_files(tmpdir, ref_sources)
|
|
54
60
|
ref_sources.each do |adoc_file|
|
|
55
61
|
@ref_document.parse_file_with_preprocessor("#{tmpdir}/#{adoc_file}")
|
|
56
62
|
end
|
|
@@ -78,6 +84,26 @@ module Defmastership
|
|
|
78
84
|
|
|
79
85
|
# Helper functions
|
|
80
86
|
module Helper
|
|
87
|
+
# @param path [String] the repository path
|
|
88
|
+
# @return [String, nil] the origin URL if found
|
|
89
|
+
def self.find_origin_url(path)
|
|
90
|
+
local_git = Git.open(path)
|
|
91
|
+
origin_remote = local_git.remotes.find { |remote| remote.name.eql?('origin') }
|
|
92
|
+
origin_remote&.url
|
|
93
|
+
rescue ArgumentError
|
|
94
|
+
nil
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
# @param path [String] the repository path
|
|
98
|
+
# @return [String] the resolved remote URL
|
|
99
|
+
def self.resolve_remote_url(path)
|
|
100
|
+
if File.directory?(path)
|
|
101
|
+
find_origin_url(path) || path
|
|
102
|
+
else
|
|
103
|
+
path
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
81
107
|
# @param doc [Document] the document with defintions
|
|
82
108
|
# @param match [MatchData] Regexp match matching a reference
|
|
83
109
|
# @return [Definition] the definition from a +Document+ with a matching reference
|
|
@@ -116,6 +116,7 @@ RSpec.describe(Defmastership::Modifier::UpdateDefVersion) do
|
|
|
116
116
|
before do
|
|
117
117
|
allow(Dir).to(receive(:mktmpdir).and_yield('tmp'))
|
|
118
118
|
allow(Git).to(receive(:clone))
|
|
119
|
+
allow(Git).to(receive(:open)).and_raise(ArgumentError)
|
|
119
120
|
allow(Defmastership::Document).to(receive(:new).twice.and_return(ref_document, document))
|
|
120
121
|
allow(document).to(receive(:parse_file_with_preprocessor).with('file1.adoc'))
|
|
121
122
|
allow(document).to(receive(:parse_file_with_preprocessor).with('file2.adoc'))
|
|
@@ -131,7 +132,7 @@ RSpec.describe(Defmastership::Modifier::UpdateDefVersion) do
|
|
|
131
132
|
end
|
|
132
133
|
|
|
133
134
|
it { expect(Dir).to(have_received(:mktmpdir).with('defmastership')) }
|
|
134
|
-
it { expect(Git).to(have_received(:clone).with('.', 'tmp', branch: 'THE_TAG')) }
|
|
135
|
+
it { expect(Git).to(have_received(:clone).with('.', 'tmp', branch: 'THE_TAG', recursive: true)) }
|
|
135
136
|
it { expect(Defmastership::Document).to(have_received(:new).twice) }
|
|
136
137
|
it { expect(ref_document).to(have_received(:parse_file_with_preprocessor).with('tmp/file1.adoc')) }
|
|
137
138
|
it { expect(ref_document).to(have_received(:parse_file_with_preprocessor).with('tmp/file2.adoc')) }
|
|
@@ -142,6 +143,111 @@ RSpec.describe(Defmastership::Modifier::UpdateDefVersion) do
|
|
|
142
143
|
end
|
|
143
144
|
end
|
|
144
145
|
|
|
146
|
+
context 'when ref_repo is not a directory' do
|
|
147
|
+
subject(:modifier) do
|
|
148
|
+
described_class.new(ref_tag: 'THE_TAG', ref_repo: 'not_a_directory', def_type: 'req', first_version: 'a')
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
let(:adoc_sources) do
|
|
152
|
+
{
|
|
153
|
+
'file1.adoc' => "[define,req,REFERENCE]\nfile1 line2"
|
|
154
|
+
}
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
before do
|
|
158
|
+
document = instance_double(Defmastership::Document, 'document')
|
|
159
|
+
ref_document = instance_double(Defmastership::Document, 'ref_document')
|
|
160
|
+
definition = instance_double(Defmastership::Definition, 'definition')
|
|
161
|
+
ref_definition = instance_double(Defmastership::Definition, 'ref_definitions')
|
|
162
|
+
|
|
163
|
+
allow(Dir).to(receive(:mktmpdir).and_yield('tmp'))
|
|
164
|
+
allow(Git).to(receive(:clone))
|
|
165
|
+
allow(File).to(receive(:directory?).with('not_a_directory').and_return(false))
|
|
166
|
+
|
|
167
|
+
allow(Defmastership::Document).to(receive(:new).twice.and_return(ref_document, document))
|
|
168
|
+
allow(document).to(receive_messages(parse_file_with_preprocessor: nil, ref_to_def: definition))
|
|
169
|
+
allow(ref_document).to(receive_messages(parse_file_with_preprocessor: nil, ref_to_def: ref_definition))
|
|
170
|
+
allow(ref_definition).to(receive_messages(explicit_version: nil, sha256_short: 'something_else'))
|
|
171
|
+
allow(definition).to(receive(:sha256_short).and_return('something'))
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
it 'clones the non-directory path directly as the repository URL' do
|
|
175
|
+
modifier.do_modifications(adoc_sources)
|
|
176
|
+
expect(Git).to(have_received(:clone).with('not_a_directory', 'tmp', branch: 'THE_TAG', recursive: true))
|
|
177
|
+
end
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
context 'when ref_repo is a local git repository' do
|
|
181
|
+
subject(:modifier) { described_class.new(ref_tag: 'THE_TAG', def_type: 'req', first_version: 'a') }
|
|
182
|
+
|
|
183
|
+
let(:local_git) { instance_double(Git::Base) }
|
|
184
|
+
let(:remote) { instance_double(Git::Remote, name: 'origin', url: 'https://gitlab.example.com/repo.git') }
|
|
185
|
+
let(:adoc_sources) do
|
|
186
|
+
{
|
|
187
|
+
'file1.adoc' => "[define,req,REFERENCE]\nfile1 line2"
|
|
188
|
+
}
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
before do
|
|
192
|
+
document = instance_double(Defmastership::Document, 'document')
|
|
193
|
+
ref_document = instance_double(Defmastership::Document, 'ref_document')
|
|
194
|
+
definition = instance_double(Defmastership::Definition, 'definition')
|
|
195
|
+
ref_definition = instance_double(Defmastership::Definition, 'ref_definitions')
|
|
196
|
+
|
|
197
|
+
allow(Dir).to(receive(:mktmpdir).and_yield('tmp'))
|
|
198
|
+
allow(Git).to(receive(:clone))
|
|
199
|
+
allow(File).to(receive(:directory?).with('.').and_return(true))
|
|
200
|
+
allow(Git).to(receive(:open)).with('.').and_return(local_git)
|
|
201
|
+
allow(local_git).to(receive(:remotes)).and_return([remote])
|
|
202
|
+
|
|
203
|
+
allow(Defmastership::Document).to(receive(:new).twice.and_return(ref_document, document))
|
|
204
|
+
allow(document).to(receive_messages(parse_file_with_preprocessor: nil, ref_to_def: definition))
|
|
205
|
+
allow(ref_document).to(receive_messages(parse_file_with_preprocessor: nil, ref_to_def: ref_definition))
|
|
206
|
+
allow(ref_definition).to(receive_messages(explicit_version: nil, sha256_short: 'something_else'))
|
|
207
|
+
allow(definition).to(receive(:sha256_short).and_return('something'))
|
|
208
|
+
|
|
209
|
+
modifier.do_modifications(adoc_sources)
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
it { expect(Git).to(have_received(:clone).with('https://gitlab.example.com/repo.git', 'tmp', branch: 'THE_TAG', recursive: true)) }
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
context 'when ref_repo is a local git repository without an origin remote' do
|
|
216
|
+
subject(:modifier) { described_class.new(ref_tag: 'THE_TAG', def_type: 'req', first_version: 'a') }
|
|
217
|
+
|
|
218
|
+
let(:local_git) { instance_double(Git::Base) }
|
|
219
|
+
let(:remote) { instance_double(Git::Remote, name: 'upstream', url: 'https://gitlab.example.com/repo.git') }
|
|
220
|
+
let(:adoc_sources) do
|
|
221
|
+
{
|
|
222
|
+
'file1.adoc' => "[define,req,REFERENCE]\nfile1 line2"
|
|
223
|
+
}
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
before do
|
|
227
|
+
document = instance_double(Defmastership::Document, 'document')
|
|
228
|
+
ref_document = instance_double(Defmastership::Document, 'ref_document')
|
|
229
|
+
definition = instance_double(Defmastership::Definition, 'definition')
|
|
230
|
+
ref_definition = instance_double(Defmastership::Definition, 'ref_definitions')
|
|
231
|
+
|
|
232
|
+
allow(Dir).to(receive(:mktmpdir).and_yield('tmp'))
|
|
233
|
+
allow(Git).to(receive(:clone))
|
|
234
|
+
allow(File).to(receive(:directory?).with('.').and_return(true))
|
|
235
|
+
allow(Git).to(receive(:open)).with('.').and_return(local_git)
|
|
236
|
+
# Setup the mock so it doesn't find 'origin'
|
|
237
|
+
allow(local_git).to(receive(:remotes)).and_return([remote])
|
|
238
|
+
|
|
239
|
+
allow(Defmastership::Document).to(receive(:new).twice.and_return(ref_document, document))
|
|
240
|
+
allow(document).to(receive_messages(parse_file_with_preprocessor: nil, ref_to_def: definition))
|
|
241
|
+
allow(ref_document).to(receive_messages(parse_file_with_preprocessor: nil, ref_to_def: ref_definition))
|
|
242
|
+
allow(ref_definition).to(receive_messages(explicit_version: nil, sha256_short: 'something_else'))
|
|
243
|
+
allow(definition).to(receive(:sha256_short).and_return('something'))
|
|
244
|
+
|
|
245
|
+
modifier.do_modifications(adoc_sources)
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
it { expect(Git).to(have_received(:clone).with('.', 'tmp', branch: 'THE_TAG', recursive: true)) }
|
|
249
|
+
end
|
|
250
|
+
|
|
145
251
|
context 'when ref_tag and ref_repo is provided' do
|
|
146
252
|
subject(:modifier) do
|
|
147
253
|
described_class.new(ref_tag: 'THE_TAG', ref_repo: 'not dot', def_type: 'req', first_version: 'a')
|
|
@@ -161,6 +267,7 @@ RSpec.describe(Defmastership::Modifier::UpdateDefVersion) do
|
|
|
161
267
|
before do
|
|
162
268
|
allow(Dir).to(receive(:mktmpdir).and_yield('tmp'))
|
|
163
269
|
allow(Git).to(receive(:clone))
|
|
270
|
+
allow(Git).to(receive(:open)).and_raise(ArgumentError)
|
|
164
271
|
allow(Defmastership::Document).to(receive(:new).twice.and_return(ref_document, document))
|
|
165
272
|
allow(document).to(receive(:parse_file_with_preprocessor).with('file1.adoc'))
|
|
166
273
|
allow(document).to(receive(:parse_file_with_preprocessor).with('file2.adoc'))
|
|
@@ -176,7 +283,7 @@ RSpec.describe(Defmastership::Modifier::UpdateDefVersion) do
|
|
|
176
283
|
end
|
|
177
284
|
|
|
178
285
|
it { expect(Dir).to(have_received(:mktmpdir).with('defmastership')) }
|
|
179
|
-
it { expect(Git).to(have_received(:clone).with('not dot', 'tmp', branch: 'THE_TAG')) }
|
|
286
|
+
it { expect(Git).to(have_received(:clone).with('not dot', 'tmp', branch: 'THE_TAG', recursive: true)) }
|
|
180
287
|
it { expect(Defmastership::Document).to(have_received(:new).twice) }
|
|
181
288
|
it { expect(ref_document).to(have_received(:parse_file_with_preprocessor).with('tmp/file1.adoc')) }
|
|
182
289
|
it { expect(ref_document).to(have_received(:parse_file_with_preprocessor).with('tmp/file2.adoc')) }
|
|
@@ -211,6 +318,7 @@ RSpec.describe(Defmastership::Modifier::UpdateDefVersion) do
|
|
|
211
318
|
before do
|
|
212
319
|
allow(Dir).to(receive(:mktmpdir).and_yield('tmp'))
|
|
213
320
|
allow(Git).to(receive(:clone))
|
|
321
|
+
allow(Git).to(receive(:open)).and_raise(ArgumentError)
|
|
214
322
|
allow(Defmastership::Document).to(receive(:new).twice.and_return(ref_document, document))
|
|
215
323
|
allow(document).to(receive(:parse_file_with_preprocessor).with('file1.adoc'))
|
|
216
324
|
allow(document).to(receive(:parse_file_with_preprocessor).with('file2.adoc'))
|
|
@@ -225,7 +333,7 @@ RSpec.describe(Defmastership::Modifier::UpdateDefVersion) do
|
|
|
225
333
|
end
|
|
226
334
|
|
|
227
335
|
it { expect(Dir).to(have_received(:mktmpdir).with('defmastership')) }
|
|
228
|
-
it { expect(Git).to(have_received(:clone).with('.', 'tmp', branch: 'THE_TAG')) }
|
|
336
|
+
it { expect(Git).to(have_received(:clone).with('.', 'tmp', branch: 'THE_TAG', recursive: true)) }
|
|
229
337
|
it { expect(Defmastership::Document).to(have_received(:new).twice) }
|
|
230
338
|
it { expect(ref_document).to(have_received(:parse_file_with_preprocessor).with('tmp/./another/doc.adoc')) }
|
|
231
339
|
it { expect(ref_document).to(have_received(:parse_file_with_preprocessor).once) }
|
|
@@ -236,6 +344,77 @@ RSpec.describe(Defmastership::Modifier::UpdateDefVersion) do
|
|
|
236
344
|
end
|
|
237
345
|
end
|
|
238
346
|
|
|
347
|
+
describe '.resolve_remote_url' do
|
|
348
|
+
subject(:resolved_url) { described_class.const_get(:Helper).resolve_remote_url(path) }
|
|
349
|
+
|
|
350
|
+
context 'when the path is not a directory' do
|
|
351
|
+
let(:path) { 'git@github.com:org/repo.git' }
|
|
352
|
+
|
|
353
|
+
before do
|
|
354
|
+
allow(File).to(receive(:directory?).with(path).and_return(false))
|
|
355
|
+
end
|
|
356
|
+
|
|
357
|
+
it 'returns the exact path itself' do
|
|
358
|
+
expect(resolved_url).to(be(path))
|
|
359
|
+
end
|
|
360
|
+
|
|
361
|
+
it 'queries File.directory?' do
|
|
362
|
+
resolved_url
|
|
363
|
+
expect(File).to(have_received(:directory?).with(path))
|
|
364
|
+
end
|
|
365
|
+
end
|
|
366
|
+
|
|
367
|
+
context 'when the path is a directory and has an origin remote' do
|
|
368
|
+
let(:path) { '/path/to/local/repo' }
|
|
369
|
+
let(:local_git) { instance_double(Git::Base) }
|
|
370
|
+
let(:remote) { instance_double(Git::Remote, name: 'origin', url: 'https://gitlab.example.com/repo.git') }
|
|
371
|
+
|
|
372
|
+
before do
|
|
373
|
+
allow(File).to(receive(:directory?).with(path).and_return(true))
|
|
374
|
+
allow(Git).to(receive(:open)).with(path).and_return(local_git)
|
|
375
|
+
allow(local_git).to(receive(:remotes)).and_return([remote])
|
|
376
|
+
end
|
|
377
|
+
|
|
378
|
+
it 'returns the origin remote url' do
|
|
379
|
+
expect(resolved_url).to(eq('https://gitlab.example.com/repo.git'))
|
|
380
|
+
end
|
|
381
|
+
|
|
382
|
+
it 'queries File.directory?' do
|
|
383
|
+
resolved_url
|
|
384
|
+
expect(File).to(have_received(:directory?).with(path))
|
|
385
|
+
end
|
|
386
|
+
end
|
|
387
|
+
|
|
388
|
+
context 'when the path is a directory but does not have an origin remote' do
|
|
389
|
+
let(:path) { '/path/to/local/repo' }
|
|
390
|
+
let(:local_git) { instance_double(Git::Base) }
|
|
391
|
+
let(:remote) { instance_double(Git::Remote, name: 'upstream', url: 'https://gitlab.example.com/repo.git') }
|
|
392
|
+
|
|
393
|
+
before do
|
|
394
|
+
allow(File).to(receive(:directory?).with(path).and_return(true))
|
|
395
|
+
allow(Git).to(receive(:open)).with(path).and_return(local_git)
|
|
396
|
+
allow(local_git).to(receive(:remotes)).and_return([remote])
|
|
397
|
+
end
|
|
398
|
+
|
|
399
|
+
it 'returns the path itself' do
|
|
400
|
+
expect(resolved_url).to(eq(path))
|
|
401
|
+
end
|
|
402
|
+
end
|
|
403
|
+
|
|
404
|
+
context 'when Git.open raises an ArgumentError' do
|
|
405
|
+
let(:path) { '/path/to/local/repo' }
|
|
406
|
+
|
|
407
|
+
before do
|
|
408
|
+
allow(File).to(receive(:directory?).with(path).and_return(true))
|
|
409
|
+
allow(Git).to(receive(:open)).with(path).and_raise(ArgumentError)
|
|
410
|
+
end
|
|
411
|
+
|
|
412
|
+
it 'returns the path itself' do
|
|
413
|
+
expect(resolved_url).to(eq(path))
|
|
414
|
+
end
|
|
415
|
+
end
|
|
416
|
+
end
|
|
417
|
+
|
|
239
418
|
describe '#replace_reference' do
|
|
240
419
|
subject(:modifier) { described_class.new(def_type: 'requirement', first_version: 'a') }
|
|
241
420
|
|
|
@@ -29,23 +29,26 @@ RSpec.describe(Defmastership::Modifier::UpdateIrefChecksum) do
|
|
|
29
29
|
allow(Defmastership::Document).to(receive(:new).and_return(document))
|
|
30
30
|
allow(document).to(receive(:parse_file_with_preprocessor))
|
|
31
31
|
allow_any_instance_of(Defmastership::Modifier::ModifierCommon).to(receive(:do_modifications).and_return(adoc_sources))
|
|
32
|
+
end
|
|
32
33
|
|
|
34
|
+
it 'creates a new document' do
|
|
33
35
|
modifier.do_modifications(adoc_sources)
|
|
36
|
+
expect(Defmastership::Document).to(have_received(:new))
|
|
34
37
|
end
|
|
35
38
|
|
|
36
|
-
it
|
|
39
|
+
it 'parses the first adoc file with preprocessor' do
|
|
40
|
+
modifier.do_modifications(adoc_sources)
|
|
41
|
+
expect(document).to(have_received(:parse_file_with_preprocessor).with('file1.adoc'))
|
|
42
|
+
end
|
|
37
43
|
|
|
38
|
-
it do
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
.once.with('file1.adoc')
|
|
42
|
-
.once.with('file2.adoc')
|
|
43
|
-
)
|
|
44
|
+
it 'parses the second adoc file with preprocessor' do
|
|
45
|
+
modifier.do_modifications(adoc_sources)
|
|
46
|
+
expect(document).to(have_received(:parse_file_with_preprocessor).with('file2.adoc'))
|
|
44
47
|
end
|
|
45
48
|
|
|
46
49
|
it { expect(modifier.do_modifications(adoc_sources)).to(eq(adoc_sources)) }
|
|
47
50
|
|
|
48
|
-
it 'call the parent method' do
|
|
51
|
+
it 'call the parent method with arguments' do
|
|
49
52
|
expect_any_instance_of(Defmastership::Modifier::ModifierCommon).to(receive(:do_modifications).with(adoc_sources))
|
|
50
53
|
modifier.do_modifications(adoc_sources)
|
|
51
54
|
end
|
|
@@ -29,23 +29,26 @@ RSpec.describe(Defmastership::Modifier::UpdateIrefVersion) do
|
|
|
29
29
|
allow(Defmastership::Document).to(receive(:new).and_return(document))
|
|
30
30
|
allow(document).to(receive(:parse_file_with_preprocessor))
|
|
31
31
|
allow_any_instance_of(Defmastership::Modifier::ModifierCommon).to(receive(:do_modifications).and_return(adoc_sources))
|
|
32
|
+
end
|
|
32
33
|
|
|
34
|
+
it 'creates a new document' do
|
|
33
35
|
modifier.do_modifications(adoc_sources)
|
|
36
|
+
expect(Defmastership::Document).to(have_received(:new))
|
|
34
37
|
end
|
|
35
38
|
|
|
36
|
-
it
|
|
39
|
+
it 'parses the first adoc file with preprocessor' do
|
|
40
|
+
modifier.do_modifications(adoc_sources)
|
|
41
|
+
expect(document).to(have_received(:parse_file_with_preprocessor).with('file1.adoc'))
|
|
42
|
+
end
|
|
37
43
|
|
|
38
|
-
it do
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
.once.with('file1.adoc')
|
|
42
|
-
.once.with('file2.adoc')
|
|
43
|
-
)
|
|
44
|
+
it 'parses the second adoc file with preprocessor' do
|
|
45
|
+
modifier.do_modifications(adoc_sources)
|
|
46
|
+
expect(document).to(have_received(:parse_file_with_preprocessor).with('file2.adoc'))
|
|
44
47
|
end
|
|
45
48
|
|
|
46
49
|
it { expect(modifier.do_modifications(adoc_sources)).to(eq(adoc_sources)) }
|
|
47
50
|
|
|
48
|
-
it 'call the parent method' do
|
|
51
|
+
it 'call the parent method with arguments' do
|
|
49
52
|
expect_any_instance_of(Defmastership::Modifier::ModifierCommon).to(receive(:do_modifications).with(adoc_sources))
|
|
50
53
|
modifier.do_modifications(adoc_sources)
|
|
51
54
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: defmastership
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.3.
|
|
4
|
+
version: 1.3.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jérôme Arbez-Gindre
|
|
@@ -272,7 +272,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
272
272
|
- !ruby/object:Gem::Version
|
|
273
273
|
version: '0'
|
|
274
274
|
requirements: []
|
|
275
|
-
rubygems_version: 4.0.
|
|
275
|
+
rubygems_version: 4.0.12
|
|
276
276
|
specification_version: 4
|
|
277
277
|
summary: Handling of references and definitions with asciidoctor
|
|
278
278
|
test_files: []
|