learn-test 2.7.0 → 3.2.0

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.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +1 -12
  3. data/.gitignore +1 -0
  4. data/.rspec +1 -0
  5. data/Gemfile +4 -2
  6. data/README.md +2 -2
  7. data/Rakefile +2 -1
  8. data/bin/learn-test +15 -14
  9. data/bin/learn-test-wip +359 -0
  10. data/learn-test.gemspec +15 -19
  11. data/lib/learn_test.rb +3 -4
  12. data/lib/learn_test/client.rb +2 -0
  13. data/lib/learn_test/dependencies/ant.rb +2 -0
  14. data/lib/learn_test/dependencies/csharp.rb +3 -1
  15. data/lib/learn_test/dependencies/imagemagick.rb +2 -0
  16. data/lib/learn_test/dependencies/java.rb +2 -0
  17. data/lib/learn_test/dependencies/karma.rb +2 -0
  18. data/lib/learn_test/dependencies/nodejs.rb +2 -0
  19. data/lib/learn_test/dependencies/phantomjs.rb +6 -4
  20. data/lib/learn_test/dependencies/protractor.rb +2 -0
  21. data/lib/learn_test/dependencies/selenium_server.rb +2 -0
  22. data/lib/learn_test/dependency.rb +4 -4
  23. data/lib/learn_test/file_finder.rb +2 -1
  24. data/lib/learn_test/git_wip.rb +23 -0
  25. data/lib/learn_test/github_interactor.rb +2 -1
  26. data/lib/learn_test/js_strategy.rb +3 -1
  27. data/lib/learn_test/learn_oauth_token_parser.rb +2 -0
  28. data/lib/learn_test/netrc_interactor.rb +2 -1
  29. data/lib/learn_test/repo_parser.rb +2 -0
  30. data/lib/learn_test/reporter.rb +14 -7
  31. data/lib/learn_test/runner.rb +5 -5
  32. data/lib/learn_test/strategies/csharp_nunit.rb +5 -3
  33. data/lib/learn_test/strategies/java_junit.rb +9 -8
  34. data/lib/learn_test/strategies/karma.rb +9 -5
  35. data/lib/learn_test/strategies/mocha.rb +10 -8
  36. data/lib/learn_test/strategies/protractor.rb +7 -6
  37. data/lib/learn_test/strategies/pytest.rb +13 -13
  38. data/lib/learn_test/strategies/pytest/requirements_checker.rb +14 -12
  39. data/lib/learn_test/strategies/rspec.rb +11 -10
  40. data/lib/learn_test/strategy.rb +5 -6
  41. data/lib/learn_test/user_id_parser.rb +2 -1
  42. data/lib/learn_test/username_parser.rb +3 -2
  43. data/lib/learn_test/version.rb +3 -1
  44. data/spec/features/rspec_unit_spec.rb +4 -2
  45. data/spec/fixtures/rspec-unit-spec/lib/dog.rb +3 -1
  46. data/spec/fixtures/rspec-unit-spec/spec/dog_spec.rb +4 -2
  47. data/spec/fixtures/rspec-unit-spec/spec/spec_helper.rb +2 -0
  48. data/spec/learn_test/git_spec.rb +40 -0
  49. data/spec/learn_test/reporter_spec.rb +69 -31
  50. data/spec/learn_test/username_parser_spec.rb +2 -0
  51. data/spec/lib/learn_test/strategies/mocha_spec.rb +21 -20
  52. data/spec/repo_parser_spec.rb +14 -12
  53. data/spec/spec_helper.rb +2 -0
  54. metadata +18 -147
  55. data/Gemfile.lock +0 -83
  56. data/lib/learn_test/dependencies/firefox.rb +0 -26
  57. data/lib/learn_test/dependencies/green_onion.rb +0 -14
  58. data/lib/learn_test/strategies/green_onion.rb +0 -57
  59. data/lib/learn_test/strategies/jasmine.rb +0 -181
  60. data/lib/learn_test/strategies/jasmine/boot.js +0 -184
  61. data/lib/learn_test/strategies/jasmine/console.js +0 -161
  62. data/lib/learn_test/strategies/jasmine/formatters/jasmine2-junit.js +0 -199
  63. data/lib/learn_test/strategies/jasmine/helpers/ConsoleHelper.js +0 -12
  64. data/lib/learn_test/strategies/jasmine/helpers/ConsoleHelperNoColor.js +0 -12
  65. data/lib/learn_test/strategies/jasmine/initializer.rb +0 -27
  66. data/lib/learn_test/strategies/jasmine/jasmine-html.js +0 -360
  67. data/lib/learn_test/strategies/jasmine/jasmine-jquery.js +0 -813
  68. data/lib/learn_test/strategies/jasmine/jasmine.css +0 -56
  69. data/lib/learn_test/strategies/jasmine/jasmine.js +0 -2403
  70. data/lib/learn_test/strategies/jasmine/jasmine_favicon.png +0 -0
  71. data/lib/learn_test/strategies/jasmine/jquery-1.8.0.min.js +0 -2
  72. data/lib/learn_test/strategies/jasmine/jquery-ui-1.8.23.custom.min.js +0 -125
  73. data/lib/learn_test/strategies/jasmine/runners/SpecRunner.html +0 -35
  74. data/lib/learn_test/strategies/jasmine/runners/run-jasmine.js +0 -229
  75. data/lib/learn_test/strategies/jasmine/templates/SpecRunnerTemplate.html.erb +0 -35
  76. data/lib/learn_test/strategies/jasmine/templates/SpecRunnerTemplateNoColor.html.erb +0 -35
  77. data/lib/learn_test/strategies/jasmine/templates/requires.yml.example +0 -7
  78. data/lib/learn_test/strategies/jasmine/vendor/require.js +0 -2077
  79. data/spec/features/jasmine_jquery_fixtures_spec.rb +0 -10
  80. data/spec/fixtures/jasmine-jquery-fixtures/index.html +0 -10
  81. data/spec/fixtures/jasmine-jquery-fixtures/requires.yml +0 -4
  82. data/spec/fixtures/jasmine-jquery-fixtures/spec/jasmine-jquery-fixtures-spec.js +0 -11
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module LearnTest
2
4
  module Strategies
