learn-test 3.3.0.pre.5 → 3.3.0.pre.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/learn_test/git/wip/base.rb +1 -1
- data/lib/learn_test/git/wip/branch.rb +2 -2
- data/lib/learn_test/git/wip/errors/base_error.rb +11 -0
- data/lib/learn_test/git/wip/errors/no_changes_error.rb +15 -0
- data/lib/learn_test/git/wip/errors/no_commits_error.rb +17 -0
- data/lib/learn_test/git/wip/reference.rb +7 -1
- data/lib/learn_test/version.rb +1 -1
- data/spec/learn_test/git/wip/base_spec.rb +6 -2
- data/spec/learn_test/git/wip/branch_spec.rb +1 -1
- data/spec/learn_test/git/wip/errors/base_error_spec.rb +7 -0
- data/spec/learn_test/git/wip/errors/no_changes_error_spec.rb +18 -0
- data/spec/learn_test/git/wip/errors/no_commits_error_spec.rb +18 -0
- data/spec/spec_helper.rb +2 -0
- metadata +10 -4
- data/lib/learn_test/git/wip/error.rb +0 -23
- data/spec/learn_test/git/wip/error_spec.rb +0 -41
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7906a9d22e49996f18bf0b8c0cd1c7d76f5ef27447ee235b09403c58b6132340
|
4
|
+
data.tar.gz: 98f97cbd9e8d2b0bd643ff95e9e6f5ec11988a74a4e1a17819d303cbb2b9bba8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ded3c645f8ae0ef2f7a2ab4cf39819b42f6c82a5a93e7876ad2ab625199d033a311fbbff03adf736a6ac64cbb655ae03eb35147abeca20ee13a59efe6979453
|
7
|
+
data.tar.gz: d41f77188f4fb422e216d0d808ab817d7a3ec915ca12376f62cdbecb39384e5256b100b4135869cb8e3e3dc4b4aeb2d52eee1ef24369fcf7a3466be130587df5
|
@@ -20,7 +20,7 @@ module LearnTest
|
|
20
20
|
|
21
21
|
current_branch = @base.current_branch
|
22
22
|
|
23
|
-
raise NoCommitsError, 'master' if current_branch.nil? # TODO: Swap to `main`?
|
23
|
+
raise Errors::NoCommitsError, 'master' if current_branch.nil? # TODO: Swap to `main`?
|
24
24
|
|
25
25
|
@tmp = Tempfile.new(TEMPFILE)
|
26
26
|
@working_branch = Branch.new(base: @base, name: current_branch)
|
@@ -16,10 +16,10 @@ module LearnTest
|
|
16
16
|
begin
|
17
17
|
@base.revparse(@name)
|
18
18
|
rescue ::Git::GitExecuteError => e
|
19
|
-
regex =
|
19
|
+
regex = Errors::NoCommitsError::REGEX
|
20
20
|
|
21
21
|
if raise_no_commits
|
22
|
-
raise e.message.match(regex) ?
|
22
|
+
raise e.message.match(regex) ? Errors::NoCommitsError.new(@name) : e
|
23
23
|
end
|
24
24
|
|
25
25
|
raise unless e.message.match(regex)
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module LearnTest
|
4
|
+
module Git
|
5
|
+
module Wip
|
6
|
+
module Errors
|
7
|
+
class NoCommitsError < BaseError
|
8
|
+
REGEX = /unknown revision or path not in the working tree/i.freeze
|
9
|
+
|
10
|
+
def initialize(branch)
|
11
|
+
super "Branch `#{branch}` doesn't have any commits. Please commit and try again."
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'fileutils'
|
4
|
+
|
3
5
|
module LearnTest
|
4
6
|
module Git
|
5
7
|
module Wip
|
@@ -10,7 +12,11 @@ module LearnTest
|
|
10
12
|
|
11
13
|
def initialize(base:, name:)
|
12
14
|
dir = File.join(base.repo.path, PREFIX)
|
13
|
-
|
15
|
+
file = File.join(dir, name)
|
16
|
+
sha = base.log(1)[0].sha
|
17
|
+
|
18
|
+
FileUtils.mkdir_p(dir, { mode: 0755 }) unless Dir.exist?(dir)
|
19
|
+
File.open(file, 'w+') { |f| f.puts sha } unless File.exist?(file)
|
14
20
|
|
15
21
|
super(base: base, name: "#{PREFIX}#{name}")
|
16
22
|
end
|
data/lib/learn_test/version.rb
CHANGED
@@ -43,7 +43,11 @@ describe LearnTest::Git::Wip::Base do
|
|
43
43
|
before(:each) { initialize_repo }
|
44
44
|
|
45
45
|
it 'should create refs/wip' do
|
46
|
-
expect(
|
46
|
+
expect(FileUtils)
|
47
|
+
.to receive(:mkdir_p)
|
48
|
+
.with("#{path}/.git/refs/wip/", { mode: 0755 })
|
49
|
+
.and_call_original
|
50
|
+
|
47
51
|
instance.process!
|
48
52
|
end
|
49
53
|
end
|
@@ -52,7 +56,7 @@ describe LearnTest::Git::Wip::Base do
|
|
52
56
|
before(:each) { initialize_repo(commit: false) }
|
53
57
|
|
54
58
|
it 'should raise' do
|
55
|
-
expect { instance.process! }.to raise_error(LearnTest::Git::Wip::NoCommitsError)
|
59
|
+
expect { instance.process! }.to raise_error(LearnTest::Git::Wip::Errors::NoCommitsError)
|
56
60
|
end
|
57
61
|
end
|
58
62
|
|
@@ -91,7 +91,7 @@ describe LearnTest::Git::Wip::Branch do
|
|
91
91
|
expect do
|
92
92
|
branch.last_revision(raise_no_commits: true)
|
93
93
|
end.to raise_error(
|
94
|
-
LearnTest::Git::Wip::NoCommitsError, "Branch `#{name}` doesn't have any commits. Please commit and try again."
|
94
|
+
LearnTest::Git::Wip::Errors::NoCommitsError, "Branch `#{name}` doesn't have any commits. Please commit and try again."
|
95
95
|
)
|
96
96
|
end
|
97
97
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe LearnTest::Git::Wip::Errors::NoChangesError do
|
4
|
+
let(:branch) { rand(0..999_999).to_s }
|
5
|
+
|
6
|
+
it 'should inherit from Error' do
|
7
|
+
expect(described_class).to be < LearnTest::Git::Wip::Errors::BaseError
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should require a branch' do
|
11
|
+
expect { described_class.new }.to raise_error(ArgumentError)
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should have the correct messaging' do
|
15
|
+
error = described_class.new(branch)
|
16
|
+
expect(error.message).to eq "No changes found on `#{branch}`"
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe LearnTest::Git::Wip::Errors::NoCommitsError do
|
4
|
+
let(:branch) { rand(0..999_999).to_s }
|
5
|
+
|
6
|
+
it 'should inherit from Error' do
|
7
|
+
expect(described_class).to be < LearnTest::Git::Wip::Errors::BaseError
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should require a branch' do
|
11
|
+
expect { described_class.new }.to raise_error(ArgumentError)
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should have the correct messaging' do
|
15
|
+
error = described_class.new(branch)
|
16
|
+
expect(error.message).to eq "Branch `#{branch}` doesn't have any commits. Please commit and try again."
|
17
|
+
end
|
18
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -12,6 +12,8 @@ support_dir = File.join('./', 'spec', 'support', '**', '*.rb')
|
|
12
12
|
Dir.glob(support_dir).each { |f| require f }
|
13
13
|
|
14
14
|
RSpec.configure do |config|
|
15
|
+
config.filter_run focus: true
|
16
|
+
|
15
17
|
config.expect_with :rspec do |expectations|
|
16
18
|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
17
19
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: learn-test
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.3.0.pre.
|
4
|
+
version: 3.3.0.pre.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Flatiron School
|
@@ -184,7 +184,9 @@ files:
|
|
184
184
|
- lib/learn_test/git.rb
|
185
185
|
- lib/learn_test/git/wip/base.rb
|
186
186
|
- lib/learn_test/git/wip/branch.rb
|
187
|
-
- lib/learn_test/git/wip/
|
187
|
+
- lib/learn_test/git/wip/errors/base_error.rb
|
188
|
+
- lib/learn_test/git/wip/errors/no_changes_error.rb
|
189
|
+
- lib/learn_test/git/wip/errors/no_commits_error.rb
|
188
190
|
- lib/learn_test/git/wip/reference.rb
|
189
191
|
- lib/learn_test/github_interactor.rb
|
190
192
|
- lib/learn_test/js_strategy.rb
|
@@ -221,7 +223,9 @@ files:
|
|
221
223
|
- spec/fixtures/rspec-unit-spec/spec/spec_helper.rb
|
222
224
|
- spec/learn_test/git/wip/base_spec.rb
|
223
225
|
- spec/learn_test/git/wip/branch_spec.rb
|
224
|
-
- spec/learn_test/git/wip/
|
226
|
+
- spec/learn_test/git/wip/errors/base_error_spec.rb
|
227
|
+
- spec/learn_test/git/wip/errors/no_changes_error_spec.rb
|
228
|
+
- spec/learn_test/git/wip/errors/no_commits_error_spec.rb
|
225
229
|
- spec/learn_test/git_spec.rb
|
226
230
|
- spec/learn_test/reporter_spec.rb
|
227
231
|
- spec/learn_test/username_parser_spec.rb
|
@@ -265,7 +269,9 @@ test_files:
|
|
265
269
|
- spec/fixtures/rspec-unit-spec/spec/spec_helper.rb
|
266
270
|
- spec/learn_test/git/wip/base_spec.rb
|
267
271
|
- spec/learn_test/git/wip/branch_spec.rb
|
268
|
-
- spec/learn_test/git/wip/
|
272
|
+
- spec/learn_test/git/wip/errors/base_error_spec.rb
|
273
|
+
- spec/learn_test/git/wip/errors/no_changes_error_spec.rb
|
274
|
+
- spec/learn_test/git/wip/errors/no_commits_error_spec.rb
|
269
275
|
- spec/learn_test/git_spec.rb
|
270
276
|
- spec/learn_test/reporter_spec.rb
|
271
277
|
- spec/learn_test/username_parser_spec.rb
|
@@ -1,23 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module LearnTest
|
4
|
-
module Git
|
5
|
-
module Wip
|
6
|
-
class Error < StandardError; end
|
7
|
-
|
8
|
-
class NoChangesError < Error
|
9
|
-
def initialize(branch)
|
10
|
-
super "No changes found on `#{branch}`"
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
class NoCommitsError < Error
|
15
|
-
REGEX = /unknown revision or path not in the working tree/i.freeze
|
16
|
-
|
17
|
-
def initialize(branch)
|
18
|
-
super "Branch `#{branch}` doesn't have any commits. Please commit and try again."
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe LearnTest::Git::Wip do
|
4
|
-
let(:branch) { rand(0..999_999).to_s }
|
5
|
-
|
6
|
-
describe LearnTest::Git::Wip::Error do
|
7
|
-
it 'should inherit from StandardError' do
|
8
|
-
expect(described_class).to be < StandardError
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
describe LearnTest::Git::Wip::NoChangesError do
|
13
|
-
it 'should inherit from Error' do
|
14
|
-
expect(described_class).to be < LearnTest::Git::Wip::Error
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'should require a branch' do
|
18
|
-
expect { described_class.new }.to raise_error(ArgumentError)
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'should have the correct messaging' do
|
22
|
-
error = described_class.new(branch)
|
23
|
-
expect(error.message).to eq "No changes found on `#{branch}`"
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe LearnTest::Git::Wip::NoCommitsError do
|
28
|
-
it 'should inherit from Error' do
|
29
|
-
expect(described_class).to be < LearnTest::Git::Wip::Error
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'should require a branch' do
|
33
|
-
expect { described_class.new }.to raise_error(ArgumentError)
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'should have the correct messaging' do
|
37
|
-
error = described_class.new(branch)
|
38
|
-
expect(error.message).to eq "Branch `#{branch}` doesn't have any commits. Please commit and try again."
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|