social_snippet 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.gitignore +2 -0
- data/.travis.yml +22 -3
- data/Gemfile +25 -2
- data/Guardfile +9 -0
- data/README.md +6 -1
- data/Rakefile +51 -1
- data/appveyor.yml +36 -0
- data/bin/ssnip +10 -0
- data/bin/sspm +10 -0
- data/lib/social_snippet.rb +15 -4
- data/lib/social_snippet/api.rb +238 -0
- data/lib/social_snippet/command_line.rb +4 -0
- data/lib/social_snippet/command_line/command.rb +158 -0
- data/lib/social_snippet/command_line/ssnip.rb +2 -0
- data/lib/social_snippet/command_line/ssnip/main_command.rb +26 -0
- data/lib/social_snippet/command_line/sspm.rb +3 -0
- data/lib/social_snippet/command_line/sspm/main_command.rb +63 -0
- data/lib/social_snippet/command_line/sspm/sub_commands.rb +16 -0
- data/lib/social_snippet/command_line/sspm/sub_commands/complete_command.rb +28 -0
- data/lib/social_snippet/command_line/sspm/sub_commands/info_command.rb +28 -0
- data/lib/social_snippet/command_line/sspm/sub_commands/install_command.rb +103 -0
- data/lib/social_snippet/command_line/sspm/sub_commands/publish_command.rb +51 -0
- data/lib/social_snippet/command_line/sspm/sub_commands/search_command.rb +32 -0
- data/lib/social_snippet/command_line/sspm/sub_commands/update_command.rb +37 -0
- data/lib/social_snippet/config.rb +92 -0
- data/lib/social_snippet/context.rb +89 -0
- data/lib/social_snippet/core.rb +40 -0
- data/lib/social_snippet/inserter.rb +64 -0
- data/lib/social_snippet/logger.rb +9 -0
- data/lib/social_snippet/registry.rb +3 -0
- data/lib/social_snippet/registry/registry_client.rb +15 -0
- data/lib/social_snippet/registry/registry_resources.rb +3 -0
- data/lib/social_snippet/registry/registry_resources/base.rb +80 -0
- data/lib/social_snippet/registry/registry_resources/repositories.rb +23 -0
- data/lib/social_snippet/repository.rb +6 -0
- data/lib/social_snippet/repository/drivers.rb +3 -0
- data/lib/social_snippet/repository/drivers/base_repository.rb +192 -0
- data/lib/social_snippet/repository/drivers/git_repository.rb +76 -0
- data/lib/social_snippet/repository/repository_errors.rb +5 -0
- data/lib/social_snippet/repository/repository_factory.rb +59 -0
- data/lib/social_snippet/repository/repository_installer.rb +86 -0
- data/lib/social_snippet/repository/repository_manager.rb +177 -0
- data/lib/social_snippet/resolvers.rb +4 -0
- data/lib/social_snippet/resolvers/base_resolver.rb +103 -0
- data/lib/social_snippet/resolvers/dep_resolver.rb +61 -0
- data/lib/social_snippet/resolvers/insert_resolver.rb +100 -0
- data/lib/social_snippet/snippet.rb +14 -0
- data/lib/social_snippet/tag.rb +198 -0
- data/lib/social_snippet/tag_parser.rb +61 -0
- data/lib/social_snippet/version.rb +26 -1
- data/social_snippet.gemspec +18 -3
- data/spec/helpers/codeclimate_helper.rb +4 -0
- data/spec/helpers/fakefs_helper.rb +15 -0
- data/spec/helpers/webmock_helper.rb +16 -0
- data/spec/lib/api_spec.rb +106 -0
- data/spec/lib/command_line/sspm_install_spec.rb +224 -0
- data/spec/lib/command_line/sspm_search_spec.rb +167 -0
- data/spec/lib/command_line/sspm_spec.rb +81 -0
- data/spec/lib/config_spec.rb +56 -0
- data/spec/lib/context_spec.rb +48 -0
- data/spec/lib/core_spec.rb +126 -0
- data/spec/lib/inserter_spec.rb +177 -0
- data/spec/lib/registry_client_spec.rb +173 -0
- data/spec/lib/repository/base_repository_spec.rb +104 -0
- data/spec/lib/repository/git_repository_spec.rb +83 -0
- data/spec/lib/repository/repository_factory_spec.rb +31 -0
- data/spec/lib/repository/repository_installer_spec.rb +63 -0
- data/spec/lib/repository/repository_manager_spec.rb +201 -0
- data/spec/lib/tag_parser_spec.rb +173 -0
- data/spec/lib/tag_spec.rb +93 -0
- data/spec/spec_helper.rb +106 -0
- data/test/base_repository_test.rb +375 -0
- data/test/command_test.rb +39 -0
- data/test/context_test.rb +31 -0
- data/test/core_test.rb +2091 -0
- data/test/git_repository_test.rb +114 -0
- data/test/install_command_test.rb +28 -0
- data/test/repository_manager_test.rb +109 -0
- data/test/tag_parser_test.rb +47 -0
- data/test/tag_test.rb +217 -0
- data/test/version_test.rb +56 -0
- metadata +271 -14
@@ -0,0 +1,39 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
module SocialSnippet::CommandLine
|
4
|
+
|
5
|
+
describe Command do
|
6
|
+
|
7
|
+
let(:instance) { Command.new ["--opt1", "--opt2", "--opt3", "not-opt"] }
|
8
|
+
|
9
|
+
describe :is_line_option do
|
10
|
+
|
11
|
+
let(:func) do
|
12
|
+
Proc.new do |name|
|
13
|
+
instance.send(:is_line_option?, name)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
context "valid" do
|
18
|
+
|
19
|
+
it { expect(func.call "--line-option").to be_truthy }
|
20
|
+
it { expect(func.call "-l").to be_truthy }
|
21
|
+
it { expect(func.call "--option1").to be_truthy }
|
22
|
+
it { expect(func.call "--option_a").to be_truthy }
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
context "invalid" do
|
27
|
+
|
28
|
+
it { expect(func.call "-too-long").to be_falsey }
|
29
|
+
it { expect(func.call "opt").to be_falsey }
|
30
|
+
it { expect(func.call "not-opt").to be_falsey }
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
end # Command
|
37
|
+
|
38
|
+
end # SocialSnippet::CommandLine
|
39
|
+
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe SocialSnippet::Context do
|
4
|
+
|
5
|
+
describe ".new()" do
|
6
|
+
|
7
|
+
context "pass absolute path" do
|
8
|
+
|
9
|
+
let(:instance) { SocialSnippet::Context.new("/path/to/file.cpp") }
|
10
|
+
|
11
|
+
context "move file2.cpp" do
|
12
|
+
before { instance.move "file2.cpp" }
|
13
|
+
it { expect(instance.path).to eq "/path/to/file2.cpp" }
|
14
|
+
end
|
15
|
+
|
16
|
+
context "move subdir/file3.cpp" do
|
17
|
+
before { instance.move "subdir/file3.cpp" }
|
18
|
+
it { expect(instance.path).to eq "/path/to/subdir/file3.cpp" }
|
19
|
+
end
|
20
|
+
|
21
|
+
context "move /path/to_another/file.cpp" do
|
22
|
+
before { instance.move "/path/to_another/file.cpp" }
|
23
|
+
it { expect(instance.path).to eq "/path/to_another/file.cpp" }
|
24
|
+
end
|
25
|
+
|
26
|
+
end # pass absolute path
|
27
|
+
|
28
|
+
end # .new()
|
29
|
+
|
30
|
+
end # SocialSnippet::Context
|
31
|
+
|
data/test/core_test.rb
ADDED
@@ -0,0 +1,2091 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe SocialSnippet::Core do
|
4
|
+
|
5
|
+
before do
|
6
|
+
allow_any_instance_of(::SocialSnippet::CommandLine::Command).to receive(:social_snippet).and_return fake_social_snippet
|
7
|
+
end
|
8
|
+
|
9
|
+
let(:repo_path) { fake_config.install_path }
|
10
|
+
let(:tmp_repo_path) { "/tmp/repos" }
|
11
|
+
let(:tmp_repo_path_no_ver) { "/tmp/repos_no_ver" }
|
12
|
+
let(:repo_cache_path) { fake_config.repository_cache_path }
|
13
|
+
let(:commit_id) { "thisisdummy" }
|
14
|
+
let(:short_commit_id) { commit_id[0..7] }
|
15
|
+
|
16
|
+
def find_repo_mock
|
17
|
+
repo_refs = {}
|
18
|
+
repos = Dir.glob("#{tmp_repo_path}/*").map{|path| Pathname.new(path).basename.to_s }
|
19
|
+
repos.each do |repo_name|
|
20
|
+
repo_refs[repo_name] = Dir.glob("#{tmp_repo_path}/#{repo_name}/*").map {|path| Pathname.new(path).basename.to_s }
|
21
|
+
end
|
22
|
+
|
23
|
+
repos_no_ver = Dir.glob("#{tmp_repo_path_no_ver}/*").map {|path| Pathname.new(path).basename.to_s }
|
24
|
+
|
25
|
+
allow(fake_social_snippet.repo_manager).to receive(:find_repository).with(any_args) do |repo_name, ref|
|
26
|
+
repo_refs[repo_name] ||= []
|
27
|
+
versions = repo_refs[repo_name].select {|ver| SocialSnippet::Version.is_matched_version_pattern(ref, ver) }
|
28
|
+
latest_version = VersionSorter.rsort(versions).first
|
29
|
+
|
30
|
+
repo_ref = ref
|
31
|
+
if repos_no_ver.include?(repo_name)
|
32
|
+
repo_path = "#{tmp_repo_path_no_ver}/#{repo_name}"
|
33
|
+
else
|
34
|
+
base_repo_path = "#{tmp_repo_path}/#{repo_name}/#{repo_refs[repo_name].first}"
|
35
|
+
base_repo = SocialSnippet::Repository::Drivers::BaseRepository.new(base_repo_path)
|
36
|
+
allow(base_repo).to receive(:refs).and_return repo_refs[repo_name]
|
37
|
+
base_repo.load_snippet_json
|
38
|
+
repo_version = base_repo.latest_version ref
|
39
|
+
if repo_version.nil?
|
40
|
+
repo_path = "#{tmp_repo_path}/#{repo_name}/#{repo_ref}"
|
41
|
+
unless Dir.exists?(repo_path)
|
42
|
+
raise SocialSnippet::Repository::Errors::NotExistRef
|
43
|
+
end
|
44
|
+
else
|
45
|
+
repo_path = "#{tmp_repo_path}/#{repo_name}/#{repo_version}"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
repo = SocialSnippet::Repository::Drivers::BaseRepository.new(repo_path)
|
49
|
+
allow(repo).to receive(:refs).and_return repo_refs[repo_name]
|
50
|
+
allow(repo).to receive(:commit_id).and_return "#{repo_version}#{commit_id}"
|
51
|
+
repo.load_snippet_json
|
52
|
+
repo.create_cache repo_cache_path
|
53
|
+
repo
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe "#insert_snippet" do
|
58
|
+
|
59
|
+
context "use commit id" do
|
60
|
+
|
61
|
+
before do
|
62
|
+
repo_name = "my-repo"
|
63
|
+
ref_name = "thisisdu"
|
64
|
+
|
65
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}"
|
66
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}/.git"
|
67
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json"
|
68
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/file.c"
|
69
|
+
|
70
|
+
# snippet.json
|
71
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json", [
|
72
|
+
'{"name": "' + repo_name + '"}'
|
73
|
+
].join("\n")
|
74
|
+
|
75
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/file.c", [
|
76
|
+
'/* file.c */'
|
77
|
+
].join("\n")
|
78
|
+
|
79
|
+
end # prepare my-repo#thisisdu
|
80
|
+
|
81
|
+
before { find_repo_mock }
|
82
|
+
|
83
|
+
context "snip my-repo#thisisdu" do
|
84
|
+
|
85
|
+
let(:input) do
|
86
|
+
[
|
87
|
+
'/* main.c */',
|
88
|
+
'@snip<my-repo#thisisdu:file.c>',
|
89
|
+
].join("\n")
|
90
|
+
end
|
91
|
+
|
92
|
+
let(:output) do
|
93
|
+
[
|
94
|
+
'/* main.c */',
|
95
|
+
'@snippet<my-repo#thisisdu:file.c>',
|
96
|
+
'/* file.c */',
|
97
|
+
].join("\n")
|
98
|
+
end
|
99
|
+
|
100
|
+
subject { fake_social_snippet.api.insert_snippet input }
|
101
|
+
it { should eq output }
|
102
|
+
|
103
|
+
end # snip my-repo#thisisdu
|
104
|
+
|
105
|
+
context "snip my-repo#notexist" do
|
106
|
+
|
107
|
+
let(:input) do
|
108
|
+
[
|
109
|
+
'/* main.c */',
|
110
|
+
'@snip<my-repo#notexist:file.c>',
|
111
|
+
].join("\n")
|
112
|
+
end
|
113
|
+
|
114
|
+
it do
|
115
|
+
expect { fake_social_snippet.api.insert_snippet input }.to(
|
116
|
+
raise_error(SocialSnippet::Repository::Errors::NotExistRef)
|
117
|
+
)
|
118
|
+
end
|
119
|
+
|
120
|
+
end # snip my-repo#thisisdu
|
121
|
+
|
122
|
+
end # use commid id
|
123
|
+
|
124
|
+
context "version up" do
|
125
|
+
|
126
|
+
context "snip my-repo#1" do
|
127
|
+
|
128
|
+
let(:input) do
|
129
|
+
[
|
130
|
+
'/* @snip<my-repo#1:func.c> */',
|
131
|
+
'main',
|
132
|
+
].join("\n")
|
133
|
+
end
|
134
|
+
|
135
|
+
context "release 1.0.0" do
|
136
|
+
|
137
|
+
before do
|
138
|
+
repo_name = "my-repo"
|
139
|
+
ref_name = "1.0.0"
|
140
|
+
|
141
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}"
|
142
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}/.git"
|
143
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json"
|
144
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/func.c"
|
145
|
+
|
146
|
+
# snippet.json
|
147
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json", [
|
148
|
+
'{"name": "' + repo_name + '"}'
|
149
|
+
].join("\n")
|
150
|
+
|
151
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/func.c", [
|
152
|
+
'func: 1.0.0',
|
153
|
+
].join("\n")
|
154
|
+
end # prepare my-repo#1.0.0
|
155
|
+
|
156
|
+
before { find_repo_mock }
|
157
|
+
|
158
|
+
it do
|
159
|
+
expect(fake_social_snippet.api.insert_snippet(input)).to eq [
|
160
|
+
'/* @snippet<my-repo#1.0.0:func.c> */',
|
161
|
+
'func: 1.0.0',
|
162
|
+
'main',
|
163
|
+
].join("\n").freeze
|
164
|
+
end
|
165
|
+
|
166
|
+
context "release 1.0.1" do
|
167
|
+
|
168
|
+
before do
|
169
|
+
repo_name = "my-repo"
|
170
|
+
ref_name = "1.0.1"
|
171
|
+
|
172
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}"
|
173
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}/.git"
|
174
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json"
|
175
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/func.c"
|
176
|
+
|
177
|
+
# snippet.json
|
178
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json", [
|
179
|
+
'{"name": "' + repo_name + '"}'
|
180
|
+
].join("\n")
|
181
|
+
|
182
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/func.c", [
|
183
|
+
'func: 1.0.1',
|
184
|
+
].join("\n")
|
185
|
+
end # prepare my-repo#1.0.1
|
186
|
+
|
187
|
+
before { find_repo_mock }
|
188
|
+
|
189
|
+
it do
|
190
|
+
expect(fake_social_snippet.api.insert_snippet(input)).to eq [
|
191
|
+
'/* @snippet<my-repo#1.0.1:func.c> */',
|
192
|
+
'func: 1.0.1',
|
193
|
+
'main',
|
194
|
+
].join("\n").freeze
|
195
|
+
end
|
196
|
+
|
197
|
+
context "release 1.1.0" do
|
198
|
+
|
199
|
+
before do
|
200
|
+
repo_name = "my-repo"
|
201
|
+
ref_name = "1.1.0"
|
202
|
+
|
203
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}"
|
204
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}/.git"
|
205
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json"
|
206
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/func.c"
|
207
|
+
|
208
|
+
# snippet.json
|
209
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json", [
|
210
|
+
'{"name": "' + repo_name + '"}'
|
211
|
+
].join("\n")
|
212
|
+
|
213
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/func.c", [
|
214
|
+
'func: 1.1.0',
|
215
|
+
].join("\n")
|
216
|
+
end # prepare my-repo#1.1.0
|
217
|
+
|
218
|
+
before { find_repo_mock }
|
219
|
+
|
220
|
+
it do
|
221
|
+
expect(fake_social_snippet.api.insert_snippet(input)).to eq [
|
222
|
+
'/* @snippet<my-repo#1.1.0:func.c> */',
|
223
|
+
'func: 1.1.0',
|
224
|
+
'main',
|
225
|
+
].join("\n").freeze
|
226
|
+
end
|
227
|
+
|
228
|
+
context "release 9.9.9" do
|
229
|
+
|
230
|
+
before do
|
231
|
+
repo_name = "my-repo"
|
232
|
+
ref_name = "9.9.9"
|
233
|
+
|
234
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}"
|
235
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}/.git"
|
236
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json"
|
237
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/func.c"
|
238
|
+
|
239
|
+
# snippet.json
|
240
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json", [
|
241
|
+
'{"name": "' + repo_name + '"}'
|
242
|
+
].join("\n")
|
243
|
+
|
244
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/func.c", [
|
245
|
+
'func: 9.9.9',
|
246
|
+
].join("\n")
|
247
|
+
end # prepare my-repo#9.9.9
|
248
|
+
|
249
|
+
before { find_repo_mock }
|
250
|
+
|
251
|
+
it do
|
252
|
+
expect(fake_social_snippet.api.insert_snippet(input)).to eq [
|
253
|
+
'/* @snippet<my-repo#1.1.0:func.c> */',
|
254
|
+
'func: 1.1.0',
|
255
|
+
'main',
|
256
|
+
].join("\n").freeze
|
257
|
+
end
|
258
|
+
|
259
|
+
end # release 9.9.9
|
260
|
+
|
261
|
+
end # release 1.1.0
|
262
|
+
|
263
|
+
end # release 1.0.1
|
264
|
+
|
265
|
+
end # release 1.0.0
|
266
|
+
|
267
|
+
end # snip my-repo#1
|
268
|
+
|
269
|
+
end # version up
|
270
|
+
|
271
|
+
context "use parent path" do
|
272
|
+
|
273
|
+
before do
|
274
|
+
repo_name = "my-repo"
|
275
|
+
ref_name = "1.2.3"
|
276
|
+
|
277
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}"
|
278
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}/.git"
|
279
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json"
|
280
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src"
|
281
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src/file_1"
|
282
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src/subdir_a"
|
283
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src/subdir_a/file_2"
|
284
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src/subdir_b"
|
285
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src/subdir_b/file_3"
|
286
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src/subdir_c"
|
287
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src/subdir_c/file_4"
|
288
|
+
|
289
|
+
# snippet.json
|
290
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json", [
|
291
|
+
'{"name": "' + repo_name + '", "main": "src"}'
|
292
|
+
].join("\n")
|
293
|
+
|
294
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src/file_1", [
|
295
|
+
'@snip<subdir_a/file_2>',
|
296
|
+
'file_1',
|
297
|
+
].join("\n")
|
298
|
+
|
299
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src/subdir_a/file_2", [
|
300
|
+
'@snip<../subdir_b/file_3>',
|
301
|
+
'file_2',
|
302
|
+
].join("\n")
|
303
|
+
|
304
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src/subdir_b/file_3", [
|
305
|
+
'@snip<../subdir_c/file_4>',
|
306
|
+
'file_3',
|
307
|
+
].join("\n")
|
308
|
+
|
309
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src/subdir_c/file_4", [
|
310
|
+
'file_4',
|
311
|
+
].join("\n")
|
312
|
+
end # prepare my-repo#1.2.3
|
313
|
+
|
314
|
+
before { find_repo_mock }
|
315
|
+
|
316
|
+
context "snip my-repo:file_1" do
|
317
|
+
|
318
|
+
let(:input) do
|
319
|
+
[
|
320
|
+
'@snip <my-repo:file_1>',
|
321
|
+
'main',
|
322
|
+
].join("\n").freeze
|
323
|
+
end
|
324
|
+
|
325
|
+
let(:output) do
|
326
|
+
[
|
327
|
+
'@snippet <my-repo#1.2.3:subdir_c/file_4>',
|
328
|
+
'file_4',
|
329
|
+
'@snippet <my-repo#1.2.3:subdir_b/file_3>',
|
330
|
+
'file_3',
|
331
|
+
'@snippet <my-repo#1.2.3:subdir_a/file_2>',
|
332
|
+
'file_2',
|
333
|
+
'@snippet <my-repo#1.2.3:file_1>',
|
334
|
+
'file_1',
|
335
|
+
'main',
|
336
|
+
].join("\n").freeze
|
337
|
+
end
|
338
|
+
|
339
|
+
subject { fake_social_snippet.api.insert_snippet input }
|
340
|
+
it { should eq output }
|
341
|
+
|
342
|
+
end
|
343
|
+
|
344
|
+
end # use parent path
|
345
|
+
|
346
|
+
context "snip self" do
|
347
|
+
|
348
|
+
before do
|
349
|
+
repo_name = "directly"
|
350
|
+
ref_name = "3.2.1"
|
351
|
+
|
352
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}"
|
353
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}"
|
354
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}/.git"
|
355
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json"
|
356
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/1"
|
357
|
+
|
358
|
+
# snippet.json
|
359
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json", [
|
360
|
+
'{"name": "' + repo_name + '"}'
|
361
|
+
].join("\n")
|
362
|
+
|
363
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/1", [
|
364
|
+
'@snip<1>',
|
365
|
+
'1',
|
366
|
+
].join("\n")
|
367
|
+
end # prepare directly#3.2.1
|
368
|
+
|
369
|
+
before do
|
370
|
+
repo_name = "loop-1"
|
371
|
+
ref_name = "1.1.1"
|
372
|
+
|
373
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}"
|
374
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}"
|
375
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}/.git"
|
376
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json"
|
377
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/loop"
|
378
|
+
|
379
|
+
# snippet.json
|
380
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json", [
|
381
|
+
'{"name": "' + repo_name + '"}'
|
382
|
+
].join("\n")
|
383
|
+
|
384
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/loop", [
|
385
|
+
'@snip<loop-2:loop>',
|
386
|
+
'loop-1',
|
387
|
+
].join("\n")
|
388
|
+
end # prepare loop-1#1.1.1
|
389
|
+
|
390
|
+
before do
|
391
|
+
repo_name = "loop-2"
|
392
|
+
ref_name = "1.1.1"
|
393
|
+
|
394
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}"
|
395
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}"
|
396
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}/.git"
|
397
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json"
|
398
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/loop"
|
399
|
+
|
400
|
+
# snippet.json
|
401
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json", [
|
402
|
+
'{"name": "' + repo_name + '"}'
|
403
|
+
].join("\n")
|
404
|
+
|
405
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/loop", [
|
406
|
+
'@snip<loop-3:loop>',
|
407
|
+
'loop-2',
|
408
|
+
].join("\n")
|
409
|
+
end # prepare loop-2#1.1.1
|
410
|
+
|
411
|
+
before do
|
412
|
+
repo_name = "loop-3"
|
413
|
+
ref_name = "1.1.1"
|
414
|
+
|
415
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}"
|
416
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}"
|
417
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}/.git"
|
418
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json"
|
419
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/loop"
|
420
|
+
|
421
|
+
# snippet.json
|
422
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json", [
|
423
|
+
'{"name": "' + repo_name + '"}'
|
424
|
+
].join("\n")
|
425
|
+
|
426
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/loop", [
|
427
|
+
'@snip<loop-1:loop>',
|
428
|
+
'@snip<non-loop-4:non-loop>',
|
429
|
+
'loop-3',
|
430
|
+
].join("\n")
|
431
|
+
end # prepare loop-3#1.1.1
|
432
|
+
|
433
|
+
before do
|
434
|
+
repo_name = "non-loop-4"
|
435
|
+
ref_name = "1.1.1"
|
436
|
+
|
437
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}"
|
438
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}"
|
439
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}/.git"
|
440
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json"
|
441
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/non-loop"
|
442
|
+
|
443
|
+
# snippet.json
|
444
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json", [
|
445
|
+
'{"name": "' + repo_name + '"}'
|
446
|
+
].join("\n")
|
447
|
+
|
448
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/non-loop", [
|
449
|
+
'non-loop-4',
|
450
|
+
].join("\n")
|
451
|
+
end # prepare non-loop-4#1.1.1
|
452
|
+
|
453
|
+
before { find_repo_mock }
|
454
|
+
|
455
|
+
context "indirectly" do
|
456
|
+
|
457
|
+
context "has cyclic loop" do
|
458
|
+
|
459
|
+
let(:input) do
|
460
|
+
[
|
461
|
+
'@snip<loop-1:loop>',
|
462
|
+
'main',
|
463
|
+
].join("\n")
|
464
|
+
end
|
465
|
+
|
466
|
+
let(:output) do
|
467
|
+
[
|
468
|
+
'@snippet<non-loop-4#1.1.1:non-loop>',
|
469
|
+
'non-loop-4',
|
470
|
+
'@snippet<loop-3#1.1.1:loop>',
|
471
|
+
'loop-3',
|
472
|
+
'@snippet<loop-2#1.1.1:loop>',
|
473
|
+
'loop-2',
|
474
|
+
'@snippet<loop-1#1.1.1:loop>',
|
475
|
+
'loop-1',
|
476
|
+
'main',
|
477
|
+
].join("\n")
|
478
|
+
end
|
479
|
+
|
480
|
+
subject { fake_social_snippet.api.insert_snippet input }
|
481
|
+
it { should eq output }
|
482
|
+
|
483
|
+
end # has loop
|
484
|
+
|
485
|
+
end # indirectly
|
486
|
+
|
487
|
+
context "directly" do
|
488
|
+
|
489
|
+
context "snip directly:1" do
|
490
|
+
|
491
|
+
let(:input) do
|
492
|
+
[
|
493
|
+
'@snip<directly:1>',
|
494
|
+
].join("\n").freeze
|
495
|
+
end
|
496
|
+
|
497
|
+
let(:output) do
|
498
|
+
[
|
499
|
+
'@snippet<directly#3.2.1:1>',
|
500
|
+
'1',
|
501
|
+
].join("\n")
|
502
|
+
end
|
503
|
+
|
504
|
+
subject { fake_social_snippet.api.insert_snippet input }
|
505
|
+
it { should eq output }
|
506
|
+
|
507
|
+
end
|
508
|
+
|
509
|
+
end # directly
|
510
|
+
|
511
|
+
end # snip self
|
512
|
+
|
513
|
+
context "snippet snippet ... snippet" do
|
514
|
+
|
515
|
+
before do
|
516
|
+
repo_name = "my-repo-1"
|
517
|
+
ref_name = "0.0.1"
|
518
|
+
|
519
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}"
|
520
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}"
|
521
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}/.git"
|
522
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json"
|
523
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/1"
|
524
|
+
|
525
|
+
# snippet.json
|
526
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json", [
|
527
|
+
'{"name": "' + repo_name + '"}'
|
528
|
+
].join("\n")
|
529
|
+
|
530
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/1", [
|
531
|
+
'@snip<my-repo-2#0:2>',
|
532
|
+
'my-repo-1:1',
|
533
|
+
].join("\n")
|
534
|
+
end # prepare my-repo-1
|
535
|
+
|
536
|
+
before do
|
537
|
+
repo_name = "my-repo-2"
|
538
|
+
ref_name = "0.0.1"
|
539
|
+
|
540
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}"
|
541
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}"
|
542
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}/.git"
|
543
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json"
|
544
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/2"
|
545
|
+
|
546
|
+
# snippet.json
|
547
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json", [
|
548
|
+
'{"name": "' + repo_name + '"}'
|
549
|
+
].join("\n")
|
550
|
+
|
551
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/2", [
|
552
|
+
'@snip<my-repo-3:path/to/3>',
|
553
|
+
'my-repo-2:2',
|
554
|
+
].join("\n")
|
555
|
+
end # prepare my-repo-2#0.0.1
|
556
|
+
|
557
|
+
before do
|
558
|
+
repo_name = "my-repo-2"
|
559
|
+
ref_name = "1.2.3"
|
560
|
+
|
561
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}"
|
562
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}"
|
563
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}/.git"
|
564
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json"
|
565
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/2"
|
566
|
+
|
567
|
+
# snippet.json
|
568
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json", [
|
569
|
+
'{"name": "' + repo_name + '"}'
|
570
|
+
].join("\n")
|
571
|
+
|
572
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/2", [
|
573
|
+
'miss!!',
|
574
|
+
].join("\n")
|
575
|
+
end # prepare my-repo-2#1.2.3
|
576
|
+
|
577
|
+
before do
|
578
|
+
repo_name = "my-repo-3"
|
579
|
+
ref_name = "1.2.3"
|
580
|
+
|
581
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}"
|
582
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}"
|
583
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}/.git"
|
584
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json"
|
585
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}/path"
|
586
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}/path/to"
|
587
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/path/to/3"
|
588
|
+
|
589
|
+
# snippet.json
|
590
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json", [
|
591
|
+
'{"name": "' + repo_name + '"}'
|
592
|
+
].join("\n")
|
593
|
+
|
594
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/path/to/3", [
|
595
|
+
'@snip<my-repo-4:path/to/4>',
|
596
|
+
'my-repo-3:path/to/3',
|
597
|
+
].join("\n")
|
598
|
+
end # prepare my-repo-3#1.2.3
|
599
|
+
|
600
|
+
before do
|
601
|
+
repo_name = "my-repo-4"
|
602
|
+
ref_name = "1.2.3"
|
603
|
+
|
604
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}"
|
605
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}"
|
606
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}/.git"
|
607
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json"
|
608
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}/.git"
|
609
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}/sources"
|
610
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}/sources/path"
|
611
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}/sources/path/to"
|
612
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/sources/path/to/4"
|
613
|
+
|
614
|
+
# snippet.json
|
615
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json", [
|
616
|
+
'{"name": "' + repo_name + '", "main": "sources"}'
|
617
|
+
].join("\n")
|
618
|
+
|
619
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/sources/path/to/4", [
|
620
|
+
'@snip<my-repo-5:path/to/5>',
|
621
|
+
'my-repo-4:sources/path/to/4',
|
622
|
+
].join("\n")
|
623
|
+
end # prepare my-repo-4#1.2.3
|
624
|
+
|
625
|
+
before do
|
626
|
+
repo_name = "my-repo-5"
|
627
|
+
ref_name = "100.200.300"
|
628
|
+
|
629
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}"
|
630
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}"
|
631
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}/.git"
|
632
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json"
|
633
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}/.git"
|
634
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}/sources"
|
635
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}/sources/path"
|
636
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}/sources/path/to"
|
637
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/sources/path/to/5"
|
638
|
+
|
639
|
+
# snippet.json
|
640
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json", [
|
641
|
+
'{"name": "' + repo_name + '", "main": "sources"}'
|
642
|
+
].join("\n")
|
643
|
+
|
644
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/sources/path/to/5", [
|
645
|
+
'@snip<my-repo-6:path/to/6>',
|
646
|
+
'my-repo-5:sources/path/to/5',
|
647
|
+
].join("\n")
|
648
|
+
end # prepare my-repo-5#100.200.300
|
649
|
+
|
650
|
+
before do
|
651
|
+
repo_name = "my-repo-5"
|
652
|
+
ref_name = "99.999.999"
|
653
|
+
|
654
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}"
|
655
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}"
|
656
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}/.git"
|
657
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json"
|
658
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}/.git"
|
659
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}/sources"
|
660
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}/sources/path"
|
661
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}/sources/path/to"
|
662
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/sources/path/to/5"
|
663
|
+
|
664
|
+
# snippet.json
|
665
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json", [
|
666
|
+
'{"name": "' + repo_name + '", "main": "sources"}'
|
667
|
+
].join("\n")
|
668
|
+
|
669
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/sources/path/to/5", [
|
670
|
+
'miss!!',
|
671
|
+
'my-repo-5:5',
|
672
|
+
].join("\n")
|
673
|
+
end # prepare my-repo-5#99.999.999
|
674
|
+
|
675
|
+
before do
|
676
|
+
repo_name = "my-repo-6"
|
677
|
+
|
678
|
+
FileUtils.mkdir_p "#{tmp_repo_path_no_ver}/#{repo_name}"
|
679
|
+
FileUtils.mkdir_p "#{tmp_repo_path_no_ver}/#{repo_name}/.git"
|
680
|
+
FileUtils.touch "#{tmp_repo_path_no_ver}/#{repo_name}/snippet.json"
|
681
|
+
FileUtils.mkdir_p "#{tmp_repo_path_no_ver}/#{repo_name}/sources"
|
682
|
+
FileUtils.mkdir_p "#{tmp_repo_path_no_ver}/#{repo_name}/sources/path"
|
683
|
+
FileUtils.mkdir_p "#{tmp_repo_path_no_ver}/#{repo_name}/sources/path/to"
|
684
|
+
FileUtils.touch "#{tmp_repo_path_no_ver}/#{repo_name}/sources/path/to/6"
|
685
|
+
|
686
|
+
# snippet.json
|
687
|
+
File.write "#{tmp_repo_path_no_ver}/#{repo_name}/snippet.json", [
|
688
|
+
'{"name": "' + repo_name + '", "main": "sources"}'
|
689
|
+
].join("\n")
|
690
|
+
|
691
|
+
File.write "#{tmp_repo_path_no_ver}/#{repo_name}/sources/path/to/6", [
|
692
|
+
'@snip<my-repo-7:path/to/7>',
|
693
|
+
'my-repo-6:sources/path/to/6',
|
694
|
+
].join("\n")
|
695
|
+
end # prepare my-repo-6
|
696
|
+
|
697
|
+
before do
|
698
|
+
repo_name = "my-repo-7"
|
699
|
+
ref_name = "1.2.3"
|
700
|
+
|
701
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}"
|
702
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}"
|
703
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}/.git"
|
704
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json"
|
705
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}/.git"
|
706
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}/sources"
|
707
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}/sources/path"
|
708
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}/sources/path/to"
|
709
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/sources/path/to/7"
|
710
|
+
|
711
|
+
# snippet.json
|
712
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json", [
|
713
|
+
'{"name": "' + repo_name + '", "main": "sources"}'
|
714
|
+
].join("\n")
|
715
|
+
|
716
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/sources/path/to/7", [
|
717
|
+
'end',
|
718
|
+
'my-repo-7:sources/path/to/7',
|
719
|
+
].join("\n")
|
720
|
+
end # prepare my-repo-7#1.2.3
|
721
|
+
|
722
|
+
before { find_repo_mock }
|
723
|
+
|
724
|
+
context "snip my-repo-1:1" do
|
725
|
+
|
726
|
+
let(:input) do
|
727
|
+
[
|
728
|
+
'/* @snip <my-repo-1:1> */',
|
729
|
+
].join("\n").freeze
|
730
|
+
end
|
731
|
+
|
732
|
+
let(:output) do
|
733
|
+
[
|
734
|
+
'/* @snippet <my-repo-7#1.2.3:path/to/7> */',
|
735
|
+
'end',
|
736
|
+
'my-repo-7:sources/path/to/7',
|
737
|
+
'/* @snippet <my-repo-6#thisisdu:path/to/6> */',
|
738
|
+
'my-repo-6:sources/path/to/6',
|
739
|
+
'/* @snippet <my-repo-5#100.200.300:path/to/5> */',
|
740
|
+
'my-repo-5:sources/path/to/5',
|
741
|
+
'/* @snippet <my-repo-4#1.2.3:path/to/4> */',
|
742
|
+
'my-repo-4:sources/path/to/4',
|
743
|
+
'/* @snippet <my-repo-3#1.2.3:path/to/3> */',
|
744
|
+
'my-repo-3:path/to/3',
|
745
|
+
'/* @snippet <my-repo-2#0.0.1:2> */',
|
746
|
+
'my-repo-2:2',
|
747
|
+
'/* @snippet <my-repo-1#0.0.1:1> */',
|
748
|
+
'my-repo-1:1',
|
749
|
+
].join("\n").freeze
|
750
|
+
end
|
751
|
+
|
752
|
+
subject { fake_social_snippet.api.insert_snippet input }
|
753
|
+
it { should eq output }
|
754
|
+
|
755
|
+
end # snip my-repo-1:1
|
756
|
+
|
757
|
+
end # snippet snippet ... snippet
|
758
|
+
|
759
|
+
context "snippet snippets" do
|
760
|
+
|
761
|
+
before do
|
762
|
+
repo_name = "my-repo"
|
763
|
+
ref_name = "0.0.1"
|
764
|
+
|
765
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}"
|
766
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}"
|
767
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}/.git"
|
768
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json"
|
769
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/1"
|
770
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/2"
|
771
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/3"
|
772
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/4"
|
773
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/5"
|
774
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/6"
|
775
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/7"
|
776
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/8"
|
777
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/9"
|
778
|
+
|
779
|
+
# snippet.json
|
780
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json", [
|
781
|
+
'{"name": "' + repo_name + '"}'
|
782
|
+
].join("\n")
|
783
|
+
|
784
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/1", [
|
785
|
+
'@snip<5>',
|
786
|
+
'@snip<4>',
|
787
|
+
'@snip<3>',
|
788
|
+
'@snip<2>',
|
789
|
+
'1',
|
790
|
+
].join("\n")
|
791
|
+
|
792
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/2", [
|
793
|
+
'@snip<9>',
|
794
|
+
'@snip<8>',
|
795
|
+
'@snip<7>',
|
796
|
+
'@snip<6>',
|
797
|
+
'2',
|
798
|
+
].join("\n")
|
799
|
+
|
800
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/3", [
|
801
|
+
'3',
|
802
|
+
].join("\n")
|
803
|
+
|
804
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/4", [
|
805
|
+
'4',
|
806
|
+
].join("\n")
|
807
|
+
|
808
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/5", [
|
809
|
+
'5',
|
810
|
+
].join("\n")
|
811
|
+
|
812
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/6", [
|
813
|
+
'6',
|
814
|
+
].join("\n")
|
815
|
+
|
816
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/7", [
|
817
|
+
'7',
|
818
|
+
].join("\n")
|
819
|
+
|
820
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/8", [
|
821
|
+
'8',
|
822
|
+
].join("\n")
|
823
|
+
|
824
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/9", [
|
825
|
+
'9',
|
826
|
+
].join("\n")
|
827
|
+
end
|
828
|
+
|
829
|
+
before { find_repo_mock }
|
830
|
+
|
831
|
+
let(:input) do
|
832
|
+
[
|
833
|
+
'@snip<my-repo:1>',
|
834
|
+
'main',
|
835
|
+
].join("\n").freeze
|
836
|
+
end
|
837
|
+
|
838
|
+
let(:output) do
|
839
|
+
[
|
840
|
+
'@snippet<my-repo#0.0.1:5>',
|
841
|
+
'5',
|
842
|
+
'@snippet<my-repo#0.0.1:4>',
|
843
|
+
'4',
|
844
|
+
'@snippet<my-repo#0.0.1:3>',
|
845
|
+
'3',
|
846
|
+
'@snippet<my-repo#0.0.1:9>',
|
847
|
+
'9',
|
848
|
+
'@snippet<my-repo#0.0.1:8>',
|
849
|
+
'8',
|
850
|
+
'@snippet<my-repo#0.0.1:7>',
|
851
|
+
'7',
|
852
|
+
'@snippet<my-repo#0.0.1:6>',
|
853
|
+
'6',
|
854
|
+
'@snippet<my-repo#0.0.1:2>',
|
855
|
+
'2',
|
856
|
+
'@snippet<my-repo#0.0.1:1>',
|
857
|
+
'1',
|
858
|
+
'main',
|
859
|
+
].join("\n")
|
860
|
+
end
|
861
|
+
|
862
|
+
subject { fake_social_snippet.api.insert_snippet input }
|
863
|
+
it { should eq output }
|
864
|
+
|
865
|
+
end # snippet snippets
|
866
|
+
|
867
|
+
context "use multiple repos and multiple versions" do
|
868
|
+
|
869
|
+
before do
|
870
|
+
repo_name = "my-repo"
|
871
|
+
ref_name = "0.0.3"
|
872
|
+
|
873
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}"
|
874
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}"
|
875
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}/.git"
|
876
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src"
|
877
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json"
|
878
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src/1.rb"
|
879
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src/2.rb"
|
880
|
+
|
881
|
+
# snippet.json
|
882
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json", [
|
883
|
+
'{"name": "' + repo_name + '", "main": "src"}',
|
884
|
+
].join("\n")
|
885
|
+
|
886
|
+
# src/1.rb
|
887
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src/1.rb", [
|
888
|
+
'# @snip</2.rb>',
|
889
|
+
'OK',
|
890
|
+
].join("\n")
|
891
|
+
|
892
|
+
# src/2.rb
|
893
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src/2.rb", [
|
894
|
+
'0.0.3',
|
895
|
+
].join("\n")
|
896
|
+
|
897
|
+
end # prepare my-repo#0.0.3
|
898
|
+
|
899
|
+
before do
|
900
|
+
repo_name = "my-repo"
|
901
|
+
ref_name = "0.0.2"
|
902
|
+
|
903
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}"
|
904
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}"
|
905
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}/.git"
|
906
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src"
|
907
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json"
|
908
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src/1.rb"
|
909
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src/2.rb"
|
910
|
+
|
911
|
+
# snippet.json
|
912
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json", [
|
913
|
+
'{"name": "' + repo_name + '", "main": "src"}',
|
914
|
+
].join("\n")
|
915
|
+
|
916
|
+
# src/1.rb
|
917
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src/1.rb", [
|
918
|
+
'# @snip</2.rb>',
|
919
|
+
'def func_1',
|
920
|
+
' return 2 * func_2()',
|
921
|
+
'end',
|
922
|
+
].join("\n")
|
923
|
+
|
924
|
+
# src/2.rb
|
925
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src/2.rb", [
|
926
|
+
'ERROR_CASE',
|
927
|
+
].join("\n")
|
928
|
+
|
929
|
+
end # prepare my-repo#0.0.2
|
930
|
+
|
931
|
+
before do
|
932
|
+
repo_name = "my-repo"
|
933
|
+
ref_name = "0.0.1"
|
934
|
+
|
935
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}"
|
936
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}"
|
937
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}/.git"
|
938
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src"
|
939
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json"
|
940
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src/1.rb"
|
941
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src/2.rb"
|
942
|
+
|
943
|
+
# snippet.json
|
944
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json", [
|
945
|
+
'{"name": "' + repo_name + '", "main": "src"}',
|
946
|
+
].join("\n")
|
947
|
+
|
948
|
+
# src/1.rb
|
949
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src/1.rb", [
|
950
|
+
'# @snip</2.rb>',
|
951
|
+
'def func_1',
|
952
|
+
' return 2 * func_2()',
|
953
|
+
'end',
|
954
|
+
].join("\n")
|
955
|
+
|
956
|
+
# src/2.rb
|
957
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src/2.rb", [
|
958
|
+
'ERROR_CASE',
|
959
|
+
].join("\n")
|
960
|
+
|
961
|
+
end # prepare my-repo#0.0.1
|
962
|
+
|
963
|
+
before do
|
964
|
+
repo_name = "my-repo"
|
965
|
+
ref_name = "1.0.0"
|
966
|
+
|
967
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}"
|
968
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}"
|
969
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}/.git"
|
970
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src"
|
971
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json"
|
972
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src/1.rb"
|
973
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src/2.rb"
|
974
|
+
|
975
|
+
# snippet.json
|
976
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json", [
|
977
|
+
'{"name": "' + repo_name + '", "main": "src"}',
|
978
|
+
].join("\n")
|
979
|
+
|
980
|
+
# src/1.rb
|
981
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src/1.rb", [
|
982
|
+
'# @snip</2.rb>',
|
983
|
+
'def func_1',
|
984
|
+
' return 2 * func_2()',
|
985
|
+
'end',
|
986
|
+
].join("\n")
|
987
|
+
|
988
|
+
# src/2.rb
|
989
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src/2.rb", [
|
990
|
+
'THIS_IS_OK',
|
991
|
+
].join("\n")
|
992
|
+
end # prepare my-repo#1.0.0
|
993
|
+
|
994
|
+
before do
|
995
|
+
repo_name = "new-my-repo"
|
996
|
+
ref_name = "0.0.1"
|
997
|
+
|
998
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}"
|
999
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}"
|
1000
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}/.git"
|
1001
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src"
|
1002
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json"
|
1003
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src/1.rb"
|
1004
|
+
|
1005
|
+
# snippet.json
|
1006
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json", [
|
1007
|
+
'{"name": "' + repo_name + '", "main": "src"}',
|
1008
|
+
].join("\n")
|
1009
|
+
|
1010
|
+
# src/1.rb
|
1011
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src/1.rb", [
|
1012
|
+
'OLD VERSION',
|
1013
|
+
].join("\n")
|
1014
|
+
end # prepare new-my-repo#0.0.1
|
1015
|
+
|
1016
|
+
before do
|
1017
|
+
repo_name = "new-my-repo"
|
1018
|
+
ref_name = "0.0.2"
|
1019
|
+
|
1020
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}"
|
1021
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}"
|
1022
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}/.git"
|
1023
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src"
|
1024
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json"
|
1025
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src/1.rb"
|
1026
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src/2.rb"
|
1027
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src/3.rb"
|
1028
|
+
|
1029
|
+
# snippet.json
|
1030
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json", [
|
1031
|
+
'{"name": "' + repo_name + '", "main": "src"}',
|
1032
|
+
].join("\n")
|
1033
|
+
|
1034
|
+
# src/1.rb
|
1035
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src/1.rb", [
|
1036
|
+
'# @snip <my-repo#0:1.rb>',
|
1037
|
+
'# @snip </2.rb>',
|
1038
|
+
'# @snip <3.rb>',
|
1039
|
+
'GOOD VERSION',
|
1040
|
+
].join("\n")
|
1041
|
+
|
1042
|
+
# src/2.rb
|
1043
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src/2.rb", [
|
1044
|
+
'OK: 2.rb',
|
1045
|
+
].join("\n")
|
1046
|
+
|
1047
|
+
# src/3.rb
|
1048
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src/3.rb", [
|
1049
|
+
'OK: 3.rb',
|
1050
|
+
].join("\n")
|
1051
|
+
end # prepare new-my-repo#0.0.2
|
1052
|
+
|
1053
|
+
before do
|
1054
|
+
find_repo_mock
|
1055
|
+
end
|
1056
|
+
|
1057
|
+
context "use my-repo" do
|
1058
|
+
|
1059
|
+
let(:input) do
|
1060
|
+
[
|
1061
|
+
'@snip<my-repo:1.rb>',
|
1062
|
+
].join("\n")
|
1063
|
+
end
|
1064
|
+
|
1065
|
+
let(:output) do
|
1066
|
+
[
|
1067
|
+
'@snippet<my-repo#1.0.0:2.rb>',
|
1068
|
+
'THIS_IS_OK',
|
1069
|
+
'@snippet<my-repo#1.0.0:1.rb>',
|
1070
|
+
'def func_1',
|
1071
|
+
' return 2 * func_2()',
|
1072
|
+
'end',
|
1073
|
+
].join("\n")
|
1074
|
+
end
|
1075
|
+
|
1076
|
+
subject { fake_social_snippet.api.insert_snippet input }
|
1077
|
+
it { should eq output }
|
1078
|
+
|
1079
|
+
end # use my-repo
|
1080
|
+
|
1081
|
+
context "use my-repo#1" do
|
1082
|
+
|
1083
|
+
let(:input) do
|
1084
|
+
[
|
1085
|
+
'@snip<my-repo#1:1.rb>',
|
1086
|
+
].join("\n")
|
1087
|
+
end
|
1088
|
+
|
1089
|
+
let(:output) do
|
1090
|
+
[
|
1091
|
+
'@snippet<my-repo#1.0.0:2.rb>',
|
1092
|
+
'THIS_IS_OK',
|
1093
|
+
'@snippet<my-repo#1.0.0:1.rb>',
|
1094
|
+
'def func_1',
|
1095
|
+
' return 2 * func_2()',
|
1096
|
+
'end',
|
1097
|
+
].join("\n")
|
1098
|
+
end
|
1099
|
+
|
1100
|
+
subject { fake_social_snippet.api.insert_snippet input }
|
1101
|
+
it { should eq output }
|
1102
|
+
|
1103
|
+
end # use my-repo#1
|
1104
|
+
|
1105
|
+
context "use my-repo#1 and my-repo#0" do
|
1106
|
+
|
1107
|
+
let(:input) do
|
1108
|
+
[
|
1109
|
+
'@snip<my-repo#1:1.rb>',
|
1110
|
+
'@snip<my-repo#0:1.rb>',
|
1111
|
+
].join("\n")
|
1112
|
+
end
|
1113
|
+
|
1114
|
+
let(:output) do
|
1115
|
+
[
|
1116
|
+
'@snippet<my-repo#1.0.0:2.rb>',
|
1117
|
+
'THIS_IS_OK',
|
1118
|
+
'@snippet<my-repo#1.0.0:1.rb>',
|
1119
|
+
'def func_1',
|
1120
|
+
' return 2 * func_2()',
|
1121
|
+
'end',
|
1122
|
+
'@snippet<my-repo#0.0.3:2.rb>',
|
1123
|
+
'0.0.3',
|
1124
|
+
'@snippet<my-repo#0.0.3:1.rb>',
|
1125
|
+
'OK',
|
1126
|
+
].join("\n")
|
1127
|
+
end
|
1128
|
+
|
1129
|
+
subject { fake_social_snippet.api.insert_snippet input }
|
1130
|
+
it { should eq output }
|
1131
|
+
|
1132
|
+
end # use my-repo#1 and my-repo#0
|
1133
|
+
|
1134
|
+
context "use new-my-repo" do
|
1135
|
+
|
1136
|
+
let(:input) do
|
1137
|
+
[
|
1138
|
+
'# @snip <new-my-repo:1.rb>',
|
1139
|
+
].join("\n")
|
1140
|
+
end
|
1141
|
+
|
1142
|
+
let(:output) do
|
1143
|
+
[
|
1144
|
+
'# @snippet <my-repo#0.0.3:2.rb>',
|
1145
|
+
'0.0.3',
|
1146
|
+
'# @snippet <my-repo#0.0.3:1.rb>',
|
1147
|
+
'OK',
|
1148
|
+
'# @snippet <new-my-repo#0.0.2:2.rb>',
|
1149
|
+
'OK: 2.rb',
|
1150
|
+
'# @snippet <new-my-repo#0.0.2:3.rb>',
|
1151
|
+
'OK: 3.rb',
|
1152
|
+
'# @snippet <new-my-repo#0.0.2:1.rb>',
|
1153
|
+
'GOOD VERSION',
|
1154
|
+
].join("\n")
|
1155
|
+
end
|
1156
|
+
|
1157
|
+
subject { fake_social_snippet.api.insert_snippet input }
|
1158
|
+
it { should eq output }
|
1159
|
+
|
1160
|
+
end # use new-my-repo
|
1161
|
+
|
1162
|
+
end # use multiple repos and multiple versions
|
1163
|
+
|
1164
|
+
context "use latest version without ref" do
|
1165
|
+
|
1166
|
+
before do
|
1167
|
+
repo_name = "my-repo"
|
1168
|
+
ref_name = "0.0.3"
|
1169
|
+
|
1170
|
+
FileUtils.mkdir_p "#{tmp_repo_path}"
|
1171
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}"
|
1172
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}/.git"
|
1173
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src"
|
1174
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json"
|
1175
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src/1.rb"
|
1176
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src/2.rb"
|
1177
|
+
|
1178
|
+
# snippet.json
|
1179
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/snippet.json", [
|
1180
|
+
'{"name": "' + repo_name + '", "main": "src"}',
|
1181
|
+
].join("\n")
|
1182
|
+
|
1183
|
+
# src/1.rb
|
1184
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src/1.rb", [
|
1185
|
+
'# @snip</2.rb>',
|
1186
|
+
'def func_1',
|
1187
|
+
' return 2 * func_2()',
|
1188
|
+
'end',
|
1189
|
+
].join("\n")
|
1190
|
+
|
1191
|
+
# src/2.rb
|
1192
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{ref_name}/src/2.rb", [
|
1193
|
+
'def func_2',
|
1194
|
+
' return 42',
|
1195
|
+
'end',
|
1196
|
+
].join("\n")
|
1197
|
+
|
1198
|
+
end # prepare my-repo#0.0.3
|
1199
|
+
|
1200
|
+
before { find_repo_mock }
|
1201
|
+
|
1202
|
+
let(:input) do
|
1203
|
+
[
|
1204
|
+
'#@snip <my-repo:1.rb>',
|
1205
|
+
].join("\n")
|
1206
|
+
end
|
1207
|
+
|
1208
|
+
let(:output) do
|
1209
|
+
[
|
1210
|
+
'#@snippet <my-repo#0.0.3:2.rb>',
|
1211
|
+
'def func_2',
|
1212
|
+
' return 42',
|
1213
|
+
'end',
|
1214
|
+
'#@snippet <my-repo#0.0.3:1.rb>',
|
1215
|
+
'def func_1',
|
1216
|
+
' return 2 * func_2()',
|
1217
|
+
'end',
|
1218
|
+
].join("\n")
|
1219
|
+
end
|
1220
|
+
|
1221
|
+
subject { fake_social_snippet.api.insert_snippet input }
|
1222
|
+
it { should eq output }
|
1223
|
+
|
1224
|
+
end # use latest version without ref
|
1225
|
+
|
1226
|
+
context "snippet snippet with ref" do
|
1227
|
+
|
1228
|
+
before do
|
1229
|
+
repo_name = "my-repo"
|
1230
|
+
ref_name = "0.0.1"
|
1231
|
+
|
1232
|
+
FileUtils.mkdir_p "#{repo_path}"
|
1233
|
+
FileUtils.mkdir_p "#{repo_path}/#{repo_name}/#{ref_name}"
|
1234
|
+
FileUtils.mkdir_p "#{repo_path}/#{repo_name}/#{ref_name}/.git"
|
1235
|
+
FileUtils.mkdir_p "#{repo_path}/#{repo_name}/#{ref_name}/src"
|
1236
|
+
FileUtils.touch "#{repo_path}/#{repo_name}/#{ref_name}/snippet.json"
|
1237
|
+
FileUtils.touch "#{repo_path}/#{repo_name}/#{ref_name}/src/1.rb"
|
1238
|
+
FileUtils.touch "#{repo_path}/#{repo_name}/#{ref_name}/src/2.rb"
|
1239
|
+
|
1240
|
+
# snippet.json
|
1241
|
+
File.write "#{repo_path}/#{repo_name}/#{ref_name}/snippet.json", [
|
1242
|
+
'{"name": "' + repo_name + '", "main": "src"}',
|
1243
|
+
].join("\n")
|
1244
|
+
|
1245
|
+
# src/1.rb
|
1246
|
+
File.write "#{repo_path}/#{repo_name}/#{ref_name}/src/1.rb", [
|
1247
|
+
'# @snip</2.rb>',
|
1248
|
+
'def func_1',
|
1249
|
+
' return 2 * func_2()',
|
1250
|
+
'end',
|
1251
|
+
].join("\n")
|
1252
|
+
|
1253
|
+
# src/2.rb
|
1254
|
+
File.write "#{repo_path}/#{repo_name}/#{ref_name}/src/2.rb", [
|
1255
|
+
'def func_2',
|
1256
|
+
' return 42',
|
1257
|
+
'end',
|
1258
|
+
].join("\n")
|
1259
|
+
|
1260
|
+
allow(fake_social_snippet.repo_manager).to receive(:find_repository).with(repo_name, ref_name) do
|
1261
|
+
repo = SocialSnippet::Repository::Drivers::BaseRepository.new("#{repo_path}/#{repo_name}/#{ref_name}")
|
1262
|
+
allow(repo).to receive(:refs).and_return([
|
1263
|
+
'0.0.1',
|
1264
|
+
'0.0.2',
|
1265
|
+
])
|
1266
|
+
allow(repo).to receive(:commit_id).and_return "#{ref_name}#{commit_id}"
|
1267
|
+
repo.load_snippet_json
|
1268
|
+
repo.create_cache repo_cache_path
|
1269
|
+
repo
|
1270
|
+
end
|
1271
|
+
|
1272
|
+
end # prepare my-repo#0.0.1
|
1273
|
+
|
1274
|
+
before do
|
1275
|
+
repo_name = "my-repo"
|
1276
|
+
ref_name = "0.0.2"
|
1277
|
+
|
1278
|
+
FileUtils.mkdir_p "#{repo_path}"
|
1279
|
+
FileUtils.mkdir_p "#{repo_path}/#{repo_name}/#{ref_name}"
|
1280
|
+
FileUtils.mkdir_p "#{repo_path}/#{repo_name}/#{ref_name}/.git"
|
1281
|
+
FileUtils.mkdir_p "#{repo_path}/#{repo_name}/#{ref_name}/src"
|
1282
|
+
FileUtils.touch "#{repo_path}/#{repo_name}/#{ref_name}/snippet.json"
|
1283
|
+
FileUtils.touch "#{repo_path}/#{repo_name}/#{ref_name}/src/1.rb"
|
1284
|
+
FileUtils.touch "#{repo_path}/#{repo_name}/#{ref_name}/src/2.rb"
|
1285
|
+
|
1286
|
+
# snippet.json
|
1287
|
+
File.write "#{repo_path}/#{repo_name}/#{ref_name}/snippet.json", [
|
1288
|
+
'{"name": "' + repo_name + '", "main": "src"}',
|
1289
|
+
].join("\n")
|
1290
|
+
|
1291
|
+
# src/1.rb
|
1292
|
+
File.write "#{repo_path}/#{repo_name}/#{ref_name}/src/1.rb", [
|
1293
|
+
'# @snip</2.rb>',
|
1294
|
+
'def func_1',
|
1295
|
+
' return 2 * func_2()',
|
1296
|
+
'end',
|
1297
|
+
].join("\n")
|
1298
|
+
|
1299
|
+
# src/2.rb
|
1300
|
+
File.write "#{repo_path}/#{repo_name}/#{ref_name}/src/2.rb", [
|
1301
|
+
'def func_2',
|
1302
|
+
' return 10000 + 42',
|
1303
|
+
'end',
|
1304
|
+
].join("\n")
|
1305
|
+
|
1306
|
+
allow(fake_social_snippet.repo_manager).to receive(:find_repository).with(repo_name, ref_name) do
|
1307
|
+
repo = SocialSnippet::Repository::Drivers::BaseRepository.new("#{repo_path}/#{repo_name}/#{ref_name}")
|
1308
|
+
allow(repo).to receive(:refs).and_return([
|
1309
|
+
'0.0.1',
|
1310
|
+
'0.0.2',
|
1311
|
+
])
|
1312
|
+
allow(repo).to receive(:commit_id).and_return "#{ref_name}#{commit_id}"
|
1313
|
+
repo.load_snippet_json
|
1314
|
+
repo.create_cache repo_cache_path
|
1315
|
+
repo
|
1316
|
+
end
|
1317
|
+
end # prepare my-repo#0.0.2
|
1318
|
+
|
1319
|
+
context "use 0.0.1" do
|
1320
|
+
|
1321
|
+
let(:input) do
|
1322
|
+
[
|
1323
|
+
'# main.rb',
|
1324
|
+
'# @snip <my-repo#0.0.1:1.rb>',
|
1325
|
+
'puts func_1',
|
1326
|
+
].join("\n")
|
1327
|
+
end
|
1328
|
+
|
1329
|
+
let(:output) do
|
1330
|
+
[
|
1331
|
+
'# main.rb',
|
1332
|
+
'# @snippet <my-repo#0.0.1:2.rb>',
|
1333
|
+
'def func_2',
|
1334
|
+
' return 42',
|
1335
|
+
'end',
|
1336
|
+
'# @snippet <my-repo#0.0.1:1.rb>',
|
1337
|
+
'def func_1',
|
1338
|
+
' return 2 * func_2()',
|
1339
|
+
'end',
|
1340
|
+
'puts func_1',
|
1341
|
+
].join("\n")
|
1342
|
+
end
|
1343
|
+
|
1344
|
+
subject { fake_social_snippet.api.insert_snippet(input) }
|
1345
|
+
it { should eq output }
|
1346
|
+
|
1347
|
+
end # use 0.0.1
|
1348
|
+
|
1349
|
+
context "use 0.0.2" do
|
1350
|
+
|
1351
|
+
let(:input) do
|
1352
|
+
[
|
1353
|
+
'# main.rb',
|
1354
|
+
'# @snip <my-repo#0.0.2:1.rb>',
|
1355
|
+
'puts func_1',
|
1356
|
+
].join("\n")
|
1357
|
+
end
|
1358
|
+
|
1359
|
+
let(:output) do
|
1360
|
+
[
|
1361
|
+
'# main.rb',
|
1362
|
+
'# @snippet <my-repo#0.0.2:2.rb>',
|
1363
|
+
'def func_2',
|
1364
|
+
' return 10000 + 42',
|
1365
|
+
'end',
|
1366
|
+
'# @snippet <my-repo#0.0.2:1.rb>',
|
1367
|
+
'def func_1',
|
1368
|
+
' return 2 * func_2()',
|
1369
|
+
'end',
|
1370
|
+
'puts func_1',
|
1371
|
+
].join("\n")
|
1372
|
+
end
|
1373
|
+
|
1374
|
+
subject { fake_social_snippet.api.insert_snippet(input) }
|
1375
|
+
it { should eq output }
|
1376
|
+
|
1377
|
+
end # use 0.0.2
|
1378
|
+
|
1379
|
+
context "use 0.0.1 and 0.0.2" do
|
1380
|
+
|
1381
|
+
let(:input) do
|
1382
|
+
[
|
1383
|
+
'# main.rb',
|
1384
|
+
'# @snip <my-repo#0.0.2:1.rb>',
|
1385
|
+
'# @snip <my-repo#0.0.1:1.rb>',
|
1386
|
+
].join("\n")
|
1387
|
+
end
|
1388
|
+
|
1389
|
+
let(:output) do
|
1390
|
+
[
|
1391
|
+
'# main.rb',
|
1392
|
+
'# @snippet <my-repo#0.0.2:2.rb>',
|
1393
|
+
'def func_2',
|
1394
|
+
' return 10000 + 42',
|
1395
|
+
'end',
|
1396
|
+
'# @snippet <my-repo#0.0.2:1.rb>',
|
1397
|
+
'def func_1',
|
1398
|
+
' return 2 * func_2()',
|
1399
|
+
'end',
|
1400
|
+
'# @snippet <my-repo#0.0.1:2.rb>',
|
1401
|
+
'def func_2',
|
1402
|
+
' return 42',
|
1403
|
+
'end',
|
1404
|
+
'# @snippet <my-repo#0.0.1:1.rb>',
|
1405
|
+
'def func_1',
|
1406
|
+
' return 2 * func_2()',
|
1407
|
+
'end',
|
1408
|
+
].join("\n")
|
1409
|
+
end
|
1410
|
+
|
1411
|
+
subject { fake_social_snippet.api.insert_snippet(input) }
|
1412
|
+
it { should eq output }
|
1413
|
+
|
1414
|
+
end # use 0.0.1 and 0.0.2
|
1415
|
+
|
1416
|
+
end # snippet snippet with ref
|
1417
|
+
|
1418
|
+
context "snippet snippet" do
|
1419
|
+
|
1420
|
+
before do
|
1421
|
+
repo_name = "my-repo"
|
1422
|
+
|
1423
|
+
FileUtils.mkdir_p "#{repo_path}"
|
1424
|
+
FileUtils.mkdir_p "#{repo_path}/#{repo_name}"
|
1425
|
+
FileUtils.mkdir_p "#{repo_path}/#{repo_name}/.git"
|
1426
|
+
FileUtils.mkdir_p "#{repo_path}/#{repo_name}/src"
|
1427
|
+
FileUtils.touch "#{repo_path}/#{repo_name}/snippet.json"
|
1428
|
+
FileUtils.touch "#{repo_path}/#{repo_name}/src/1.rb"
|
1429
|
+
FileUtils.touch "#{repo_path}/#{repo_name}/src/2.rb"
|
1430
|
+
|
1431
|
+
# snippet.json
|
1432
|
+
File.write "#{repo_path}/#{repo_name}/snippet.json", [
|
1433
|
+
'{"name": "' + repo_name + '", "main": "src"}',
|
1434
|
+
].join("\n")
|
1435
|
+
|
1436
|
+
# src/1.rb
|
1437
|
+
File.write "#{repo_path}/#{repo_name}/src/1.rb", [
|
1438
|
+
'# @snip</2.rb>',
|
1439
|
+
'def func_1',
|
1440
|
+
' return 2 * func_2()',
|
1441
|
+
'end',
|
1442
|
+
].join("\n")
|
1443
|
+
|
1444
|
+
# src/2.rb
|
1445
|
+
File.write "#{repo_path}/#{repo_name}/src/2.rb", [
|
1446
|
+
'def func_2',
|
1447
|
+
' return 42',
|
1448
|
+
'end',
|
1449
|
+
].join("\n")
|
1450
|
+
|
1451
|
+
repo_config = Proc.new do |path|
|
1452
|
+
repo = SocialSnippet::Repository::Drivers::BaseRepository.new("#{repo_path}/#{repo_name}")
|
1453
|
+
allow(repo).to receive(:commit_id).and_return commit_id
|
1454
|
+
allow(repo).to receive(:refs).and_return []
|
1455
|
+
repo.load_snippet_json
|
1456
|
+
repo.create_cache repo_cache_path
|
1457
|
+
repo
|
1458
|
+
end
|
1459
|
+
|
1460
|
+
allow(fake_social_snippet.repo_manager).to receive(:find_repository).with(repo_name) { repo_config.call }
|
1461
|
+
allow(fake_social_snippet.repo_manager).to receive(:find_repository).with(repo_name, short_commit_id) { repo_config.call }
|
1462
|
+
|
1463
|
+
end # prepare my-repo
|
1464
|
+
|
1465
|
+
let(:input) do
|
1466
|
+
[
|
1467
|
+
'# main.rb',
|
1468
|
+
'# @snip <my-repo:1.rb>',
|
1469
|
+
'puts func_1',
|
1470
|
+
].join("\n")
|
1471
|
+
end
|
1472
|
+
|
1473
|
+
let(:output) do
|
1474
|
+
[
|
1475
|
+
'# main.rb',
|
1476
|
+
'# @snippet <my-repo#' + short_commit_id + ':2.rb>',
|
1477
|
+
'def func_2',
|
1478
|
+
' return 42',
|
1479
|
+
'end',
|
1480
|
+
'# @snippet <my-repo#' + short_commit_id + ':1.rb>',
|
1481
|
+
'def func_1',
|
1482
|
+
' return 2 * func_2()',
|
1483
|
+
'end',
|
1484
|
+
'puts func_1',
|
1485
|
+
].join("\n")
|
1486
|
+
end
|
1487
|
+
|
1488
|
+
subject { fake_social_snippet.api.insert_snippet(input) }
|
1489
|
+
it { should eq output }
|
1490
|
+
|
1491
|
+
end
|
1492
|
+
|
1493
|
+
context "snip with repo" do
|
1494
|
+
|
1495
|
+
before do
|
1496
|
+
repo_name = "my-repo"
|
1497
|
+
|
1498
|
+
FileUtils.mkdir_p "#{repo_path}"
|
1499
|
+
FileUtils.mkdir_p "#{repo_path}/#{repo_name}"
|
1500
|
+
FileUtils.mkdir_p "#{repo_path}/#{repo_name}/.git"
|
1501
|
+
FileUtils.mkdir_p "#{repo_path}/#{repo_name}/a"
|
1502
|
+
FileUtils.touch "#{repo_path}/#{repo_name}/snippet.json"
|
1503
|
+
FileUtils.touch "#{repo_path}/#{repo_name}/a.rb"
|
1504
|
+
FileUtils.touch "#{repo_path}/#{repo_name}/a/1.rb"
|
1505
|
+
FileUtils.touch "#{repo_path}/#{repo_name}/a/2.rb"
|
1506
|
+
|
1507
|
+
# snippet.json
|
1508
|
+
File.write "#{repo_path}/#{repo_name}/snippet.json", [
|
1509
|
+
'{"name": "' + repo_name + '"}',
|
1510
|
+
].join("\n")
|
1511
|
+
|
1512
|
+
# a.rb
|
1513
|
+
File.write "#{repo_path}/#{repo_name}/a.rb", [
|
1514
|
+
'# @snip <./a/1.rb>',
|
1515
|
+
'# @snip <./a/2.rb>',
|
1516
|
+
].join("\n")
|
1517
|
+
|
1518
|
+
# a/1.rb
|
1519
|
+
File.write "#{repo_path}/#{repo_name}/a/1.rb", [
|
1520
|
+
'puts "1"',
|
1521
|
+
].join("\n")
|
1522
|
+
|
1523
|
+
# a/2.rb
|
1524
|
+
File.write "#{repo_path}/#{repo_name}/a/2.rb", [
|
1525
|
+
'puts "2"',
|
1526
|
+
].join("\n")
|
1527
|
+
|
1528
|
+
repo_config = Proc.new do |path|
|
1529
|
+
repo = SocialSnippet::Repository::Drivers::BaseRepository.new("#{repo_path}/#{repo_name}")
|
1530
|
+
allow(repo).to receive(:commit_id).and_return commit_id
|
1531
|
+
allow(repo).to receive(:refs).and_return []
|
1532
|
+
repo.load_snippet_json
|
1533
|
+
repo.create_cache repo_cache_path
|
1534
|
+
repo
|
1535
|
+
end
|
1536
|
+
|
1537
|
+
allow(fake_social_snippet.repo_manager).to receive(:find_repository).with("my-repo") { repo_config.call }
|
1538
|
+
allow(fake_social_snippet.repo_manager).to receive(:find_repository).with("my-repo", short_commit_id) { repo_config.call }
|
1539
|
+
end # my-repo
|
1540
|
+
|
1541
|
+
let(:input) do
|
1542
|
+
[
|
1543
|
+
"# @snip<my-repo:a.rb>"
|
1544
|
+
].join("\n")
|
1545
|
+
end
|
1546
|
+
|
1547
|
+
let(:output) do
|
1548
|
+
[
|
1549
|
+
'# @snippet<my-repo#' + short_commit_id + ':a/1.rb>',
|
1550
|
+
'puts "1"',
|
1551
|
+
'# @snippet<my-repo#' + short_commit_id + ':a/2.rb>',
|
1552
|
+
'puts "2"',
|
1553
|
+
'# @snippet<my-repo#' + short_commit_id + ':a.rb>',
|
1554
|
+
].join("\n")
|
1555
|
+
end
|
1556
|
+
|
1557
|
+
subject { fake_social_snippet.api.insert_snippet(input) }
|
1558
|
+
it { should eq output }
|
1559
|
+
|
1560
|
+
end # snip with repo
|
1561
|
+
|
1562
|
+
context "multiple snippets without duplicates" do
|
1563
|
+
|
1564
|
+
before do
|
1565
|
+
repo_name = "repo-a"
|
1566
|
+
|
1567
|
+
FileUtils.mkdir_p "#{repo_path}"
|
1568
|
+
FileUtils.mkdir_p "#{repo_path}/#{repo_name}"
|
1569
|
+
FileUtils.mkdir_p "#{repo_path}/#{repo_name}/.git"
|
1570
|
+
FileUtils.touch "#{repo_path}/#{repo_name}/snippet.json"
|
1571
|
+
FileUtils.touch "#{repo_path}/#{repo_name}/parent"
|
1572
|
+
FileUtils.touch "#{repo_path}/#{repo_name}/child_1"
|
1573
|
+
FileUtils.touch "#{repo_path}/#{repo_name}/child_2"
|
1574
|
+
FileUtils.touch "#{repo_path}/#{repo_name}/child_3"
|
1575
|
+
|
1576
|
+
# snippet.json
|
1577
|
+
File.write "#{repo_path}/#{repo_name}/snippet.json", [
|
1578
|
+
'{"name": "' + repo_name + '"}',
|
1579
|
+
].join("\n")
|
1580
|
+
|
1581
|
+
# parent
|
1582
|
+
File.write "#{repo_path}/#{repo_name}/parent", [
|
1583
|
+
'@snip<child_1>',
|
1584
|
+
'@snip<child_2>',
|
1585
|
+
'@snip<child_3>',
|
1586
|
+
].join("\n")
|
1587
|
+
|
1588
|
+
repo_config = Proc.new do |path|
|
1589
|
+
repo = SocialSnippet::Repository::Drivers::BaseRepository.new("#{repo_path}/#{repo_name}")
|
1590
|
+
allow(repo).to receive(:commit_id).and_return commit_id
|
1591
|
+
allow(repo).to receive(:refs).and_return []
|
1592
|
+
repo.load_snippet_json
|
1593
|
+
repo.create_cache repo_cache_path
|
1594
|
+
repo
|
1595
|
+
end
|
1596
|
+
|
1597
|
+
allow(fake_social_snippet.repo_manager).to receive(:find_repository).with(repo_name) { repo_config.call }
|
1598
|
+
allow(fake_social_snippet.repo_manager).to receive(:find_repository).with(repo_name, short_commit_id) { repo_config.call }
|
1599
|
+
end # repo-a
|
1600
|
+
|
1601
|
+
let(:input) do
|
1602
|
+
[
|
1603
|
+
'@snip <repo-a:parent>',
|
1604
|
+
].join("\n")
|
1605
|
+
end
|
1606
|
+
|
1607
|
+
let(:output) do
|
1608
|
+
[
|
1609
|
+
'@snippet <repo-a#' + short_commit_id + ':child_1>',
|
1610
|
+
'@snippet <repo-a#' + short_commit_id + ':child_2>',
|
1611
|
+
'@snippet <repo-a#' + short_commit_id + ':child_3>',
|
1612
|
+
'@snippet <repo-a#' + short_commit_id + ':parent>',
|
1613
|
+
].join("\n")
|
1614
|
+
end
|
1615
|
+
|
1616
|
+
subject { fake_social_snippet.api.insert_snippet(input) }
|
1617
|
+
it { should eq output }
|
1618
|
+
|
1619
|
+
end # multiple snippets without duplicates
|
1620
|
+
|
1621
|
+
context "multiple snippets with duplicates" do
|
1622
|
+
|
1623
|
+
before do
|
1624
|
+
repo_name = "my_repo"
|
1625
|
+
|
1626
|
+
FileUtils.mkdir_p "#{repo_path}"
|
1627
|
+
FileUtils.mkdir_p "#{repo_path}/#{repo_name}"
|
1628
|
+
FileUtils.mkdir_p "#{repo_path}/#{repo_name}/.git"
|
1629
|
+
FileUtils.touch "#{repo_path}/#{repo_name}/snippet.json"
|
1630
|
+
FileUtils.touch "#{repo_path}/#{repo_name}/parent"
|
1631
|
+
FileUtils.touch "#{repo_path}/#{repo_name}/child_1"
|
1632
|
+
FileUtils.touch "#{repo_path}/#{repo_name}/child_2"
|
1633
|
+
FileUtils.touch "#{repo_path}/#{repo_name}/child_3"
|
1634
|
+
|
1635
|
+
# snippet.json
|
1636
|
+
File.write "#{repo_path}/#{repo_name}/snippet.json", [
|
1637
|
+
'{"name": "' + repo_name + '"}',
|
1638
|
+
].join("\n")
|
1639
|
+
|
1640
|
+
# parent
|
1641
|
+
File.write "#{repo_path}/#{repo_name}/parent", [
|
1642
|
+
'@snip<child_1>',
|
1643
|
+
'@snip<child_2>',
|
1644
|
+
'@snip<child_2>',
|
1645
|
+
'@snip<child_3>',
|
1646
|
+
'@snip<child_1>',
|
1647
|
+
'@snip<child_2>',
|
1648
|
+
'@snip<child_3>',
|
1649
|
+
].join("\n")
|
1650
|
+
|
1651
|
+
repo_config = Proc.new do |path|
|
1652
|
+
repo = SocialSnippet::Repository::Drivers::BaseRepository.new("#{repo_path}/#{repo_name}")
|
1653
|
+
allow(repo).to receive(:commit_id).and_return commit_id
|
1654
|
+
allow(repo).to receive(:refs).and_return []
|
1655
|
+
repo.load_snippet_json
|
1656
|
+
repo.create_cache repo_cache_path
|
1657
|
+
repo
|
1658
|
+
end
|
1659
|
+
|
1660
|
+
allow(fake_social_snippet.repo_manager).to receive(:find_repository).with(repo_name) { repo_config.call }
|
1661
|
+
allow(fake_social_snippet.repo_manager).to receive(:find_repository).with(repo_name, short_commit_id) { repo_config.call }
|
1662
|
+
end
|
1663
|
+
|
1664
|
+
let(:input) do
|
1665
|
+
[
|
1666
|
+
'@snip <my_repo:parent>',
|
1667
|
+
'@snip<my_repo:child_3>',
|
1668
|
+
'@snip<my_repo:child_2>',
|
1669
|
+
'@snip<my_repo:child_1>',
|
1670
|
+
].join("\n")
|
1671
|
+
end
|
1672
|
+
|
1673
|
+
let(:output) do
|
1674
|
+
[
|
1675
|
+
'@snippet <my_repo#' + short_commit_id + ':child_1>',
|
1676
|
+
'@snippet <my_repo#' + short_commit_id + ':child_2>',
|
1677
|
+
'@snippet <my_repo#' + short_commit_id + ':child_3>',
|
1678
|
+
'@snippet <my_repo#' + short_commit_id + ':parent>',
|
1679
|
+
].join("\n")
|
1680
|
+
end
|
1681
|
+
|
1682
|
+
subject { fake_social_snippet.api.insert_snippet(input) }
|
1683
|
+
it { should eq output }
|
1684
|
+
|
1685
|
+
end
|
1686
|
+
|
1687
|
+
context "more duplicate cases" do
|
1688
|
+
|
1689
|
+
context "already snipped" do
|
1690
|
+
|
1691
|
+
before do
|
1692
|
+
repo_name = "my-repo"
|
1693
|
+
|
1694
|
+
FileUtils.mkdir_p "#{tmp_repo_path_no_ver}"
|
1695
|
+
FileUtils.mkdir_p "#{tmp_repo_path_no_ver}/#{repo_name}"
|
1696
|
+
FileUtils.mkdir_p "#{tmp_repo_path_no_ver}/#{repo_name}/.git"
|
1697
|
+
FileUtils.mkdir_p "#{tmp_repo_path_no_ver}/#{repo_name}/src"
|
1698
|
+
FileUtils.touch "#{tmp_repo_path_no_ver}/#{repo_name}/snippet.json"
|
1699
|
+
FileUtils.touch "#{tmp_repo_path_no_ver}/#{repo_name}/src/1"
|
1700
|
+
FileUtils.touch "#{tmp_repo_path_no_ver}/#{repo_name}/src/2"
|
1701
|
+
FileUtils.touch "#{tmp_repo_path_no_ver}/#{repo_name}/src/3"
|
1702
|
+
|
1703
|
+
# snippet.json
|
1704
|
+
File.write "#{tmp_repo_path_no_ver}/#{repo_name}/snippet.json", [
|
1705
|
+
'{',
|
1706
|
+
' "name": "' + repo_name + '",',
|
1707
|
+
' "main": "src"',
|
1708
|
+
'}',
|
1709
|
+
].join("\n")
|
1710
|
+
|
1711
|
+
# src/1
|
1712
|
+
File.write "#{tmp_repo_path_no_ver}/#{repo_name}/src/1", [
|
1713
|
+
'@snip<2>',
|
1714
|
+
'@snip<3>',
|
1715
|
+
].join("\n")
|
1716
|
+
|
1717
|
+
# src/2
|
1718
|
+
File.write "#{tmp_repo_path_no_ver}/#{repo_name}/src/2", [
|
1719
|
+
'2',
|
1720
|
+
].join("\n")
|
1721
|
+
|
1722
|
+
# src/3
|
1723
|
+
File.write "#{tmp_repo_path_no_ver}/#{repo_name}/src/3", [
|
1724
|
+
'3',
|
1725
|
+
].join("\n")
|
1726
|
+
end # prepare for my-repo
|
1727
|
+
|
1728
|
+
before do
|
1729
|
+
repo_name = "has-version"
|
1730
|
+
repo_version = "0.0.1"
|
1731
|
+
|
1732
|
+
FileUtils.mkdir_p "#{tmp_repo_path}"
|
1733
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}"
|
1734
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{repo_version}"
|
1735
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{repo_version}/.git"
|
1736
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{repo_version}/src"
|
1737
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{repo_version}/snippet.json"
|
1738
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{repo_version}/src/1"
|
1739
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{repo_version}/src/2"
|
1740
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{repo_version}/src/3"
|
1741
|
+
|
1742
|
+
# snippet.json
|
1743
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{repo_version}/snippet.json", [
|
1744
|
+
'{',
|
1745
|
+
' "name": "' + repo_name + '",',
|
1746
|
+
' "main": "src"',
|
1747
|
+
'}',
|
1748
|
+
].join("\n")
|
1749
|
+
|
1750
|
+
# src/1
|
1751
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{repo_version}/src/1", [
|
1752
|
+
'@snip<2>',
|
1753
|
+
'@snip<3>',
|
1754
|
+
'0.0.1: 1',
|
1755
|
+
].join("\n")
|
1756
|
+
|
1757
|
+
# src/2
|
1758
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{repo_version}/src/2", [
|
1759
|
+
'0.0.1: 2',
|
1760
|
+
].join("\n")
|
1761
|
+
|
1762
|
+
# src/3
|
1763
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{repo_version}/src/3", [
|
1764
|
+
'0.0.1: 3',
|
1765
|
+
].join("\n")
|
1766
|
+
end # prepare has-version#0.0.1
|
1767
|
+
|
1768
|
+
before do
|
1769
|
+
repo_name = "has-version"
|
1770
|
+
repo_version = "1.2.3"
|
1771
|
+
|
1772
|
+
FileUtils.mkdir_p "#{tmp_repo_path}"
|
1773
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}"
|
1774
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{repo_version}"
|
1775
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{repo_version}/.git"
|
1776
|
+
FileUtils.mkdir_p "#{tmp_repo_path}/#{repo_name}/#{repo_version}/src"
|
1777
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{repo_version}/snippet.json"
|
1778
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{repo_version}/src/1"
|
1779
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{repo_version}/src/2"
|
1780
|
+
FileUtils.touch "#{tmp_repo_path}/#{repo_name}/#{repo_version}/src/3"
|
1781
|
+
|
1782
|
+
# snippet.json
|
1783
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{repo_version}/snippet.json", [
|
1784
|
+
'{',
|
1785
|
+
' "name": "' + repo_name + '",',
|
1786
|
+
' "main": "src"',
|
1787
|
+
'}',
|
1788
|
+
].join("\n")
|
1789
|
+
|
1790
|
+
# src/1
|
1791
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{repo_version}/src/1", [
|
1792
|
+
'@snip<2>',
|
1793
|
+
'@snip<3>',
|
1794
|
+
'1.2.3: 1',
|
1795
|
+
].join("\n")
|
1796
|
+
|
1797
|
+
# src/2
|
1798
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{repo_version}/src/2", [
|
1799
|
+
'1.2.3: 2',
|
1800
|
+
].join("\n")
|
1801
|
+
|
1802
|
+
# src/3
|
1803
|
+
File.write "#{tmp_repo_path}/#{repo_name}/#{repo_version}/src/3", [
|
1804
|
+
'1.2.3: 3',
|
1805
|
+
].join("\n")
|
1806
|
+
end # prepare has-version#1.2.3
|
1807
|
+
|
1808
|
+
before do
|
1809
|
+
find_repo_mock
|
1810
|
+
end
|
1811
|
+
|
1812
|
+
context "already snipped using version" do
|
1813
|
+
|
1814
|
+
context "not already snipped" do
|
1815
|
+
|
1816
|
+
let(:input) do
|
1817
|
+
[
|
1818
|
+
'@snip<has-version#0:1>',
|
1819
|
+
'@snip<has-version#1:1>',
|
1820
|
+
].join("\n").freeze
|
1821
|
+
end
|
1822
|
+
|
1823
|
+
let(:output) do
|
1824
|
+
[
|
1825
|
+
'@snippet<has-version#0.0.1:2>',
|
1826
|
+
'0.0.1: 2',
|
1827
|
+
'@snippet<has-version#0.0.1:3>',
|
1828
|
+
'0.0.1: 3',
|
1829
|
+
'@snippet<has-version#0.0.1:1>',
|
1830
|
+
'0.0.1: 1',
|
1831
|
+
'@snippet<has-version#1.2.3:2>',
|
1832
|
+
'1.2.3: 2',
|
1833
|
+
'@snippet<has-version#1.2.3:3>',
|
1834
|
+
'1.2.3: 3',
|
1835
|
+
'@snippet<has-version#1.2.3:1>',
|
1836
|
+
'1.2.3: 1',
|
1837
|
+
].join("\n").freeze
|
1838
|
+
end
|
1839
|
+
|
1840
|
+
subject { fake_social_snippet.api.insert_snippet(input) }
|
1841
|
+
it { should eq output }
|
1842
|
+
|
1843
|
+
end
|
1844
|
+
|
1845
|
+
context "snipped", :force => true do
|
1846
|
+
|
1847
|
+
let(:input) do
|
1848
|
+
[
|
1849
|
+
'@snippet<has-version#0.0.1:1>',
|
1850
|
+
'@snip<has-version#0:1>',
|
1851
|
+
'@snip<has-version#1:1>',
|
1852
|
+
].join("\n").freeze
|
1853
|
+
end
|
1854
|
+
|
1855
|
+
let(:output) do
|
1856
|
+
[
|
1857
|
+
'@snippet<has-version#0.0.1:1>',
|
1858
|
+
'@snippet<has-version#1.2.3:2>',
|
1859
|
+
'1.2.3: 2',
|
1860
|
+
'@snippet<has-version#1.2.3:3>',
|
1861
|
+
'1.2.3: 3',
|
1862
|
+
'@snippet<has-version#1.2.3:1>',
|
1863
|
+
'1.2.3: 1',
|
1864
|
+
].join("\n").freeze
|
1865
|
+
end
|
1866
|
+
|
1867
|
+
subject { fake_social_snippet.api.insert_snippet(input) }
|
1868
|
+
it { should eq output }
|
1869
|
+
|
1870
|
+
end # snipped
|
1871
|
+
|
1872
|
+
context "use another repo" do
|
1873
|
+
|
1874
|
+
let(:input) do
|
1875
|
+
[
|
1876
|
+
'@snippet<has-version#0.0.1:1>',
|
1877
|
+
'@snip<has-version#0:1>',
|
1878
|
+
'@snip<my-repo:1>',
|
1879
|
+
'@snip<has-version:1>',
|
1880
|
+
].join("\n").freeze
|
1881
|
+
end
|
1882
|
+
|
1883
|
+
let(:output) do
|
1884
|
+
[
|
1885
|
+
'@snippet<has-version#0.0.1:1>',
|
1886
|
+
'@snippet<my-repo#thisisdu:2>',
|
1887
|
+
'2',
|
1888
|
+
'@snippet<my-repo#thisisdu:3>',
|
1889
|
+
'3',
|
1890
|
+
'@snippet<my-repo#thisisdu:1>',
|
1891
|
+
'@snippet<has-version#1.2.3:2>',
|
1892
|
+
'1.2.3: 2',
|
1893
|
+
'@snippet<has-version#1.2.3:3>',
|
1894
|
+
'1.2.3: 3',
|
1895
|
+
'@snippet<has-version#1.2.3:1>',
|
1896
|
+
'1.2.3: 1',
|
1897
|
+
].join("\n").freeze
|
1898
|
+
end
|
1899
|
+
|
1900
|
+
subject { fake_social_snippet.api.insert_snippet(input) }
|
1901
|
+
it { should eq output }
|
1902
|
+
|
1903
|
+
end
|
1904
|
+
|
1905
|
+
end # already snipped using version
|
1906
|
+
|
1907
|
+
context "already snipped case" do
|
1908
|
+
|
1909
|
+
let(:input) do
|
1910
|
+
[
|
1911
|
+
'@snippet<my-repo#' + short_commit_id + ':3>',
|
1912
|
+
'3',
|
1913
|
+
'',
|
1914
|
+
'@snip<my-repo:1>',
|
1915
|
+
'@snip<my-repo:2>',
|
1916
|
+
].join("\n")
|
1917
|
+
end
|
1918
|
+
|
1919
|
+
let(:output) do
|
1920
|
+
[
|
1921
|
+
'@snippet<my-repo#' + short_commit_id + ':3>',
|
1922
|
+
'3',
|
1923
|
+
'',
|
1924
|
+
'@snippet<my-repo#' + short_commit_id + ':2>',
|
1925
|
+
'2',
|
1926
|
+
'@snippet<my-repo#' + short_commit_id + ':1>',
|
1927
|
+
].join("\n")
|
1928
|
+
end
|
1929
|
+
|
1930
|
+
subject { fake_social_snippet.api.insert_snippet(input) }
|
1931
|
+
it { should eq output }
|
1932
|
+
|
1933
|
+
end # already snipped case
|
1934
|
+
|
1935
|
+
context "not already snipped case" do
|
1936
|
+
|
1937
|
+
let(:input) do
|
1938
|
+
[
|
1939
|
+
'@snip<my-repo:1>',
|
1940
|
+
'@snip<my-repo:2>',
|
1941
|
+
'@snip<my-repo:3>',
|
1942
|
+
].join("\n")
|
1943
|
+
end
|
1944
|
+
|
1945
|
+
let(:output) do
|
1946
|
+
[
|
1947
|
+
'@snippet<my-repo#' + short_commit_id + ':2>',
|
1948
|
+
'2',
|
1949
|
+
'@snippet<my-repo#' + short_commit_id + ':3>',
|
1950
|
+
'3',
|
1951
|
+
'@snippet<my-repo#' + short_commit_id + ':1>',
|
1952
|
+
].join("\n")
|
1953
|
+
end
|
1954
|
+
|
1955
|
+
subject { fake_social_snippet.api.insert_snippet(input) }
|
1956
|
+
it { should eq output }
|
1957
|
+
|
1958
|
+
end # not already snipped case
|
1959
|
+
|
1960
|
+
end # alread snipped
|
1961
|
+
|
1962
|
+
context "other repos have same snip tag" do
|
1963
|
+
|
1964
|
+
before do
|
1965
|
+
repo_name = "my_lib"
|
1966
|
+
|
1967
|
+
FileUtils.mkdir_p "#{tmp_repo_path_no_ver}"
|
1968
|
+
FileUtils.mkdir_p "#{tmp_repo_path_no_ver}/#{repo_name}"
|
1969
|
+
FileUtils.mkdir_p "#{tmp_repo_path_no_ver}/#{repo_name}/.git"
|
1970
|
+
FileUtils.mkdir_p "#{tmp_repo_path_no_ver}/#{repo_name}/src/lib"
|
1971
|
+
FileUtils.touch "#{tmp_repo_path_no_ver}/#{repo_name}/snippet.json"
|
1972
|
+
FileUtils.touch "#{tmp_repo_path_no_ver}/#{repo_name}/src/lib/add_func.cpp"
|
1973
|
+
|
1974
|
+
# snippet.json
|
1975
|
+
File.write "#{tmp_repo_path_no_ver}/#{repo_name}/snippet.json", [
|
1976
|
+
'{',
|
1977
|
+
' "name": "' + repo_name + '",',
|
1978
|
+
' "main": "src"',
|
1979
|
+
'}',
|
1980
|
+
].join("\n")
|
1981
|
+
|
1982
|
+
# src/add_func.cpp
|
1983
|
+
File.write "#{tmp_repo_path_no_ver}/#{repo_name}/src/add_func.cpp", [
|
1984
|
+
'int add_func( int a, int b ) {',
|
1985
|
+
' return a + b;',
|
1986
|
+
'}',
|
1987
|
+
].join("\n")
|
1988
|
+
end # prepare for my_lib repo
|
1989
|
+
|
1990
|
+
before do
|
1991
|
+
repo_name = "my_repo_a"
|
1992
|
+
|
1993
|
+
FileUtils.mkdir_p "#{tmp_repo_path_no_ver}"
|
1994
|
+
FileUtils.mkdir_p "#{tmp_repo_path_no_ver}/#{repo_name}"
|
1995
|
+
FileUtils.mkdir_p "#{tmp_repo_path_no_ver}/#{repo_name}/.git"
|
1996
|
+
FileUtils.touch "#{tmp_repo_path_no_ver}/#{repo_name}/snippet.json"
|
1997
|
+
FileUtils.touch "#{tmp_repo_path_no_ver}/#{repo_name}/use_add_func.cpp"
|
1998
|
+
|
1999
|
+
# snippet.json
|
2000
|
+
File.write "#{tmp_repo_path_no_ver}/#{repo_name}/snippet.json", [
|
2001
|
+
'{"name": "' + repo_name + '"}',
|
2002
|
+
].join("\n")
|
2003
|
+
|
2004
|
+
# use_add_func.cpp
|
2005
|
+
File.write "#{tmp_repo_path_no_ver}/#{repo_name}/use_add_func.cpp", [
|
2006
|
+
'// @snip <my_lib:add_func.cpp>',
|
2007
|
+
'int my_repo_a_use_add_func( int a, int b ) {',
|
2008
|
+
' return add_func(a, b);',
|
2009
|
+
'}',
|
2010
|
+
].join("\n")
|
2011
|
+
end # prepare for my_repo_a repo
|
2012
|
+
|
2013
|
+
before do
|
2014
|
+
repo_name = "my_repo_b"
|
2015
|
+
|
2016
|
+
FileUtils.mkdir_p "#{tmp_repo_path_no_ver}"
|
2017
|
+
FileUtils.mkdir_p "#{tmp_repo_path_no_ver}/#{repo_name}"
|
2018
|
+
FileUtils.mkdir_p "#{tmp_repo_path_no_ver}/#{repo_name}/.git"
|
2019
|
+
FileUtils.touch "#{tmp_repo_path_no_ver}/#{repo_name}/snippet.json"
|
2020
|
+
FileUtils.touch "#{tmp_repo_path_no_ver}/#{repo_name}/use_add_func.cpp"
|
2021
|
+
|
2022
|
+
# snippet.json
|
2023
|
+
File.write "#{tmp_repo_path_no_ver}/#{repo_name}/snippet.json", [
|
2024
|
+
'{"name": "' + repo_name + '"}',
|
2025
|
+
].join("\n")
|
2026
|
+
|
2027
|
+
# use_add_func.cpp
|
2028
|
+
File.write "#{tmp_repo_path_no_ver}/#{repo_name}/use_add_func.cpp", [
|
2029
|
+
'// @snip <my_lib:add_func.cpp>',
|
2030
|
+
'int my_repo_b_use_add_func( int a, int b ) {',
|
2031
|
+
' return add_func(a, b);',
|
2032
|
+
'}',
|
2033
|
+
].join("\n")
|
2034
|
+
end # prepare for my_repo_b repo
|
2035
|
+
|
2036
|
+
before { find_repo_mock }
|
2037
|
+
|
2038
|
+
let(:input) do
|
2039
|
+
[
|
2040
|
+
'#include <iostream>',
|
2041
|
+
'',
|
2042
|
+
'// @snip<my_repo_a:use_add_func.cpp>',
|
2043
|
+
'// @snip<my_repo_b:use_add_func.cpp>',
|
2044
|
+
'',
|
2045
|
+
'int main() {',
|
2046
|
+
' int a, b;',
|
2047
|
+
' std::cin >> a >> b;',
|
2048
|
+
' std::cout << my_repo_a_use_add_func(a, b) << " == " << my_repo_a_use_add_func(a, b) << std::endl;',
|
2049
|
+
' return 0;',
|
2050
|
+
'}',
|
2051
|
+
].join("\n")
|
2052
|
+
end
|
2053
|
+
|
2054
|
+
let(:output) do
|
2055
|
+
[
|
2056
|
+
'#include <iostream>',
|
2057
|
+
'',
|
2058
|
+
'// @snippet<my_lib#' + short_commit_id + ':add_func.cpp>',
|
2059
|
+
'int add_func( int a, int b ) {',
|
2060
|
+
' return a + b;',
|
2061
|
+
'}',
|
2062
|
+
'// @snippet<my_repo_a#' + short_commit_id + ':use_add_func.cpp>',
|
2063
|
+
'int my_repo_a_use_add_func( int a, int b ) {',
|
2064
|
+
' return add_func(a, b);',
|
2065
|
+
'}',
|
2066
|
+
'// @snippet<my_repo_b#' + short_commit_id + ':use_add_func.cpp>',
|
2067
|
+
'int my_repo_b_use_add_func( int a, int b ) {',
|
2068
|
+
' return add_func(a, b);',
|
2069
|
+
'}',
|
2070
|
+
'',
|
2071
|
+
'int main() {',
|
2072
|
+
' int a, b;',
|
2073
|
+
' std::cin >> a >> b;',
|
2074
|
+
' std::cout << my_repo_a_use_add_func(a, b) << " == " << my_repo_a_use_add_func(a, b) << std::endl;',
|
2075
|
+
' return 0;',
|
2076
|
+
'}',
|
2077
|
+
].join("\n")
|
2078
|
+
end
|
2079
|
+
|
2080
|
+
context "call insert_snippet" do
|
2081
|
+
subject { fake_social_snippet.api.insert_snippet(input) }
|
2082
|
+
it { should eq output }
|
2083
|
+
end
|
2084
|
+
|
2085
|
+
end # other repos have same snip tags
|
2086
|
+
|
2087
|
+
end # more duplicate cases
|
2088
|
+
|
2089
|
+
end # insert_snippet
|
2090
|
+
|
2091
|
+
end # SocialSnippet::Core
|