learn-test 3.3.0.pre.3 → 3.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2a1a864132415df805ab19a42f9a8c5d3892602742fca35cf3a8aff5ae5e7a97
4
- data.tar.gz: 62fcb6feb51b50944d9622fb4306d815125c9338efc1be888775037e853b6d70
3
+ metadata.gz: 159d9e9f72ea50f9b2f88f1bb947933f59ab93eabad5d0b5354aef0315700898
4
+ data.tar.gz: b553b0b3bbdbd257b1227a60ce63aee383187b3f4218eee14193ddac0fbc77d4
5
5
  SHA512:
6
- metadata.gz: 52ab71e5a63eec57aba9391d97255d4aca85e62c9adae8dadb7f02efb0591d6f3d0637a203fca5b1c47fb27cd627c935d837b2e05f55f79f0b7dc1ebbcf025d7
7
- data.tar.gz: 94c627e54f10bbb7ae74f482c4d806ccba4de548b6530843524d950c6a5da3286d5e2e422a70a242daa1e51f66181950c991927e5f0eac38af874195bf176e23
6
+ metadata.gz: 2071fedae3bad80d38ee3ee451aadf17a85dcc2bd4efa50e87a70d28d8cf629e6df27729e1790c82ee9beeeba4b2f2a90b550815b50e22e3bd7770207686e9aa
7
+ data.tar.gz: 5ac388b9d5fcad67fef8957cf937879dbfee791357d60cea982d7cf19431ae0e1f7d36d2a04fa1f0acf516c7451fb47a1aac174e6e14c67d8b9f88948edf2159
@@ -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)
@@ -43,9 +43,6 @@ module LearnTest
43
43
  new_tree = build_new_tree(@wip_branch.parent)
44
44
  @base.diff(new_tree, @wip_branch.parent)
45
45
 
46
- # tree_diff = @base.diff(new_tree, @wip_branch.parent)
47
- # raise LearnTest::Git::Wip::NoChangesError, @wip_branch if tree_diff.count.zero?
48
-
49
46
  commit = @base.commit_tree(new_tree, parent: @wip_branch.parent)
50
47
 
51
48
  @base.lib.send(:command, 'update-ref', ['-m', @message, @wip_branch, commit.objectish])
@@ -16,11 +16,13 @@ module LearnTest
16
16
  begin
17
17
  @base.revparse(@name)
18
18
  rescue ::Git::GitExecuteError => e
19
+ regex = Errors::NoCommitsError::REGEX
20
+
19
21
  if raise_no_commits
20
- raise e.message.match(LearnTest::Git::Wip::NoCommitsError::REGEX) ? LearnTest::Git::Wip::NoCommitsError.new(@name) : e
22
+ raise e.message.match(regex) ? Errors::NoCommitsError.new(@name) : e
21
23
  end
22
24
 
23
- raise unless e.message.match(LearnTest::Git::Wip::NoCommitsError::REGEX)
25
+ raise unless e.message.match(regex)
24
26
 
25
27
  false
26
28
  end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LearnTest
4
+ module Git
5
+ module Wip
6
+ module Errors
7
+ class BaseError < StandardError; end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LearnTest
4
+ module Git
5
+ module Wip
6
+ module Errors
7
+ class NoChangesError < BaseError
8
+ def initialize(branch)
9
+ super "No changes found on `#{branch}`"
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -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
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'fileutils'
4
+
5
+ module LearnTest
6
+ module Git
7
+ module Wip
8
+ class Reference < Branch
9
+ attr_accessor :parent
10
+
11
+ PREFIX = 'refs/wip/'
12
+
13
+ def initialize(base:, name:)
14
+ dir = File.join(base.repo.path, PREFIX)
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)
20
+
21
+ super(base: base, name: "#{PREFIX}#{name}")
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'fileutils'
4
4
  require 'json'
5
+ require 'logger'
5
6
 
6
7
  module LearnTest
7
8
  class Reporter
@@ -54,7 +55,7 @@ module LearnTest
54
55
  return
55
56
  end
56
57
 
57
- logger = @debug ? Logger.new(STDOUT, level: Logger::DEBUG) : false
58
+ logger = @debug ? ::Logger.new($stdout, level: ::Logger::DEBUG) : false
58
59
  repo = LearnTest::Git.open(options: { log: logger })
