social_snippet 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +8 -8
  2. data/.travis.yml +11 -4
  3. data/README.md +6 -6
  4. data/Rakefile +19 -1
  5. data/lib/social_snippet.rb +11 -0
  6. data/lib/social_snippet/api/install_repository_api.rb +23 -82
  7. data/lib/social_snippet/api/manifest_api.rb +3 -3
  8. data/lib/social_snippet/api/update_repository_api.rb +34 -35
  9. data/lib/social_snippet/command_line/sspm/sub_commands/install_command.rb +7 -7
  10. data/lib/social_snippet/config.rb +18 -8
  11. data/lib/social_snippet/core.rb +13 -0
  12. data/lib/social_snippet/document.rb +2 -0
  13. data/lib/social_snippet/document_backend.rb +2 -0
  14. data/lib/social_snippet/document_backend/yaml_document.rb +252 -0
  15. data/lib/social_snippet/document_backend/yaml_document/query.rb +45 -0
  16. data/lib/social_snippet/repository.rb +2 -2
  17. data/lib/social_snippet/repository/driver_factory.rb +42 -0
  18. data/lib/social_snippet/repository/drivers.rb +3 -2
  19. data/lib/social_snippet/repository/drivers/driver_base.rb +100 -0
  20. data/lib/social_snippet/repository/drivers/entry.rb +11 -0
  21. data/lib/social_snippet/repository/drivers/git_driver.rb +100 -0
  22. data/lib/social_snippet/repository/models.rb +15 -0
  23. data/lib/social_snippet/repository/models/package.rb +97 -0
  24. data/lib/social_snippet/repository/models/repository.rb +94 -0
  25. data/lib/social_snippet/repository/repository_manager.rb +79 -67
  26. data/lib/social_snippet/resolvers/base_resolver.rb +13 -17
  27. data/lib/social_snippet/rspec/test_document.rb +305 -0
  28. data/lib/social_snippet/rspec/test_driver.rb +76 -0
  29. data/lib/social_snippet/rspec/test_storage.rb +459 -0
  30. data/lib/social_snippet/storage.rb +1 -0
  31. data/lib/social_snippet/storage_backend.rb +3 -0
  32. data/lib/social_snippet/storage_backend/file_system_storage.rb +71 -0
  33. data/lib/social_snippet/storage_backend/storage_base.rb +35 -0
  34. data/lib/social_snippet/version.rb +8 -3
  35. data/spec/helpers/codeclimate_helper.rb +1 -1
  36. data/spec/helpers/fakefs_helper.rb +10 -0
  37. data/spec/helpers/social_snippet_helper.rb +117 -0
  38. data/spec/lib/api/insert_snippet_spec.rb +95 -2
  39. data/spec/lib/api/update_repository_spec.rb +196 -0
  40. data/spec/lib/command_line/sspm_install_spec.rb +169 -180
  41. data/spec/lib/command_line/sspm_update_spec.rb +56 -0
  42. data/spec/lib/config_spec.rb +6 -8
  43. data/spec/lib/core_spec.rb +21 -38
  44. data/spec/lib/file_system_storage_spec.rb +170 -0
  45. data/spec/lib/insert_resolver_spec.rb +15 -2
  46. data/spec/lib/registry_client_spec.rb +6 -9
  47. data/spec/lib/repository/driver_base_spec.rb +89 -0
  48. data/spec/lib/repository/git_driver_spec.rb +10 -0
  49. data/spec/lib/repository/package_spec.rb +172 -0
  50. data/spec/lib/repository/repository_factory_spec.rb +67 -22
  51. data/spec/lib/repository/repository_manager_spec.rb +71 -114
  52. data/spec/lib/repository/repository_spec.rb +191 -0
  53. data/spec/lib/yaml_document_spec.rb +14 -0
  54. data/spec/spec_helper.rb +8 -93
  55. data/test/config_test.rb +6 -7
  56. data/test/driver_base_test.rb +201 -0
  57. data/test/git_driver_test.rb +51 -0
  58. data/test/insert_snippet_test.rb +256 -349
  59. data/test/repository_manager_test.rb +7 -16
  60. data/test/yaml_document_test.rb +97 -0
  61. metadata +44 -16
  62. data/lib/social_snippet/repository/drivers/base_repository.rb +0 -189
  63. data/lib/social_snippet/repository/drivers/git_repository.rb +0 -74
  64. data/lib/social_snippet/repository/repository_factory.rb +0 -59
  65. data/lib/social_snippet/repository/repository_installer.rb +0 -85
  66. data/spec/lib/repository/base_repository_spec.rb +0 -104
  67. data/spec/lib/repository/git_repository_spec.rb +0 -83
  68. data/spec/lib/repository/repository_installer_spec.rb +0 -63
  69. data/test/base_repository_test.rb +0 -375
  70. data/test/git_repository_test.rb +0 -114
