learn-test 3.3.0.pre.1 → 3.3.0.pre.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8068b9ca6cd44a8bea55fbe7aff5ec5ee08f811e171021726a6e6364c250a210
4
- data.tar.gz: 2e6ab893c0f4492cae089cb0c08f836a56486c5d3d3a1140cdf7b4172dc6fbff
3
+ metadata.gz: 7906a9d22e49996f18bf0b8c0cd1c7d76f5ef27447ee235b09403c58b6132340
4
+ data.tar.gz: 98f97cbd9e8d2b0bd643ff95e9e6f5ec11988a74a4e1a17819d303cbb2b9bba8
5
5
  SHA512:
6
- metadata.gz: e409f578b4721d75066dc5430d7c725ca47df693487b1cda69149ba4db5d3ca0e7ae33e61e57150ec43c2aaeb1c3e03e5b66ee1d0ddbf281b3c26b8f423aa087
7
- data.tar.gz: 4a05f33e6601662c068f6d10fb9d225c68f0d60b1edb90dcf195271f4594c426bcf80e99fb987fc49cc69d7f8e723be2fc16f16d4b467f10cd0af103dd043260
6
+ metadata.gz: 6ded3c645f8ae0ef2f7a2ab4cf39819b42f6c82a5a93e7876ad2ab625199d033a311fbbff03adf736a6ac64cbb655ae03eb35147abeca20ee13a59efe6979453
7
+ data.tar.gz: d41f77188f4fb422e216d0d808ab817d7a3ec915ca12376f62cdbecb39384e5256b100b4135869cb8e3e3dc4b4aeb2d52eee1ef24369fcf7a3466be130587df5
@@ -8,7 +8,9 @@ require 'zeitwerk'
8
8
  loader = Zeitwerk::Loader.for_gem
9
9
  loader.inflector.inflect(
10
10
  'csharp' => 'CSharp',
11
- 'csharp_nunit' => 'CSharpNunit'
11
+ 'csharp_nunit' => 'CSharpNunit',
12
+ 'nodejs' => 'NodeJS',
13
+ 'phantomjs' => 'PhantomJS'
12
14
  )
13
15
  loader.setup
14
16
 
@@ -10,7 +10,6 @@ module LearnTest
10
10
  module Wip
11
11
  class Base < ::Git::Path
12
12
  TEMPFILE = '.wip'
13
- PREFIX = 'refs/wip/'
14
13
 
15
14
  attr_reader :working_branch, :wip_branch
16
15
 
@@ -21,11 +20,11 @@ module LearnTest
21
20
 
22
21
  current_branch = @base.current_branch
23
22
 
24
- raise NoCommitsError, 'master' if current_branch.nil? # TODO: Swap to `main`?
23
+ raise Errors::NoCommitsError, 'master' if current_branch.nil? # TODO: Swap to `main`?
25
24
 
26
25
  @tmp = Tempfile.new(TEMPFILE)
27
26
  @working_branch = Branch.new(base: @base, name: current_branch)
28
- @wip_branch = Branch.new(base: @base, name: "#{PREFIX}#{current_branch}")
27
+ @wip_branch = Reference.new(base: @base, name: current_branch)
29
28
  end
30
29
 
31
30
  def process!
@@ -44,9 +43,6 @@ module LearnTest
44
43
  new_tree = build_new_tree(@wip_branch.parent)
45
44
  @base.diff(new_tree, @wip_branch.parent)
46
45
 
47
- # tree_diff = @base.diff(new_tree, @wip_branch.parent)
48
- # raise NoChangesError, @wip_branch if tree_diff.count.zero?
49
-
50
46
  commit = @base.commit_tree(new_tree, parent: @wip_branch.parent)
51
47
 