3
5
  class Karma < LearnTest::Strategy
@@ -16,11 +18,13 @@ module LearnTest
16
18
 
17
19
  def run
18
20
  run_karma
19
- if @missing_karma
20
- puts "Installing local karma dependencies...".green
21
- run_install('npm install')
22
- run_karma
23
- end
21
+
22
+ return unless @missing_karma
23
+
24
+ puts 'Installing local karma dependencies...'.green
25
+ run_install('npm install')
26
+
27
+ run_karma
24
28
  end
25
29
 
26
30
  def output
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module LearnTest
2
4
  module Strategies
3
5
  class Mocha < LearnTest::Strategy
@@ -8,7 +10,7 @@ module LearnTest
8
10
  end
9
11
 
10
12
  def detect
11
- return false if !js_package
13
+ return false unless js_package
12
14
 
13
15
  (has_js_dependency?(:mocha) || in_browser?) ? true : false
14
16
  end
@@ -58,18 +60,18 @@ module LearnTest
58
60
  npm_install
59
61
 
60
62
  if in_browser?
61
- exec("npm test")
63
+ exec('npm test')
62
64
  else
63
65
  run_node_based_mocha
64
66
  end
65
67
  end
66
68
 
67
69
  def run_node_based_mocha
68
- command = if (js_package[:scripts] && js_package[:scripts][:test] || "").include?(".results.json")
69
- "npm test"
70
+ command = if (js_package[:scripts] && js_package[:scripts][:test] || '').include?('.results.json')
71
+ 'npm test'
70
72
  else
71
73
  install_mocha_multi
72
- "node_modules/.bin/mocha -R mocha-multi --reporter-options spec=-,json=.results.json"
74
+ 'node_modules/.bin/mocha -R mocha-multi --reporter-options spec=-,json=.results.json'
73
75
  end
74
76
 
75
77
  system(command)
@@ -84,9 +86,9 @@ module LearnTest
84
86
  end
85
87
 
86
88
  def install_mocha_multi