@@ -0,0 +1 @@
1
+ class SocialSnippet::Storage < SocialSnippet::StorageBackend::StorageBase; end
@@ -0,0 +1,3 @@
1
+ require_relative "storage_backend/storage_base"
2
+ require_relative "storage_backend/file_system_storage"
3
+ module SocialSnippet::StorageBackend; end
@@ -0,0 +1,71 @@
1
+ module SocialSnippet::StorageBackend
2
+
3
+ class FileSystemStorage < StorageBase
4
+
5
+ def read(path)
6
+ ::File.read path
7
+ end
8
+
9
+ def write(path, data)
10
+ ::File.write path, data
11
+ end
12
+
13
+ def touch(path)
14
+ ::FileUtils.touch path
15
+ end
16
+
17
+ def cp_r(src, dest)
18
+ ::FileUtils.cp_r src, dest
19
+ end
20
+
21
+ def rm(path)
22
+ ::FileUtils.rm path
23
+ end
24
+
25
+ def rm_r(path)
26
+ ::FileUtils.rm_r path
27
+ end
28
+
29
+ def cd(path)
30
+ ::FileUtils.cd path
31
+ end
32
+
33
+ def pwd
34
+ ::Dir.pwd
35
+ end
36
+
37
+ def glob(glob_path)
38
+ ::Dir.glob glob_path
39
+ end
40
+
41
+ def exists?(path)
42
+ ::File.exists? path
43
+ end
44
+
45
+ def file?(path)
46
+ ::File.file? path
47
+ end
48
+
49
+ def directory?(path)
50
+ ::File.directory? path
51
+ end
52
+
53
+ def mkdir(path)
54
+ ::FileUtils.mkdir path
55
+ end
56
+
57
+ def mkdir_p(path)
58
+ ::FileUtils.mkdir_p path
59
+ end
60
+
61
+ def self.activate!
62
+ ::SocialSnippet.class_eval do
63
+ remove_const :Storage
64
+ const_set :Storage, ::SocialSnippet::StorageBackend::FileSystemStorage
65
+ end
66
+ end
67
+
68
+ end
69
+
70
+ end
71
+
@@ -0,0 +1,35 @@
1
+ module SocialSnippet::StorageBackend
2
+
3
+ class StorageBase
4
+
5
+ def read(path)
6
+ raise "not implemented"
7
+ end
8
+
9
+ def write(path, data)
10
+ raise "not implemented"
11
+ end
12
+
13
+ def glob(glob_path)
14
+ raise "not implemented"
15
+ end
16
+
17
+ def exists?(path)
18
+ raise "not implemented"
19
+ end
20
+
21
+ def file?(path)
22
+ raise "not implemented"
23
+ end
24
+
25
+ def directory?(path)
26
+ raise "not implemented"
27
+ end
28
+
29
+ def mkdir_p(path)
30
+ raise "not implemented"
31
+ end
32
+
33
+ end
34
+
35
+ end
@@ -1,6 +1,6 @@
1
1
  module SocialSnippet
