learn-test 3.2.1.pre.6 → 3.2.4

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: 8794c9f5f79754792e07d3d25d4394cb893f1156c2f90ddf49fa791e3295ed5b
4
- data.tar.gz: 106bb411827dd6cc527f5f2703f1720a7cb5abd4f950fae6f9429da46beef4c9
3
+ metadata.gz: 78b850c796efd54f383ea05c625ad8d5f6038d9dcf865b19fc21fd6dcad435fb
4
+ data.tar.gz: 88336d0c6c787c1680b22453220a1046741f7ffaf06d97ce090b7fd4d02d4f25
5
5
  SHA512:
6
- metadata.gz: b0499f0e0986bc8e1a2e8425bfdf364c701540b8f7e799055b7929868fecec7a5c4812a0df10deaf310f5efff8d22d7caa5e3b046f96b719757d32c81f2269e8
7
- data.tar.gz: 51369aeb558ad730d61618dbcf426c99250d4368c7b3baec7e0d858e39a29cf18d378cabad353bb2ea13164a3adaa60731ca5ec8de1d3ca6b22cfdacb4eca005
6
+ metadata.gz: ed0abed1a972742bdbd28e05ca20218109f3834267ef560bf884b358e237107f6c294ecbda9248d570fe88c8f4014efb7cdc44bd6779b246acc59d639a35e80c
7
+ data.tar.gz: c36adeff838bf630cc640df29e38f7a82de8e65c5aeff5f20a1c107b93d277c4af07ceb2703306d4306a5295237aec822a1f3105bfebfd7a7d64998be5a69700
@@ -30,7 +30,7 @@ Options for save:
30
30
  'commit.gpgSign = true'
31
31
  "
32
32
 
33
- source "$(git --exec-path)/git-sh-setup"
33
+ . "$(git --exec-path)/git-sh-setup"
34
34
 
35
35
  require_work_tree
36
36
 
@@ -26,6 +26,7 @@ require_relative 'learn_test/strategies/java_junit'
26
26
  require_relative 'learn_test/strategies/csharp_nunit'
27
27
  require_relative 'learn_test/strategies/mocha'
28
28
  require_relative 'learn_test/strategies/pytest'
29
+ require_relative 'learn_test/strategies/none'
29
30
 
30
31
  module LearnTest
31
32
  module Dependencies
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'git'
4
+ require 'logger'
4
5
 
5
6
  module LearnTest
6
7
  module GitWip
@@ -9,25 +10,23 @@ module LearnTest
9
10
  git = Git.open('./', log: log)
10
11
  working_branch = git.current_branch
11
12
 
12
- Open3.popen3('learn-test-wip save "Automatic test submission" --editor') do |_stdin, stdout, stderr, wait_thr|
13
- while out = stdout.gets do
14
- puts out
15
- end
16
-
17
- while err = stderr.gets do
18
- puts err
19
- end
13
+ commands = [
14
+ 'learn-test-wip save "Automatic test submission" --editor',
15
+ "git push origin wip/#{working_branch}:refs/heads/wip"
16
+ ].join(';')
17
+
18
+ Open3.popen3(commands) do |_stdin, _stdout, _stderr, wait_thr|
19
+ # while out = stdout.gets do; puts out; end
20
+ # while err = stderr.gets do; puts err; end
20
21
 
21
22
  if wait_thr.value.exitstatus.zero?
22
- git.push('origin', "wip/#{working_branch}:refs/heads/wip")
23
23
  git.config['remote.origin.url'].gsub('.git', '/tree/wip')
24
24
  else
25
- puts 'There was an error running learn-test-wip'
25
+ # puts 'There was an error running learn-test-wip'
26
26
  false
27
27
  end
28
28
  end
29
29
  rescue StandardError => e
30
- puts e
31
30
  false
32
31
  end
33
32
  end
@@ -9,7 +9,6 @@ module LearnTest
9
9
  def initialize(repo, options = {})
10
10
  @repo = repo
11
11
  @options = options
12
- die unless strategy
13
12
  end
14
13
 
15
14
  def run
@@ -34,7 +33,11 @@ module LearnTest
34
33
  end
35
34
 
36
35
  def strategy