87
- if !File.exist?('node_modules/mocha-multi')
88
- run_install('npm install mocha-multi', npm_install: true)
89
- end
89
+ return if File.exist?('node_modules/mocha-multi')
90
+
91
+ run_install('npm install mocha-multi', npm_install: true)
90
92
  end
91
93
  end
92
94
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'open3'
2
4
 
3
5
  module LearnTest
@@ -17,7 +19,7 @@ module LearnTest
17
19
  end
18
20
 
19
21
  def run
20
- if !selenium_running?
22
+ unless selenium_running?
21
23
  stdin, stdout, stderr, wait_thr = Open3.popen3('webdriver-manager start')
22
24
  @pid = wait_thr.pid
23
25
 
@@ -88,14 +90,14 @@ module LearnTest
88
90
 
89
91
  def passing_count
90
92
  @passing_count ||= output.inject(0) do |count, test|
91
- count += 1 if test[:assertions].all?{ |a| a[:passed] }
93
+ count += 1 if test[:assertions].all? { |a| a[:passed] }
92
94
  count
93
95
  end
94
96
  end
95
97
 
96
98
  def failure_count
97
99
  @failure_count ||= output.inject(0) do |count, test|
98
- count += 1 if !test[:assertions].all? { |a| a[:passed] }
100
+ count += 1 unless test[:assertions].all? { |a| a[:passed] }
99
101
  count
100
102
  end
101
103
  end
@@ -114,14 +116,13 @@ module LearnTest
114
116
  end
115
117
 
116
118
  def selenium_running?
117
- process = `ps aux | grep selenium`.split("\n").detect{ |p| p.include?('chromedriver') }
119
+ process = `ps aux | grep selenium`.split("\n").detect { |p| p.include?('chromedriver') }
118
120
  if process
119
121
  @selenium_pid = process.split[1].to_i
120
122
  return true
121
123
  end
122
- return false
124
+ false
123
125
  end
124
-
125
126
  end
126
127
  end
127
128
  end
@@ -1,10 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'crack'
2
4
  require_relative 'pytest/requirements_checker'
3
5
 
4
6
  module LearnTest
5
7
  module Strategies
6
8
  class Pytest < LearnTest::Strategy
7
-
8
9
  def service_endpoint
9
10
  '/e/flatiron_pytest'
10
11
  end
@@ -22,18 +23,18 @@ module LearnTest
22
23
  end
23
24
 
24
25
  def output
25
- @output ||= Crack::XML.parse(File.read('.results.xml'))["testsuite"]
26
+ @output ||= Crack::XML.parse(File.read('.results.xml'))['testsuite']
26
27
  end
27
28
 
28
29
  def test_files
29
30
  # pytest will run all files of the form test_*.py or *_test.py
30
- @test_files ||= Dir.glob("**/test_*.py") + Dir.glob("**/*_test.py")
31
+ @test_files ||= Dir.glob('**/test_*.py') + Dir.glob('**/*_test.py')
31
32
  end
32
33
 
33
34
  def results
34
- failed_count = output["failures"].to_i + output["errors"].to_i
35
- skipped_count = output["skips"].to_i
36
- passed_count = output["tests"].to_i - failed_count - skipped_count
35
+ failed_count = output['failures'].to_i + output['errors'].to_i
36
+ skipped_count = output['skips'].to_i
37
+ passed_count = output['tests'].to_i - failed_count - skipped_count
37
38
  {
38
39
  username: username,
39
40
  github_user_id: user_id,
@@ -43,10 +44,10 @@ module LearnTest
43
44
  test_suite: [{
44
45
  framework: 'pytest',
45
46
  formatted_output: output.to_json,
46
- duration: output["time"]
47
+ duration: output['time']
47
48
  }]
48
49
  },
49
- examples: output["tests"].to_i,
50
+ examples: output['tests'].to_i,
50
51
  passing_count: passed_count,
51
52
  pending_count: skipped_count,
52
53
  failure_count: failed_count,
@@ -70,16 +71,15 @@ module LearnTest
70
71
  # if there is a single test the `testcase` xml parse turns out a hash
71
72
  # instead of an array with a single hash. this will make sure single
72
73
  # tests have the same output structure (Array) as multiple tests