2
2
 
3
- VERSION = "0.0.9"
3
+ VERSION = "0.0.10"
4
4
 
5
5
  module Version
6
6
 
@@ -13,12 +13,17 @@ module SocialSnippet
13
13
 
14
14
  # "2.1.0" and "2.1.1" match "2.1"
15
15
  # "2.11.0" and "2.11.1" do not match "2.1"
16
- return version.start_with?("#{pattern}.")
16
+ version.start_with?("#{pattern}.")
17
17
  end
18
18
 
19
19
  # Check given text is version string
20
20
  def is_version(s)
21
- return /^([0]|[1-9][0-9]*)\.([0]|[1-9][0-9]*)\.([0]|[1-9][0-9]*)$/ === s
21
+ /^([0]|[1-9][0-9]*)\.([0]|[1-9][0-9]*)\.([0]|[1-9][0-9]*)$/ === s
22
+ end
23
+
24
+ # "1.2.3" => "1.2"
25
+ def minor(s)
26
+ /^(([0]|[1-9][0-9]*)\.([0]|[1-9][0-9]*))\.([0]|[1-9][0-9]*)$/.match(s)[1]
22
27
  end
23
28
 
24
29
  end
@@ -1,4 +1,4 @@
1
- if ENV["TRAVIS"] == "true"
1
+ if ENV["TRAVIS"] === "true" && ENV["ENABLE_CODECLIMATE"] === "true"
2
2
  require "codeclimate-test-reporter"
3
3
  CodeClimate::TestReporter.start
4
4
  end
@@ -13,3 +13,13 @@ module FakeFSHelpers
13
13
 
14
14
  end
15
15
 