52
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(NoCommitsError::REGEX) ? 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(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
@@ -68,7 +68,7 @@ module LearnTest
68
68
  repo.push('origin', "#{res.wip_branch}:refs/heads/fis-wip", { force: true })
69
69
  rescue ::Git::GitExecuteError => e
70
70
  if @debug
71
- puts 'There was a problem connecting to Github. Not pushing current branch state.'.red
71
+ puts 'There was a problem connecting to GitHub. Not pushing current branch state.'.red
72
72
  puts e.message
73
73
  end
74
74
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LearnTest
4
- VERSION = '3.3.0.pre.1'
4
+ VERSION = '3.3.0.pre.6'
5
5
  end
@@ -12,9 +12,10 @@ describe 'Running a RSpec Unit Test', type: :aruba do
12
12
  before :each do
13
13
  copy '%/rspec-unit-spec', 'example'
14
14
  cd 'example'
15
- run_command_and_stop 'git init'
16
- run_command_and_stop 'git add .'
17
- run_command_and_stop 'git commit -m "Initial Commit"'
15
+
16
+ git_init
17
+ git_add
18
+ git_commit 'Initial Commit'
18
19
  end
19
20
 
20
21
  def run(flags = '')
@@ -31,27 +31,32 @@ describe LearnTest::Git::Wip::Base do
31
31
  create_directory 'example'
32
32
  cd 'example'
33
33
  write_file 'README.md', 'Hello World'
34
- run_command_and_stop 'git init'
34
+ git_init
35
35
 
36
36
  if commit # rubocop:disable Style/GuardClause
37
- run_command_and_stop 'git add .'
38
- run_command_and_stop 'git commit -m "Initial Commit"'
37
+ git_add
38
+ git_commit 'Initial Commit'
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
 
@@ -74,8 +79,8 @@ describe LearnTest::Git::Wip::Base do
74
79
  initialize_repo
75
80
  write_file 'test.rb', ''
76
81
 
77
- run_command_and_stop 'git add .'
78
- run_command_and_stop 'git commit -m "foo"'
82
+ git_add
83
+ git_commit 'foo'
79
84
  end
80
85
 
81
86
  it 'should process successfully' do
@@ -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
@@ -96,6 +96,20 @@ describe LearnTest::Reporter do
96
96
  end
97
97
 
98
98
  it 'posts results to the service endpoint' do
99
+ branch = double(LearnTest::Git::Wip::Branch)
100
+ branch_name = 'bar'
101
+
102
+ expect(LearnTest::Git).to receive(:open).and_return(git_base)
103
+ expect(git_base).to receive(:wip).and_return(git_wip)
104
+ expect(git_wip).to receive(:success?).and_return(true)
105
+
106
+ expect(branch).to receive(:to_s).and_return(branch_name)
107
+ expect(git_wip).to receive(:wip_branch).and_return(branch)
108
+
109
+ expect(git_base)
110
+ .to receive(:push)
111
+ .with('origin', "#{branch_name}:refs/heads/fis-wip", { force: true })
112
+
99
113
  reporter.report
100
114
 
101
115
  expect(client).to have_received(:post_results)
@@ -8,7 +8,12 @@ SimpleCov.start
8
8
 
9
9
  require_relative '../lib/learn_test'
10
10
 
11
+ support_dir = File.join('./', 'spec', 'support', '**', '*.rb')
12
+ Dir.glob(support_dir).each { |f| require f }
13
+
11
14
  RSpec.configure do |config|
15
+ config.filter_run focus: true
16
+
12
17
  config.expect_with :rspec do |expectations|
13
18
  expectations.include_chain_clauses_in_custom_matcher_descriptions = true
14
19
  end
@@ -0,0 +1,17 @@
1
+ def git_set_user
2
+ run_command_and_stop 'git config user.email "info@flatironschool.com"'
3
+ run_command_and_stop 'git config user.name "Flatiron School"'
4
+ end
5
+
6
+ def git_init
7
+ run_command_and_stop 'git init'
8
+ git_set_user
9
+ end
10
+
11
+ def git_add(files = '.')
12
+ run_command_and_stop "git add #{files}"
13
+ end
14
+
15
+ def git_commit(msg)
16
+ run_command_and_stop "git commit -m \"#{msg}\""
17
+ 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.1
4
+ version: 3.3.0.pre.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Flatiron School
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-15 00:00:00.000000000 Z
11
+ date: 2020-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -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
@@ -228,6 +233,7 @@ files:
228
233
  - spec/lib/learn_test/strategies/none_spec.rb
229
234
  - spec/repo_parser_spec.rb
230
235
  - spec/spec_helper.rb
236
+ - spec/support/git.rb
231
237
  homepage: https://github.com/learn-co/learn-test
232
238
  licenses:
233
239
  - MIT
@@ -263,7 +269,9 @@ test_files:
263
269
  - spec/fixtures/rspec-unit-spec/spec/spec_helper.rb
264
270
  - spec/learn_test/git/wip/base_spec.rb
265
271
  - spec/learn_test/git/wip/branch_spec.rb
266
- - 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
267
275
  - spec/learn_test/git_spec.rb
268
276
  - spec/learn_test/reporter_spec.rb
269
277
  - spec/learn_test/username_parser_spec.rb
@@ -271,3 +279,4 @@ test_files:
271
279
  - spec/lib/learn_test/strategies/none_spec.rb
272
280
  - spec/repo_parser_spec.rb
273
281
  - spec/spec_helper.rb
282
+ - spec/support/git.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