73
- output["testcase"] = [output["testcase"]].flatten
74
+ output['testcase'] = [output['testcase']].flatten
74
75
 
75
- output["testcase"].reduce([]) do |errors, example|
76
- if example.has_key?("failure")
77
- errors << example.map{|k, v| "#{k}: #{v}"}
76
+ output['testcase'].reduce([]) do |errors, example|
77
+ if example.has_key?('failure')
78
+ errors << example.map { |k, v| "#{k}: #{v}" }
78
79
  end
79
80
  errors
80
81
  end
81
82
  end
82
-
83
83
  end
84
84
  end
85
85
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'open3'
2
4
 
3
5
  module LearnTest
@@ -12,10 +14,10 @@ module LearnTest
12
14
 
13
15
  class PythonChecker
14
16
  def self.check
15
- if !self.python_installed? || !self.correct_python_version?
16
- puts "Please install python 2.7.x or 3.x.x"
17
- exit
18
- end
17
+ return unless !self.python_installed? || !self.correct_python_version?
18
+
19
+ puts 'Please install python 2.7.x or 3.x.x'
20
+ exit
19
21
  end
20
22
 
21
23
  def self.python_installed?
@@ -31,10 +33,10 @@ module LearnTest
31
33
 
32
34
  class PipChecker
33
35
  def self.check
34
- if !self.pip_installed?
35
- puts "Please ensure pip is installed"
36
- exit
37
- end
36
+ return if self.pip_installed?
37
+
38
+ puts 'Please ensure pip is installed'
39
+ exit
38
40
  end
39
41
 
40
42
  def self.pip_installed?
@@ -44,10 +46,10 @@ module LearnTest
44
46
 
45
47
  class PytestChecker
46
48
  def self.check
47
- if !self.pytest_installed?
48
- puts "Please ensure pytest is installed"
49
- exit
50
- end
49
+ return if self.pytest_installed?
50
+
51
+ puts 'Please ensure pytest is installed'
52
+ exit
51
53
  end
52
54
 
53
55
  def self.pytest_installed?
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module LearnTest
2
4
  module Strategies
3
5
  class Rspec < LearnTest::Strategy
@@ -11,8 +13,8 @@ module LearnTest
11
13
 
12
14
  def configure
13
15
  if format_option_present?
14
- if dot_rspec.any? {|dot_opt| dot_opt.match(/--format|-f/)}
15
- argv << dot_rspec.reject {|dot_opt| dot_opt.match(/--format|-f/)}
16
+ if dot_rspec.any? { |dot_opt| dot_opt.match(/--format|-f/) }
17
+ argv << dot_rspec.reject { |dot_opt| dot_opt.match(/--format|-f/) }
16
18
  else
17
19
  argv << dot_rspec
18
20
  end
@@ -26,14 +28,14 @@ module LearnTest
26
28
  end
27
29
 
28
30
  if example_option_present?
29
- argv << options[:example].map{|e| "--example #{e}"}.join(" ")
31
+ argv << options[:example].map { |e| "--example #{e}" }.join(' ')
30
32
  end
31
33
 
32
34
  # Don't pass the test/local flag from learn binary to rspec runner.
33
- argv.delete("--test")
34
- argv.delete("-t")
35
- argv.delete("-l")
36
- argv.delete("--local")
35
+ argv.delete('--test')
36
+ argv.delete('-t')
37
+ argv.delete('-l')
38
+ argv.delete('--local')
37
39
  end
38
40
 
39
41
  def run
@@ -98,13 +100,12 @@ module LearnTest
98
100
  def failures
99
101
  if output
100
102
  output[:examples].select do |example|
101
- example[:status] == "failed"
102
- end.map { |ex| ex[:full_description] }.join(";")
103
+ example[:status] == 'failed'
104
+ end.map { |ex| ex[:full_description] }.join(';')
103
105
  else
104
106
  'A syntax error prevented RSpec from running.'
105
107
  end
106
108
  end
107
-
108
109
  end
109
110
  end
110
111
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module LearnTest
2
4
  class Strategy
3
5
  attr_reader :runner, :options
@@ -11,11 +13,9 @@ module LearnTest
11
13
  raise NotImplementedError, 'you must add the service endpoint to the test strategy'