59
60
 
60
61
  res = repo.wip(message: 'Automatic test submission')
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LearnTest
4
- VERSION = '3.3.0.pre.3'
4
+ VERSION = '3.3.1'
5
5
  end
@@ -39,19 +39,24 @@ describe LearnTest::Git::Wip::Base do
39
39
  end
40
40
  end
41
41
 
42
- context 'no commits' do
43
- before(:each) { initialize_repo(commit: false) }
42
+ context 'no refs/wip' do
43
+ before(:each) { initialize_repo }
44
44
 
45
- it 'should raise' do
46
- expect { instance.process! }.to raise_error(LearnTest::Git::Wip::NoCommitsError)
45
+ it 'should create refs/wip' do
46
+ expect(FileUtils)
47
+ .to receive(:mkdir_p)
48
+ .with("#{path}/.git/refs/wip/", { mode: 0755 })
49
+ .and_call_original
50
+
51
+ instance.process!
47
52
  end
48
53
  end
49
54
 
50
- xcontext 'no changes' do
51
- before(:each) { initialize_repo }
55
+ context 'no commits' do
56
+ before(:each) { initialize_repo(commit: false) }
52
57
 
53
58
  it 'should raise' do
54
- expect { instance.process! }.to raise_error(LearnTest::Git::Wip::NoChangesError)
59
+ expect { instance.process! }.to raise_error(LearnTest::Git::Wip::Errors::NoCommitsError)
55
60
  end
56
61
  end
57
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,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe LearnTest::Git::Wip::Errors::BaseError do
4
+ it 'should inherit from StandardError' do
5
+ expect(described_class).to be < StandardError
6
+ end
7
+ 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
@@ -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,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: learn-test
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.0.pre.3
4
+ version: 3.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Flatiron School
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-16 00:00:00.000000000 Z
11
+ date: 2020-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -150,7 +150,7 @@ dependencies:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
152
  version: 2.4.0
153
- description:
153
+ description:
154
154
  email:
155
155
  - learn@flatironschool.com
156
156
  executables:
@@ -184,7 +184,10 @@ 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/error.rb
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
190
+ - lib/learn_test/git/wip/reference.rb
188
191
  - lib/learn_test/github_interactor.rb
189
192
  - lib/learn_test/js_strategy.rb
190
193
  - lib/learn_test/learn_oauth_token_parser.rb
@@ -220,7 +223,9 @@ files:
220
223
  - spec/fixtures/rspec-unit-spec/spec/spec_helper.rb
221
224
  - spec/learn_test/git/wip/base_spec.rb
222
225
  - spec/learn_test/git/wip/branch_spec.rb
223
- - spec/learn_test/git/wip/error_spec.rb
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
224
229
  - spec/learn_test/git_spec.rb
225
230
  - spec/learn_test/reporter_spec.rb
226
231
  - spec/learn_test/username_parser_spec.rb
@@ -233,7 +238,7 @@ homepage: https://github.com/learn-co/learn-test
233
238
  licenses:
234
239
  - MIT
235
240
  metadata: {}
236
- post_install_message:
241
+ post_install_message:
237
242
  rdoc_options: []
238
243
  require_paths:
239
244
  - lib
@@ -245,12 +250,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
245
250
  version: 2.5.0
246
251
  required_rubygems_version: !ruby/object:Gem::Requirement
247
252
  requirements:
248
- - - ">"
253
+ - - ">="
249
254
  - !ruby/object:Gem::Version
250
- version: 1.3.1
255
+ version: '0'
251
256
  requirements: []
252
- rubygems_version: 3.1.2
253
- signing_key:
257
+ rubygems_version: 3.0.3
258
+ signing_key:
254
259
  specification_version: 4
255
260
  summary: Runs RSpec, Karma, Mocha, and Python Pytest Test builds and pushes JSON output
256
261
  to Learn.
@@ -264,7 +269,9 @@ test_files:
264
269
  - spec/fixtures/rspec-unit-spec/spec/spec_helper.rb
265
270
  - spec/learn_test/git/wip/base_spec.rb
266
271
  - spec/learn_test/git/wip/branch_spec.rb
267
- - spec/learn_test/git/wip/error_spec.rb
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
268
275
  - spec/learn_test/git_spec.rb
269
276
  - spec/learn_test/reporter_spec.rb
270
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