16
+ module SocialSnippet
17
+ ::RSpec.configure do |config|
18
+ config.include FakeFSHelpers
19
+ config.before { enable_fakefs }
20
+ config.before(:example, :without_fakefs => true) { disable_fakefs }
21
+ config.after { disable_fakefs }
22
+ end
23
+ end
24
+
25
+ $WITHOUT_FAKEFS = (ENV["RSPEC_WITHOUT_FAKEFS"] === "true")
@@ -0,0 +1,117 @@
1
+ module SocialSnippet::SpecHelpers
2
+
3
+ class FakeCore; end
4
+
5
+ def fake_storage
6
+ @fake_storage ||= ::SocialSnippet::Storage.new
7
+ end
8
+
9
+ def fake_io
10
+ @fake_io ||= ::StringIO.new
11
+ end
12
+
13
+ def fake_logger
14
+ reset_fake_logger unless @logger
15
+ @logger
16
+ end
17
+
18
+ def reset_fake_logger
19
+ @logger = ::SocialSnippet::Logger.new(fake_io)
20
+ @logger.level = ::SocialSnippet::Logger::Severity::INFO
21
+ end
22
+
23
+ def fake_home
24
+ reset_fake_home unless @tmp_path
25
+ @tmp_path
26
+ end
27
+
28
+ def reset_fake_home
29
+ tmp_root = ::File.join(::Dir.tmpdir, "social_snippet")
30
+ ::FileUtils.mkdir_p tmp_root
31
+ @tmp_path = ::Dir.mktmpdir(nil, tmp_root)
32
+ end
33
+
34
+ def make_fake_home
35
+ fake_config.init_filesystem
36
+ end
37
+
38
+ def global_config
39
+ $social_snippet_config ||= ::SocialSnippet::Config.new(
40
+ fake_core,
41
+ {
42
+ :home => fake_home,
43
+ :sspm_host => "api.server",
44
+ },
45
+ )
46
+ end
47
+
48
+ def enable_global_config
49
+ @enable_global_config = true
50
+ end
51
+
52
+ def fake_config
53
+ @config ||= ::SocialSnippet::Config.new(
54
+ fake_core,
55
+ {
56
+ :home => fake_home,
57
+ :sspm_host => "api.server",
58
+ },
59
+ )
60
+ end
61
+
62
+ def fake_api
63
+ @fake_api ||= ::SocialSnippet::Api.new(fake_core)
64
+ end
65
+
66
+ def fake_core
67
+ reset_fake_core unless @fake_core
68
+ @fake_core
69
+ end
70
+
71
+ def fake_repo_manager
72
+ @fake_repo_manager ||= ::SocialSnippet::Repository::RepositoryManager.new(fake_core)
73
+ end
74
+
75
+ def fake_driver_factory
76
+ @fake_driver_factory ||= ::SocialSnippet::Repository::DriverFactory.new(fake_core)
77
+ end
78
+
79
+ def fake_registry_client
80
+ @fake_registry_client ||= ::SocialSnippet::Registry::RegistryClient.new(fake_core)
81
+ end
82
+
83
+ def reset_fake_core
84
+ @fake_core = FakeCore.new
85
+ ::SocialSnippet::Repository::Models::Package.core = fake_core
86
+ ::SocialSnippet::Repository::Models::Repository.core = fake_core
87
+ allow(fake_core).to receive(:storage).and_return fake_storage
88
+ allow(fake_core).to receive(:logger).and_return fake_logger
89
+ allow(fake_core).to receive(:config).and_return fake_config
90
+ allow(fake_core).to receive(:api).and_return fake_api
91
+ allow(fake_core).to receive(:repo_manager).and_return fake_repo_manager
92
+ allow(fake_core).to receive(:driver_factory).and_return fake_driver_factory
93
+ allow(fake_core).to receive(:registry_client).and_return fake_registry_client
94
+ allow_any_instance_of(::SocialSnippet::CommandLine::Command).to receive(:core).and_return fake_core
95
+ end
96
+
97
+ end
98
+
99
+ module SocialSnippet
100
+ ::RSpec.configure do |config|
101
+ config.include SpecHelpers
102
+ config.before { reset_fake_core }
103
+ config.before { fake_core.driver_factory.reset_drivers }
104
+ end
105
+
106
+ # setup yaml document
107
+ ::RSpec.configure do |config|
108
+ config.before do
109
+ if ::SocialSnippet::Document == ::SocialSnippet::DocumentBackend::YAMLDocument
110
+ document_path = ::File.join(::Dir.mktmpdir, "document.yml")
111
+ $yaml_document_hash = nil
112
+ ::FileUtils.rm document_path if ::File.exists?(document_path)
113
+ ::SocialSnippet::DocumentBackend::YAMLDocument.set_path document_path
114
+ end
115
+ end
116
+ end
117
+ end
@@ -6,11 +6,104 @@ module SocialSnippet
6
6
 
7
7
  describe "#insert_snippet()", :without_fakefs => true do
8
8
 