37
- @strategy ||= strategies.map { |s| s.new(self) }.detect(&:detect)
36
+ return @strategy if @strategy
37
+
38
+ detected = strategies.map { |s| s.new(self) }.detect(&:detect)
39
+
40
+ @strategy = detected || LearnTest::Strategies::None.new(self)
38
41
  end
39
42
 
40
43
  private
@@ -68,10 +71,5 @@ module LearnTest
68
71
  def local_test_run?
69
72
  options.include?('-h') || options.include?('--local')
70
73
  end
71
-
72
- def die
73
- puts "This directory doesn't appear to have any specs in it."
74
- exit
75
- end
76
74
  end
77
75
  end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LearnTest
4
+ module Strategies
5
+ class None < LearnTest::Strategy
6
+ def service_endpoint
7
+ '/e/flatiron_none'
8
+ end
9
+
10
+ def run
11
+ puts <<~MSG
12
+ This directory doesn't appear to have any specs in it, so there’s no test to run.
13
+
14
+ If you are working on Canvas, this assignment has been submitted. You can resubmit by running `learn test` again.
15
+ MSG
16
+ end
17
+
18
+ def results
19
+ {
20
+ username: username,
21
+ github_user_id: user_id,
22
+ learn_oauth_token: learn_oauth_token,
23
+ repo_name: runner.repo,
24
+ build: {
25
+ test_suite: [{ framework: 'none' }]
26
+ },
27
+ examples: 0,
28
+ passing_count: 0,
29
+ pending_count: 0,
30
+ failure_count: 0,
31
+ failure_descriptions: ''
32
+ }
33
+ end
34
+ end
35
+ end
36
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LearnTest
4
- VERSION = '3.2.1.pre.6'
4
+ VERSION = '3.2.4'
5
5
  end
@@ -7,28 +7,35 @@ describe LearnTest::GitWip do
7
7
  let!(:git_url) { 'https://github.com/learn-co/learn-test' }
8
8
  let!(:git_base) { instance_double(Git::Base) }
9
9
 
10
+ let(:wait_thr) { double }
11
+ let(:wait_thr_value) { double }
12
+ let(:stdout_and_stderr) { double }
13
+
10
14
  context 'success' do
11
15
  it 'should return the git url' do
12
16
  expect(Git::Base).to receive(:open).with('./', { log: false }).and_return(git_base)
13
17
  expect(git_base).to receive(:current_branch).and_return(working_branch)
14
18
 
15
- expect(subject).to receive(:`).with(/learn-test-wip save ".+" -u &> \/dev\/null/ )
16
- expect($?).to receive(:success?).and_return(true)
19
+ expect(wait_thr).to receive(:value).and_return(wait_thr_value)
20
+ expect(wait_thr_value).to receive(:exitstatus).and_return(0)
17
21
 
18
- expect(git_base).to receive(:push).with('origin', "wip/#{working_branch}:refs/heads/wip")
19
- expect(git_base).to receive_message_chain(:config, :[]).with('remote.origin.url').and_return("#{git_url}.git")
22
+ expect(Open3).to receive(:popen3).and_yield(nil, nil, nil, wait_thr)
20
23
 
24
+ expect(git_base).to receive_message_chain(:config, :[]).with('remote.origin.url').and_return("#{git_url}.git")
21
25
  expect(subject.run!).to eq("#{git_url}/tree/wip")
22
26
  end
23
27
  end
24
28
 
25
29
  context 'failure' do
26
30
  it 'should return false on process error' do
27
- allow(Git::Base).to receive(:open).and_return(git_base)
28
- allow(git_base).to receive(:current_branch)
29
- allow(subject).to receive(:`)
31
+ expect(Git::Base).to receive(:open).with('./', { log: false }).and_return(git_base)
32
+ expect(git_base).to receive(:current_branch).and_return(working_branch)
33
+
34
+ expect(wait_thr).to receive(:value).and_return(wait_thr_value)
35
+ expect(wait_thr_value).to receive(:exitstatus).and_return(1)
36
+
37
+ expect(Open3).to receive(:popen3).and_yield(nil, nil, nil, wait_thr)
30
38
 
31
- expect($?).to receive(:success?).and_return(false)
32
39
  expect(subject.run!).to eq(false)
33
40
  end