12
14
  end
13
15
 
14
- def check_dependencies
15
- end
16
+ def check_dependencies; end
16
17
 
17
- def configure
18
- end
18
+ def configure; end
19
19
 
20
20
  def run
21
21
  raise NotImplementedError, 'you must implement how this strategy runs its tests'
@@ -33,8 +33,7 @@ module LearnTest
33
33
  true
34
34
  end
35
35
 
36
- def cleanup
37
- end
36
+ def cleanup; end
38
37
 
39
38
  def username
40
39
  @username ||= LearnTest::UsernameParser.get_username
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module LearnTest
2
4
  class UserIdParser
3
5
  def self.get_user_id
@@ -6,4 +8,3 @@ module LearnTest
6
8
  end
7
9
  end
8
10
  end
9
-
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module LearnTest
2
4
  class UsernameParser
3
5
  def self.get_username
@@ -6,7 +8,7 @@ module LearnTest
6
8
  user_id = parser.user_id
7
9
 
8
10
  if !LearnTest::LearnOauthTokenParser.get_learn_oauth_token && (!username || user_id == 'none')
9
- print "Enter your github username: "
11
+ print 'Enter your github username: '
10
12
  username = $stdin.gets.strip
11
13
  user_id = LearnTest::GithubInteractor.get_user_id_for(username)
12
14
  parser.write(username, user_id)
@@ -16,4 +18,3 @@ module LearnTest
16
18
  end
17
19
  end
18
20
  end
19
-
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module LearnTest
2
- VERSION = '2.7.0'
4
+ VERSION = '3.2.0'
3
5
  end
@@ -1,4 +1,6 @@
1
- describe "Running a RSpec Unit Test" do
1
+ # frozen_string_literal: true
2
+
3
+ describe 'Running a RSpec Unit Test' do
2
4
  before(:all) do
3
5
  # While it doesn't cause these tests to fail, nasty messages occur (and more)
4
6
  # when either a ~/.netrc entry or file itself doesn't exist. This aims to correct that,
@@ -30,6 +32,6 @@ describe "Running a RSpec Unit Test" do
30
32
  expect(output).to include('2 examples, 0 failures')
31
33
  expect(output).to_not include('3 examples')
32
34
  expect(output).to_not include('1 example')
33
- end
35
+ end
34
36
  end
35
37
  end
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Dog
2
- end
4
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative '../lib/dog'
2
4
 
3
5
  describe Dog do
@@ -11,5 +13,5 @@ describe Dog do
11
13
 
12
14
  it 'accepts more than one example' do
13
15
  expect(subject).not_to be_an_instance_of(String)
14
- end
15
- end
16
+ end
17
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file was generated by the `rspec --init` command. Conventionally, all
2
4
  # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
5
  # The generated `.rspec` file contains `--require spec_helper` which will cause
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe LearnTest::GitWip do
4
+ subject { described_class }
5
+
6
+ let!(:working_branch) { 'develop' }
7
+ let!(:git_url) { 'https://github.com/learn-co/learn-test' }
8
+ let!(:git_base) { instance_double(Git::Base) }
9
+
10
+ context 'success' do
11
+ it 'should return the git url' do
12
+ expect(Git::Base).to receive(:open).with('./', { log: false }).and_return(git_base)
13
+ expect(git_base).to receive(:current_branch).and_return(working_branch)
14
+
15
+ expect(subject).to receive(:`).with(/learn-test-wip save ".+" -u &> \/dev\/null/ )
16
+ expect($?).to receive(:success?).and_return(true)
17
+
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")
20
+
21
+ expect(subject.run!).to eq("#{git_url}/tree/wip")
22
+ end
23
+ end
24
+
25
+ context 'failure' do
26
+ 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(:`)
30
+
31
+ expect($?).to receive(:success?).and_return(false)
32
+ expect(subject.run!).to eq(false)
33
+ end
34
+
35
+ it 'should return false on StandardError' do
36
+ expect(Git::Base).to receive(:open).and_raise(StandardError)
37
+ expect(subject.run!).to eq(false)
38
+ end
39
+ end
40
+ end