9
+ class FakeDriver < ::SocialSnippet::Repository::Drivers::DriverBase
10
+ def fetch; end
11
+
12
+ def refs
13
+ [
14
+ "master",
15
+ "develop",
16
+ "1.0.0",
17
+ "1.0.1",
18
+ "1.0.2",
19
+ ]
20
+ end
21
+
22
+ def snippet_json
23
+ {
24
+ "name" => "example-repo",
25
+ "main" => "src",
26
+ }
27
+ end
28
+
29
+ def rev_hash(ref)
30
+ raise "error" unless refs.include?(ref)
31
+ "rev-#{ref}"
32
+ end
33
+
34
+ def each_directory(ref, &block)
35
+ [
36
+ ::SocialSnippet::Repository::Drivers::Entry.new("src", ""),
37
+ ::SocialSnippet::Repository::Drivers::Entry.new("src/func", ""),
38
+ ].each &block
39
+ end
40
+
41
+ def each_file(ref, &block)
42
+ files = []
43
+
44
+ # snippet.json
45
+ files.push ::SocialSnippet::Repository::Drivers::Entry.new "snippet.json", [
46
+ '{',
47
+ ' "name": "example-repo",',
48
+ ' "desc": "This is an example repository.",',
49
+ ' "language": "C++",',
50
+ ' "main": "src"',
51
+ '}',
52
+ ].join($/)
53
+
54
+ # src/func.cpp
55
+ files.push ::SocialSnippet::Repository::Drivers::Entry.new "src/func.cpp", [
56
+ '// @snip<func/sub_func_1.cpp>',
57
+ '// @snip<func/sub_func_2.cpp>',
58
+ '// @snip<func/sub_func_3.cpp>',
59
+ 'int func() {',
60
+ ' int res = 0;',
61
+ ' res += sub_func_1();',
62
+ ' res += sub_func_2();',
63
+ ' res += sub_func_3();',
64
+ ' res *= 2;',
65
+ ' return res;',
66
+ '}',
67
+ ].join($/)
68
+
69
+ # src/func/sub_func_1.cpp
70
+ files.push ::SocialSnippet::Repository::Drivers::Entry.new "src/func/sub_func_1.cpp", [
71
+ 'int sub_func_1() {',
72
+ ' return 1;',
73
+ '}',
74
+ ].join($/)
75
+
76
+ # src/func/sub_func_2.cpp
77
+ files.push ::SocialSnippet::Repository::Drivers::Entry.new "src/func/sub_func_2.cpp", [
78
+ 'int sub_func_2() {',
79
+ ' return 2;',
80
+ '}',
81
+ ].join($/)
82
+
83
+ # src/func/sub_func_3.cpp
84
+ files.push ::SocialSnippet::Repository::Drivers::Entry.new "src/func/sub_func_3.cpp", [
85
+ 'int sub_func_4() {',
86
+ ' return 3;',
87
+ '}',
88
+ ].join($/)
89
+
90
+ files.each &block
91
+ end
92
+
93
+ def self.target_url?(url)
94
+ "dummy" === ::URI.parse(url).scheme
95
+ end
96
+ end
97
+
98
+ before do
99
+ fake_core.driver_factory.add_driver FakeDriver
100
+ end
101
+
9
102
  let(:example_repo_info) do
10
103
  {
11
104
  "name" => "example-repo",
12
105
  "desc" => "This is my repository.",
13
- "url" => "https://github.com/social-snippet/example-repo",
106
+ "url" => "dummy://driver.test/social-snippet/example-repo",
14
107
  "dependencies" => {
15
108
  },
16
109
  }
@@ -85,12 +178,12 @@ module SocialSnippet
85
178
 
86
179
  before { fake_core.api.insert_snippet input }
87
180
 
88
- # last update: 2014-10-28
89
181
  it { expect(string_io.string).to match(/@snippet/) }