34
41
 
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe LearnTest::Strategies::None do
4
+ describe '#run' do
5
+ it 'prints a message' do
6
+ strategy = LearnTest::Strategies::None.new(double(:runner, options: {}))
7
+
8
+ msg = <<~MSG
9
+ This directory doesn't appear to have any specs in it, so there’s no test to run.
10
+
11
+ If you are working on Canvas, this assignment has been submitted. You can resubmit by running `learn test` again.
12
+ MSG
13
+
14
+ expect { strategy.run }.to output(msg).to_stdout
15
+ end
16
+ end
17
+
18
+ describe '#results' do
19
+ it 'contains the appropriate attributes' do
20
+ user_id = rand(1000..9999)
21
+ username = "test-username-#{user_id}"
22
+ oauth_token = "test-token-#{user_id}"
23
+ repo = double(:repo)
24
+
25
+ runner = LearnTest::Runner.new(repo, {})
26
+ strategy = LearnTest::Strategies::None.new(runner)
27
+
28
+ expect(LearnTest::UsernameParser).to receive(:get_username)
29
+ .and_return(username)
30
+
31
+ expect(LearnTest::UserIdParser).to receive(:get_user_id)
32
+ .and_return(user_id)
33
+
34
+ expect(LearnTest::LearnOauthTokenParser).to receive(:get_learn_oauth_token)
35
+ .and_return(oauth_token)
36
+
37
+
38
+ expect(strategy.results).to eq(
39
+ username: username,
40
+ github_user_id: user_id,
41
+ learn_oauth_token: oauth_token,
42
+ repo_name: repo,
43
+ build: {
44
+ test_suite: [{ framework: 'none' }]
45
+ },
46
+ examples: 0,
47
+ passing_count: 0,
48
+ pending_count: 0,
49
+ failure_count: 0,
50
+ failure_descriptions: ''
51
+ )
52
+ end
53
+ end
54
+ 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.2.1.pre.6
4
+ version: 3.2.4
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-08-25 00:00:00.000000000 Z
11
+ date: 2020-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -136,7 +136,7 @@ dependencies:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
138
  version: 0.8.1
139
- description:
139
+ description:
140
140
  email:
141
141
  - learn@flatironschool.com
142
142
  executables:
@@ -181,6 +181,7 @@ files:
181
181
  - lib/learn_test/strategies/karma.rb
182
182
  - lib/learn_test/strategies/karma/karma.conf.js
183
183
  - lib/learn_test/strategies/mocha.rb
184
+ - lib/learn_test/strategies/none.rb
184
185
  - lib/learn_test/strategies/protractor.rb
185
186
  - lib/learn_test/strategies/pytest.rb
186
187
  - lib/learn_test/strategies/pytest/requirements_checker.rb
@@ -204,13 +205,14 @@ files:
204
205
  - spec/learn_test/reporter_spec.rb
205
206
  - spec/learn_test/username_parser_spec.rb
206
207
  - spec/lib/learn_test/strategies/mocha_spec.rb
208
+ - spec/lib/learn_test/strategies/none_spec.rb
207
209
  - spec/repo_parser_spec.rb
208
210
  - spec/spec_helper.rb
209
211
  homepage: https://github.com/learn-co/learn-test
210
212
  licenses:
211
213
  - MIT
212
214
  metadata: {}
213
- post_install_message:
215
+ post_install_message:
214
216
  rdoc_options: []
215
217
  require_paths:
216
218
  - lib
@@ -222,12 +224,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
222
224
  version: 2.5.0
223
225
  required_rubygems_version: !ruby/object:Gem::Requirement
224
226
  requirements:
225
- - - ">"
227
+ - - ">="
226
228
  - !ruby/object:Gem::Version
227
- version: 1.3.1
229
+ version: '0'
228
230
  requirements: []
229
- rubygems_version: 3.1.2
230
- signing_key:
231
+ rubygems_version: 3.0.6
232
+ signing_key:
231
233
  specification_version: 4
232
234
  summary: Runs RSpec, Karma, Mocha, and Python Pytest Test builds and pushes JSON output
233
235
  to Learn.
@@ -242,5 +244,6 @@ test_files:
242
244
  - spec/learn_test/reporter_spec.rb
243
245
  - spec/learn_test/username_parser_spec.rb
244
246
  - spec/lib/learn_test/strategies/mocha_spec.rb
247
+ - spec/lib/learn_test/strategies/none_spec.rb
245
248
  - spec/repo_parser_spec.rb
246
249
  - spec/spec_helper.rb