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.
- checksums.yaml +8 -8
- data/.travis.yml +11 -4
- data/README.md +6 -6
- data/Rakefile +19 -1
- data/lib/social_snippet.rb +11 -0
- data/lib/social_snippet/api/install_repository_api.rb +23 -82
- data/lib/social_snippet/api/manifest_api.rb +3 -3
- data/lib/social_snippet/api/update_repository_api.rb +34 -35
- data/lib/social_snippet/command_line/sspm/sub_commands/install_command.rb +7 -7
- data/lib/social_snippet/config.rb +18 -8
- data/lib/social_snippet/core.rb +13 -0
- data/lib/social_snippet/document.rb +2 -0
- data/lib/social_snippet/document_backend.rb +2 -0
- data/lib/social_snippet/document_backend/yaml_document.rb +252 -0
- data/lib/social_snippet/document_backend/yaml_document/query.rb +45 -0
- data/lib/social_snippet/repository.rb +2 -2
- data/lib/social_snippet/repository/driver_factory.rb +42 -0
- data/lib/social_snippet/repository/drivers.rb +3 -2
- data/lib/social_snippet/repository/drivers/driver_base.rb +100 -0
- data/lib/social_snippet/repository/drivers/entry.rb +11 -0
- data/lib/social_snippet/repository/drivers/git_driver.rb +100 -0
- data/lib/social_snippet/repository/models.rb +15 -0
- data/lib/social_snippet/repository/models/package.rb +97 -0
- data/lib/social_snippet/repository/models/repository.rb +94 -0
- data/lib/social_snippet/repository/repository_manager.rb +79 -67
- data/lib/social_snippet/resolvers/base_resolver.rb +13 -17
- data/lib/social_snippet/rspec/test_document.rb +305 -0
- data/lib/social_snippet/rspec/test_driver.rb +76 -0
- data/lib/social_snippet/rspec/test_storage.rb +459 -0
- data/lib/social_snippet/storage.rb +1 -0
- data/lib/social_snippet/storage_backend.rb +3 -0
- data/lib/social_snippet/storage_backend/file_system_storage.rb +71 -0
- data/lib/social_snippet/storage_backend/storage_base.rb +35 -0
- data/lib/social_snippet/version.rb +8 -3
- data/spec/helpers/codeclimate_helper.rb +1 -1
- data/spec/helpers/fakefs_helper.rb +10 -0
- data/spec/helpers/social_snippet_helper.rb +117 -0
- data/spec/lib/api/insert_snippet_spec.rb +95 -2
- data/spec/lib/api/update_repository_spec.rb +196 -0
- data/spec/lib/command_line/sspm_install_spec.rb +169 -180
- data/spec/lib/command_line/sspm_update_spec.rb +56 -0
- data/spec/lib/config_spec.rb +6 -8
- data/spec/lib/core_spec.rb +21 -38
- data/spec/lib/file_system_storage_spec.rb +170 -0
- data/spec/lib/insert_resolver_spec.rb +15 -2
- data/spec/lib/registry_client_spec.rb +6 -9
- data/spec/lib/repository/driver_base_spec.rb +89 -0
- data/spec/lib/repository/git_driver_spec.rb +10 -0
- data/spec/lib/repository/package_spec.rb +172 -0
- data/spec/lib/repository/repository_factory_spec.rb +67 -22
- data/spec/lib/repository/repository_manager_spec.rb +71 -114
- data/spec/lib/repository/repository_spec.rb +191 -0
- data/spec/lib/yaml_document_spec.rb +14 -0
- data/spec/spec_helper.rb +8 -93
- data/test/config_test.rb +6 -7
- data/test/driver_base_test.rb +201 -0
- data/test/git_driver_test.rb +51 -0
- data/test/insert_snippet_test.rb +256 -349
- data/test/repository_manager_test.rb +7 -16
- data/test/yaml_document_test.rb +97 -0
- metadata +44 -16
- data/lib/social_snippet/repository/drivers/base_repository.rb +0 -189
- data/lib/social_snippet/repository/drivers/git_repository.rb +0 -74
- data/lib/social_snippet/repository/repository_factory.rb +0 -59
- data/lib/social_snippet/repository/repository_installer.rb +0 -85
- data/spec/lib/repository/base_repository_spec.rb +0 -104
- data/spec/lib/repository/git_repository_spec.rb +0 -83
- data/spec/lib/repository/repository_installer_spec.rb +0 -63
- data/test/base_repository_test.rb +0 -375
- data/test/git_repository_test.rb +0 -114
@@ -1,31 +1,76 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
|
3
|
+
describe ::SocialSnippet::Repository::DriverFactory do
|
4
4
|
|
5
|
-
|
5
|
+
let(:driver_factory) { ::SocialSnippet::Repository::DriverFactory.new fake_core }
|
6
6
|
|
7
|
-
|
7
|
+
class FakeGitDriver < ::SocialSnippet::Repository::Drivers::DriverBase
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
end
|
13
|
-
end # git protocol
|
9
|
+
def self.target_url?(s)
|
10
|
+
/^git:\/\// === s
|
11
|
+
end
|
14
12
|
|
15
|
-
|
16
|
-
|
17
|
-
it { expect(RepositoryFactory.is_git_repo(URI.parse("git://github.com/user/repo"))).to be_truthy }
|
18
|
-
end
|
19
|
-
context "http://" do
|
20
|
-
it { expect(RepositoryFactory.is_git_repo(URI.parse("http://github.com/user/repo"))).to be_truthy }
|
21
|
-
end
|
22
|
-
context "https://" do
|
23
|
-
it { expect(RepositoryFactory.is_git_repo(URI.parse("https://github.com/user/repo"))).to be_truthy }
|
24
|
-
end
|
25
|
-
end # github.com
|
13
|
+
def fetch
|
14
|
+
end
|
26
15
|
|
27
|
-
|
16
|
+
def snippet_json
|
17
|
+
{
|
18
|
+
"name" => "fake-repo",
|
19
|
+
}
|
20
|
+
end
|
28
21
|
|
29
|
-
|
22
|
+
def latest_version
|
23
|
+
"1.2.3"
|
24
|
+
end
|
25
|
+
|
26
|
+
def rev_hash(ref)
|
27
|
+
if ref === "1.2.3"
|
28
|
+
"rev-1.2.3"
|
29
|
+
else
|
30
|
+
raise "error"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def each_directory
|
35
|
+
[
|
36
|
+
::SocialSnippet::Repository::Drivers::Entry.new("path"),
|
37
|
+
::SocialSnippet::Repository::Drivers::Entry.new("path/to"),
|
38
|
+
].each do |dir|
|
39
|
+
yield dir
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def each_file
|
44
|
+
[
|
45
|
+
::SocialSnippet::Repository::Drivers::Entry.new("snippet.json", {:name => "fake-repo"}.to_json),
|
46
|
+
::SocialSnippet::Repository::Drivers::Entry.new("path/to/file", "file"),
|
47
|
+
].each do |dir|
|
48
|
+
yield dir
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def refs
|
53
|
+
["1.2.3"]
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
context "reset drivers" do
|
59
|
+
|
60
|
+
before { driver_factory.reset_drivers }
|
61
|
+
|
62
|
+
context "add FakeGitDriver" do
|
63
|
+
|
64
|
+
before { driver_factory.add_driver FakeGitDriver }
|
65
|
+
|
66
|
+
context "clone git://github.com/user/repo" do
|
67
|
+
let(:driver) { driver_factory.clone "git://github.com/user/repo" }
|
68
|
+
it { expect(driver.snippet_json["name"]).to eq "fake-repo" }
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
end # driver_factory
|
30
76
|
|
31
|
-
end # SocialSnippet::Repository
|
@@ -4,8 +4,6 @@ module SocialSnippet::Repository
|
|
4
4
|
|
5
5
|
describe RepositoryManager do
|
6
6
|
|
7
|
-
before { stub_const "ENV", "SOCIAL_SNIPPET_HOME" => "/path/to" }
|
8
|
-
|
9
7
|
let(:rest_resource) { ::RestClient::Resource.new "http://api.server/api/dummy" }
|
10
8
|
|
11
9
|
before do
|
@@ -14,30 +12,29 @@ module SocialSnippet::Repository
|
|
14
12
|
end
|
15
13
|
end # use dummy api server
|
16
14
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
15
|
+
before do # prepare repo_a
|
16
|
+
repo = ::SocialSnippet::Repository::Models::Repository.create(
|
17
|
+
:name => "repo_a",
|
18
|
+
:url => "dummy://driver.test/user/repo_a",
|
19
|
+
)
|
20
|
+
repo.add_ref "master", "rev-master"
|
21
|
+
repo.add_ref "develop", "rev-develop"
|
22
|
+
repo.add_ref "1.2.3", "rev-1.2.3"
|
23
|
+
repo.update_attributes! :current_ref => "master"
|
24
|
+
|
25
|
+
# prepare package
|
26
|
+
repo.add_package "1.2.3"
|
27
|
+
package = ::SocialSnippet::Repository::Models::Package.create(
|
28
|
+
:repo_name => "repo_a",
|
29
|
+
:rev_hash => "rev-1.2.3",
|
30
|
+
)
|
31
|
+
package.add_file "snippet.json", {
|
32
|
+
:name => "repo_a",
|
33
|
+
:main => "src",
|
34
|
+
:desc => "this is repo_a",
|
35
|
+
}.to_json
|
35
36
|
end
|
36
37
|
|
37
|
-
let(:repo_manager) { RepositoryManager.new social_snippet }
|
38
|
-
let(:commit_id) { "dummycommitid" }
|
39
|
-
let(:short_commit_id) { commit_id[0..7] }
|
40
|
-
|
41
38
|
describe "#resolve_snippet_path" do
|
42
39
|
|
43
40
|
context "without repo" do
|
@@ -51,7 +48,7 @@ module SocialSnippet::Repository
|
|
51
48
|
let(:tag) { ::SocialSnippet::Tag.new("// @snip<./file2.cpp>") }
|
52
49
|
|
53
50
|
context "result" do
|
54
|
-
subject { repo_manager.resolve_snippet_path(context, tag) }
|
51
|
+
subject { fake_core.repo_manager.resolve_snippet_path(context, tag) }
|
55
52
|
it { should eq "path/to/file2.cpp" }
|
56
53
|
end
|
57
54
|
|
@@ -63,7 +60,7 @@ module SocialSnippet::Repository
|
|
63
60
|
before { context.move tag.path }
|
64
61
|
|
65
62
|
context "result" do
|
66
|
-
subject { repo_manager.resolve_snippet_path(context, tag) }
|
63
|
+
subject { fake_core.repo_manager.resolve_snippet_path(context, tag) }
|
67
64
|
it { should eq "path/to/subdir/file3.cpp" }
|
68
65
|
end
|
69
66
|
|
@@ -75,31 +72,6 @@ module SocialSnippet::Repository
|
|
75
72
|
|
76
73
|
context "with repo" do
|
77
74
|
|
78
|
-
let(:repo_path) { "#{ENV["SOCIAL_SNIPPET_HOME"]}/repo" }
|
79
|
-
|
80
|
-
before do
|
81
|
-
FileUtils.mkdir_p "#{repo_path}/repo_a"
|
82
|
-
FileUtils.mkdir_p "#{repo_path}/repo_a/.git"
|
83
|
-
FileUtils.touch "#{repo_path}/repo_a/snippet.json"
|
84
|
-
|
85
|
-
File.write "#{repo_path}/repo_a/snippet.json", [
|
86
|
-
'{',
|
87
|
-
' "name": "repo_a",',
|
88
|
-
' "desc": "this is repo_a",',
|
89
|
-
' "language": "C++",',
|
90
|
-
' "main": "src"',
|
91
|
-
'}',
|
92
|
-
].join($/)
|
93
|
-
|
94
|
-
allow(repo_manager).to receive(:find_repository).with("repo_a") do |path|
|
95
|
-
repo = ::SocialSnippet::Repository::Drivers::BaseRepository.new("#{repo_path}/repo_a")
|
96
|
-
expect(repo).to receive(:commit_id).and_return commit_id
|
97
|
-
repo.load_snippet_json
|
98
|
-
repo.create_cache repo_manager.repo_cache_path
|
99
|
-
repo
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
75
|
context "cur = path/to/file.cpp" do
|
104
76
|
|
105
77
|
let(:context) { ::SocialSnippet::Context.new("path/to/file.cpp") }
|
@@ -109,8 +81,8 @@ module SocialSnippet::Repository
|
|
109
81
|
let(:tag) { ::SocialSnippet::Tag.new("// @snip<repo_a:path/to/file2.cpp>") }
|
110
82
|
|
111
83
|
context "result" do
|
112
|
-
subject { repo_manager.resolve_snippet_path(context, tag) }
|
113
|
-
it { should eq "
|
84
|
+
subject { fake_core.repo_manager.resolve_snippet_path(context, tag) }
|
85
|
+
it { should eq ::File.join(fake_core.config.home, "packages", "repo_a", "rev-1.2.3", "src", "path", "to", "file2.cpp") }
|
114
86
|
end
|
115
87
|
|
116
88
|
end # snip<./file2.cpp>
|
@@ -121,85 +93,70 @@ module SocialSnippet::Repository
|
|
121
93
|
|
122
94
|
end # resolve_snippet_path
|
123
95
|
|
124
|
-
describe "#
|
125
|
-
|
126
|
-
let(:repo_path) { "#{ENV["SOCIAL_SNIPPET_HOME"]}/repo" }
|
96
|
+
describe "#find_package" do
|
127
97
|
|
128
|
-
context "
|
98
|
+
context "find_package nil" do
|
129
99
|
|
130
|
-
|
131
|
-
|
100
|
+
subject do
|
101
|
+
lambda { fake_core.repo_manager.find_package nil }
|
102
|
+
end
|
103
|
+
it { should raise_error }
|
132
104
|
|
133
105
|
end
|
134
106
|
|
135
|
-
context "
|
136
|
-
|
137
|
-
|
138
|
-
FileUtils.mkdir_p "#{repo_path}/repo_a"
|
139
|
-
FileUtils.mkdir_p "#{repo_path}/repo_a/.git"
|
140
|
-
FileUtils.touch "#{repo_path}/repo_a/snippet.json"
|
141
|
-
|
142
|
-
File.write "#{repo_path}/repo_a/snippet.json", [
|
143
|
-
'{',
|
144
|
-
' "name": "repo_a",',
|
145
|
-
' "desc": "this is repo_a",',
|
146
|
-
' "language": "C++"',
|
147
|
-
'}',
|
148
|
-
].join($/)
|
107
|
+
context "find_package empty_str" do
|
108
|
+
subject do
|
109
|
+
lambda { fake_core.repo_manager.find_package "" }
|
149
110
|
end
|
111
|
+
it { should raise_error }
|
112
|
+
end
|
150
113
|
|
151
|
-
|
152
|
-
expect(::SocialSnippet::Repository::Drivers::GitRepository).to receive(:new) do |path|
|
153
|
-
::SocialSnippet::Repository::Drivers::BaseRepository.new(path)
|
154
|
-
end
|
155
|
-
expect_any_instance_of(::SocialSnippet::Repository::Drivers::BaseRepository).to receive(:commit_id).and_return commit_id
|
156
|
-
end
|
114
|
+
context "create repo_a as a git repo" do
|
157
115
|
|
158
116
|
context "find repo_a" do
|
159
|
-
let(:repo) { repo_manager.
|
160
|
-
it { expect(repo.name).to eq "repo_a" }
|
161
|
-
it { expect(repo.desc).to eq "this is repo_a" }
|
117
|
+
let(:repo) { fake_core.repo_manager.find_package("repo_a") }
|
118
|
+
it { expect(repo.snippet_json["name"]).to eq "repo_a" }
|
119
|
+
it { expect(repo.snippet_json["desc"]).to eq "this is repo_a" }
|
162
120
|
end # find repo_a
|
163
121
|
|
164
122
|
end # create three repos
|
165
123
|
|
166
|
-
end #
|
124
|
+
end # find_package
|
167
125
|
|
168
126
|
describe "find_repositories_start_with" do
|
169
127
|
|
170
|
-
|
171
|
-
|
172
|
-
before do
|
173
|
-
FileUtils.mkdir_p "#{dummy_install_path}"
|
174
|
-
FileUtils.mkdir_p "#{dummy_install_path}/my-repo"
|
175
|
-
FileUtils.mkdir_p "#{dummy_install_path}/new-repo"
|
176
|
-
FileUtils.mkdir_p "#{dummy_install_path}/my-graph-lib"
|
177
|
-
FileUtils.mkdir_p "#{dummy_install_path}/my-math-lib"
|
178
|
-
allow(repo_manager.installer).to receive(:path).and_return dummy_install_path
|
179
|
-
end # prepare install_path
|
180
|
-
|
181
|
-
context "find my-" do
|
182
|
-
subject { repo_manager.find_repositories_start_with("my-") }
|
183
|
-
it { should include "my-repo" }
|
184
|
-
it { should_not include "new-repo" }
|
185
|
-
it { should include "my-graph-lib" }
|
186
|
-
it { should include "my-math-lib" }
|
187
|
-
end
|
128
|
+
context "prepare repositories" do
|
188
129
|
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
130
|
+
before do
|
131
|
+
::SocialSnippet::Repository::Models::Repository.create :name => "my-repo"
|
132
|
+
::SocialSnippet::Repository::Models::Repository.create :name => "my-graph-lib"
|
133
|
+
::SocialSnippet::Repository::Models::Repository.create :name => "my-math-lib"
|
134
|
+
end
|
135
|
+
|
136
|
+
context "find my-" do
|
137
|
+
subject { fake_core.repo_manager.find_repositories_start_with("my-") }
|
138
|
+
it { should include "my-repo" }
|
139
|
+
it { should_not include "new-repo" }
|
140
|
+
it { should include "my-graph-lib" }
|
141
|
+
it { should include "my-math-lib" }
|
142
|
+
end
|
143
|
+
|
144
|
+
context "find my-re" do
|
145
|
+
subject { fake_core.repo_manager.find_repositories_start_with("my-re") }
|
146
|
+
it { should include "my-repo" }
|
147
|
+
it { should_not include "new-repo" }
|
148
|
+
it { should_not include "my-graph-lib" }
|
149
|
+
it { should_not include "my-math-lib" }
|
150
|
+
end
|
151
|
+
|
152
|
+
context "find new-" do
|
153
|
+
subject { fake_core.repo_manager.find_repositories_start_with("new-") }
|
154
|
+
it { should_not include "new-repo" }
|
155
|
+
it { should_not include "my-repo" }
|
156
|
+
it { should_not include "my-graph-lib" }
|
157
|
+
it { should_not include "my-math-lib" }
|
158
|
+
end
|
196
159
|
|
197
|
-
context "find new-" do
|
198
|
-
subject { repo_manager.find_repositories_start_with("new-") }
|
199
|
-
it { should include "new-repo" }
|
200
|
-
it { should_not include "my-repo" }
|
201
|
-
it { should_not include "my-graph-lib" }
|
202
|
-
it { should_not include "my-math-lib" }
|
203
160
|
end
|
204
161
|
|
205
162
|
end # find_repositories_start_with
|
@@ -0,0 +1,191 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe ::SocialSnippet::Repository::Models::Repository do
|
4
|
+
|
5
|
+
let(:repo_url) { "git://github.com/user/my-repo" }
|
6
|
+
let(:repo) do
|
7
|
+
::SocialSnippet::Repository::Models::Repository.new(
|
8
|
+
:url => repo_url,
|
9
|
+
)
|
10
|
+
end
|
11
|
+
|
12
|
+
before { ::SocialSnippet::Repository::Models::Repository.core = fake_core }
|
13
|
+
|
14
|
+
describe "#package_versions" do
|
15
|
+
|
16
|
+
context "add refs" do
|
17
|
+
|
18
|
+
before do
|
19
|
+
repo.add_ref "master", "rev-master"
|
20
|
+
repo.add_ref "1.0.0", "rev-1.0.0"
|
21
|
+
repo.add_ref "1.0.1", "rev-1.0.1"
|
22
|
+
repo.add_ref "1.1.0", "rev-1.1.0"
|
23
|
+
end
|
24
|
+
|
25
|
+
context "check package versions" do
|
26
|
+
subject { repo.package_versions }
|
27
|
+
it { should be_empty }
|
28
|
+
end
|
29
|
+
|
30
|
+
context "check package_ref_keys" do
|
31
|
+
subject { repo.package_ref_keys }
|
32
|
+
it { should be_empty }
|
33
|
+
end
|
34
|
+
|
35
|
+
context "add packages" do
|
36
|
+
|
37
|
+
before do
|
38
|
+
repo.add_package "master"
|
39
|
+
repo.add_package "1.0.0"
|
40
|
+
repo.add_package "1.0.1"
|
41
|
+
end
|
42
|
+
|
43
|
+
context "check package_ref_keys" do
|
44
|
+
subject { repo.package_ref_keys }
|
45
|
+
it { should_not be_empty }
|
46
|
+
it { should include "master" }
|
47
|
+
end
|
48
|
+
|
49
|
+
context "check latest_version" do
|
50
|
+
subject { repo.latest_version }
|
51
|
+
it { should eq "1.1.0" }
|
52
|
+
end
|
53
|
+
|
54
|
+
context "check latest_package_version" do
|
55
|
+
subject { repo.latest_package_version }
|
56
|
+
it { should eq "1.0.1" }
|
57
|
+
end
|
58
|
+
|
59
|
+
context "check package_minor_versions" do
|
60
|
+
subject { repo.package_minor_versions }
|
61
|
+
it { should include "1.0" }
|
62
|
+
it { should_not include "1.1" }
|
63
|
+
end
|
64
|
+
|
65
|
+
context "add package" do
|
66
|
+
|
67
|
+
before do
|
68
|
+
repo.add_package "1.1.0"
|
69
|
+
end
|
70
|
+
|
71
|
+
context "check latest_version" do
|
72
|
+
subject { repo.latest_version }
|
73
|
+
it { should eq "1.1.0" }
|
74
|
+
end
|
75
|
+
|
76
|
+
context "check latest_package_version" do
|
77
|
+
subject { repo.latest_package_version }
|
78
|
+
it { should eq "1.1.0" }
|
79
|
+
end
|
80
|
+
|
81
|
+
context "check package_minor_versions" do
|
82
|
+
subject { repo.package_minor_versions }
|
83
|
+
it { should include "1.0" }
|
84
|
+
it { should include "1.1" }
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
end #add_package
|
94
|
+
|
95
|
+
describe "#add_ref" do
|
96
|
+
context "add master" do
|
97
|
+
before { repo.add_ref "master", "rev-master" }
|
98
|
+
subject { repo.refs }
|
99
|
+
it { should include "master" }
|
100
|
+
it { expect(repo.rev_hash["master"]).to eq "rev-master" }
|
101
|
+
context "add develop" do
|
102
|
+
before { repo.add_ref "develop", "rev-develop" }
|
103
|
+
subject { repo.refs }
|
104
|
+
it { should include "develop" }
|
105
|
+
it { expect(repo.rev_hash["master"]).to eq "rev-master" }
|
106
|
+
it { expect(repo.rev_hash["develop"]).to eq "rev-develop" }
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end #add_ref
|
110
|
+
|
111
|
+
describe "#versions" do
|
112
|
+
subject { repo.versions }
|
113
|
+
context "add master" do
|
114
|
+
before { repo.add_ref "master", "rev-master" }
|
115
|
+
it { should_not include "master" }
|
116
|
+
context "add 1.2.3" do
|
117
|
+
before { repo.add_ref "1.2.3", "rev-develop" }
|
118
|
+
it { should_not be_empty }
|
119
|
+
it { should include "1.2.3" }
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end #versions
|
123
|
+
|
124
|
+
describe "#has_versions?" do
|
125
|
+
subject { repo.has_versions? }
|
126
|
+
context "add master" do
|
127
|
+
before { repo.add_ref "master", "rev-master" }
|
128
|
+
it { should be_falsey }
|
129
|
+
context "add 1.2.3" do
|
130
|
+
before { repo.add_ref "1.2.3", "rev-1.2.3" }
|
131
|
+
it { should be_truthy}
|
132
|
+
end
|
133
|
+
context "add 4.5" do
|
134
|
+
before { repo.add_ref "4.5", "rev-4.5" }
|
135
|
+
it { should be_falsey }
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end #versions
|
139
|
+
|
140
|
+
describe "#latest_version" do
|
141
|
+
subject { repo.latest_version }
|
142
|
+
context "add master" do
|
143
|
+
before { repo.add_ref "master", "rev-master" }
|
144
|
+
it { should be_nil }
|
145
|
+
context "add 10.0.0" do
|
146
|
+
before { repo.add_ref "10.0.0", "rev-10.0.0" }
|
147
|
+
it { should eq "10.0.0" }
|
148
|
+
context "add 10.0.1" do
|
149
|
+
before { repo.add_ref "10.0.1", "rev-10.0.1" }
|
150
|
+
it { should eq "10.0.1" }
|
151
|
+
context "add 10.1.0" do
|
152
|
+
before { repo.add_ref "10.1.0", "rev-10.1.0" }
|
153
|
+
it { should eq "10.1.0" }
|
154
|
+
context "add 9.999.9" do
|
155
|
+
before { repo.add_ref "9.999.9", "rev-9.999.9" }
|
156
|
+
it { should eq "10.1.0" }
|
157
|
+
context "latest_version 9" do
|
158
|
+
subject { repo.latest_version 9 }
|
159
|
+
it { should eq "9.999.9" }
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end #latest_version
|
167
|
+
|
168
|
+
describe "test persistence" do
|
169
|
+
|
170
|
+
context "repo.name = my-repo" do
|
171
|
+
|
172
|
+
before { repo.name = "my-repo" }
|
173
|
+
|
174
|
+
context "save!" do
|
175
|
+
|
176
|
+
before { repo.save! }
|
177
|
+
|
178
|
+
context "find my-repo" do
|
179
|
+
let(:my_repo) { ::SocialSnippet::Repository::Models::Repository.find_by :name => "my-repo" }
|
180
|
+
it { expect(my_repo.name).to eq "my-repo" }
|
181
|
+
it { expect(my_repo.url).to eq "git://github.com/user/my-repo" }
|
182
|
+
end
|
183
|
+
|
184
|
+
end # save repository
|
185
|
+
|
186
|
+
end # repo.set_name my-repo
|
187
|
+
|
188
|
+
end # test to store data
|
189
|
+
|
190
|
+
end # ::SocialSnippet::Repository::Models::Repository
|
191
|
+
|