90
182
  it { expect(string_io.string).to match(/example-repo#.*:func\.cpp/) }
91
183
  it { expect(string_io.string).to match(/example-repo#.*:func\/sub_func_1\.cpp/) }
92
184
  it { expect(string_io.string).to match(/example-repo#.*:func\/sub_func_2\.cpp/) }
93
185
  it { expect(string_io.string).to match(/example-repo#.*:func\/sub_func_3\.cpp/) }
186
+ it { expect(string_io.string).to_not match(/ERROR/) }
94
187
 
95
188
  end # $ ssnip / with a snip tag
96
189
 
@@ -0,0 +1,196 @@
1
+ require "spec_helper"
2
+
3
+ describe ::SocialSnippet::Api::UpdateRepositoryApi do
4
+
5
+ describe "has dependencies" do
6
+
7
+ context "prepare stubs" do
8
+
9
+ let(:graph_algo_url) { "dummy://driver.test/user/graph-algo" }
10
+ let(:adjacent_list_url) { "dummy://driver.test/user/adjacent-list" }
11
+ let(:graph_interface_url) { "dummy://driver.test/user/graph-interface" }
12
+
13
+ before do
14
+ allow(fake_core.repo_manager).to receive(:install).with(graph_interface_url, "1.2.3", kind_of(::Hash)) do
15
+ repo = ::SocialSnippet::Repository::Models::Repository.find_or_create_by(:name => "graph-interface")
16
+ repo.update_attributes! :url => graph_interface_url
17
+ repo.add_ref "1.2.3", "rev-1.2.3"
18
+ pkg = ::SocialSnippet::Repository::Models::Package.create(
19
+ :repo_name => "graph-interface",
20
+ :rev_hash => "rev-1.2.3",
21
+ )
22
+ pkg.add_file "snippet.json", {}.to_json
23
+ pkg
24
+ end
25
+ allow(fake_core.api).to receive(:resolve_name_by_registry).with("graph-interface") do
26
+ graph_interface_url
27
+ end
28
+ end
29
+
30
+ before do
31
+ allow(fake_core.repo_manager).to receive(:install).with(adjacent_list_url, "9.9.9", kind_of(::Hash)) do
32
+ repo = ::SocialSnippet::Repository::Models::Repository.find_or_create_by(:name => "adjacent-list")
33
+ repo.update_attributes! :url => adjacent_list_url
34
+ repo.add_ref "9.9.9", "rev-9.9.9"
35
+ pkg = ::SocialSnippet::Repository::Models::Package.create(
36
+ :repo_name => "adjacent-list",
37
+ :rev_hash => "rev-9.9.9",
38
+ )
39
+ pkg.add_file "snippet.json", {}.to_json
40
+ pkg.add_dependency "graph-interface", "1.2.3"
41
+ pkg
42
+ end
43
+ allow(fake_core.api).to receive(:resolve_name_by_registry).with("adjacent-list") do
44
+ adjacent_list_url
45
+ end
46
+ end
47
+
48
+ before do
49
+ allow(fake_core.repo_manager).to receive(:install).with(graph_algo_url, "1.0.0", kind_of(::Hash)) do
50
+ repo = ::SocialSnippet::Repository::Models::Repository.find_or_create_by(:name => "graph-algo")
51
+ repo.update_attributes! :url => graph_algo_url
52
+ repo.add_ref "1.0.0", "rev-1.0.0"
53
+ repo.add_package "1.0.0"
54
+ pkg = ::SocialSnippet::Repository::Models::Package.create(
55
+ :repo_name => "graph-algo",
56
+ :rev_hash => "rev-1.0.0",
57
+ )
58
+ pkg.add_file "snippet.json", {}.to_json
59
+ pkg
60
+ end
61
+ allow(fake_core.api).to receive(:resolve_name_by_registry).with("graph-algo") do
62
+ graph_algo_url
63
+ end
64
+ end
65
+
66
+ before { fake_core.api.install_repository graph_algo_url, "1.0.0" }
67
+ it { expect(fake_core.repo_manager.exists? "graph-algo", "1.0.0").to be_truthy }
68
+ it { expect(fake_core.repo_manager.exists? "adjacent-list", "9.9.9").to be_falsey }
69
+ it { expect(fake_core.repo_manager.exists? "graph-interface", "1.2.3").to be_falsey}
70
+
71
+ context "prepare update for graph-algo" do
72
+
73
+ class FakeDriverGraphAlgo < ::SocialSnippet::Repository::Drivers::DriverBase
74
+ def fetch; end
75
+
76
+ def snippet_json
77
+ {
78
+ "name" => "graph-algo",
79
+ "dependencies" => {
80
+ "adjacent-list" => "9.9.9",
81
+ },
82
+ }
83
+ end
84
+
85
+ def rev_hash(ref)
86
+ if refs.include?(ref)
87
+ "rev-#{ref}"
88
+ else
89
+ raise "error"
90
+ end
91
+ end
92
+
93
+ def each_directory(ref); end
94
+ def each_file(ref, &block)
95
+ [
96
+ ::SocialSnippet::Repository::Drivers::Entry.new("snippet.json", snippet_json.to_json)
97
+ ].each(&block)
98
+ end
99
+
100
+ def refs
101
+ ["1.0.0", "1.0.1"]
102
+ end
103
+
104
+ def self.target_url?(url)
105
+ "dummy" === ::URI.parse(url).scheme
106
+ end
107
+ end # class FakeDriverGraphAlgo
108
+
109
+ before do
110
+ fake_core.driver_factory.reset_drivers
111
+ fake_core.driver_factory.add_driver FakeDriverGraphAlgo
112
+ end
113
+
114
+ context "update graph-algo" do
115
+ before { fake_core.api.update_repository "graph-algo" }
116
+ it { expect(fake_core.repo_manager.exists? "graph-algo", "1.0.0").to be_truthy }
117
+ it { expect(fake_core.repo_manager.exists? "graph-algo", "1.0.1").to be_truthy }
118
+ it { expect(fake_core.repo_manager.exists? "adjacent-list", "9.9.9").to be_truthy }
119
+ it { expect(fake_core.repo_manager.exists? "graph-interface", "1.2.3").to be_truthy }
120
+ end
121
+ end
122
+
123
+ end
124
+
125
+ end
126
+
127
+ context "prepare driver" do
128
+
129
+ class FakeDriverUpdateTest < ::SocialSnippet::Repository::Drivers::DriverBase
130
+ def fetch; end
131
+
132
+ def snippet_json
133
+ {
134
+ "name" => "my-repo"
135
+ }
136
+ end
137
+
138
+ def rev_hash(ref)
139
+ if refs.include?(ref)
140
+ "rev-#{ref}"
141
+ else
142
+ raise "error"
143
+ end
144
+ end
145
+
146
+ def each_directory(ref); end
147
+ def each_file(ref, &block)
148
+ [
149
+ ::SocialSnippet::Repository::Drivers::Entry.new("snippet.json", snippet_json.to_json),
150
+ ].each(&block)
151
+ end
152
+
153
+ def refs
154
+ self.class.refs
155
+ end
156
+
157
+ def self.refs
158
+ @refs ||= new_refs
159
+ end
160
+
161
+ def self.new_refs
162
+ ["1.0.0"]
163
+ end
164
+
165
+ def self.add_ref(ref)
166
+ @refs.push ref
167
+ end
168
+
169
+ def self.target_url?(url)
170
+ "dummy" === ::URI.parse(url).scheme
171
+ end
172
+ end # class FakeDriverUpdateTest
173
+
174
+ before do
175
+ fake_core.driver_factory.reset_drivers
176
+ fake_core.driver_factory.add_driver FakeDriverUpdateTest
177
+ end
178
+
179
+ context "install my-repo#1.0.0" do
180
+ before { fake_core.api.install_repository "dummy://driver.test/user/my-repo", "1.0.0" }
181
+ it { expect(fake_core.repo_manager.exists? "my-repo", "1.0.0").to be_truthy }
182
+ it { expect(fake_core.repo_manager.exists? "my-repo", "1.0.1").to be_falsey }
183
+ context "add 1.0.1" do
184
+ before { FakeDriverUpdateTest.add_ref "1.0.1" }
185
+ context "update my-repo" do
186
+ before { fake_core.api.update_repository "my-repo" }
187
+ it { expect(fake_core.repo_manager.exists? "my-repo", "1.0.0").to be_truthy }
188
+ it { expect(fake_core.repo_manager.exists? "my-repo", "1.0.1").to be_truthy }
189
+ end
190
+ end
191
+ end # install my-repo#1.0.0
192
+
193
+ end # prepare driver
194
+
195
+ end # ::SocialSnippet::Api::UpdateRepositoryApi
196
+