learn-test 2.6.1 → 3.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +48 -0
  3. data/.gitignore +1 -1
  4. data/Gemfile +4 -1
  5. data/README.md +2 -2
  6. data/bin/learn-test +4 -0
  7. data/learn-test.gemspec +8 -12
  8. data/lib/learn_test.rb +0 -4
  9. data/lib/learn_test/repo_parser.rb +2 -3
  10. data/lib/learn_test/runner.rb +0 -2
  11. data/lib/learn_test/strategies/rspec.rb +8 -0
  12. data/lib/learn_test/username_parser.rb +1 -1
  13. data/lib/learn_test/version.rb +1 -1
  14. data/spec/features/rspec_unit_spec.rb +26 -1
  15. data/spec/fixtures/.netrc +3 -0
  16. data/spec/fixtures/rspec-unit-spec/spec/dog_spec.rb +8 -0
  17. data/spec/learn_test/username_parser_spec.rb +61 -0
  18. metadata +23 -138
  19. data/lib/learn_test/dependencies/firefox.rb +0 -26
  20. data/lib/learn_test/dependencies/green_onion.rb +0 -14
  21. data/lib/learn_test/strategies/green_onion.rb +0 -57
  22. data/lib/learn_test/strategies/jasmine.rb +0 -181
  23. data/lib/learn_test/strategies/jasmine/boot.js +0 -184
  24. data/lib/learn_test/strategies/jasmine/console.js +0 -161
  25. data/lib/learn_test/strategies/jasmine/formatters/jasmine2-junit.js +0 -199
  26. data/lib/learn_test/strategies/jasmine/helpers/ConsoleHelper.js +0 -12
  27. data/lib/learn_test/strategies/jasmine/helpers/ConsoleHelperNoColor.js +0 -12
  28. data/lib/learn_test/strategies/jasmine/initializer.rb +0 -27
  29. data/lib/learn_test/strategies/jasmine/jasmine-html.js +0 -360
  30. data/lib/learn_test/strategies/jasmine/jasmine-jquery.js +0 -813
  31. data/lib/learn_test/strategies/jasmine/jasmine.css +0 -56
  32. data/lib/learn_test/strategies/jasmine/jasmine.js +0 -2403
  33. data/lib/learn_test/strategies/jasmine/jasmine_favicon.png +0 -0
  34. data/lib/learn_test/strategies/jasmine/jquery-1.8.0.min.js +0 -2
  35. data/lib/learn_test/strategies/jasmine/jquery-ui-1.8.23.custom.min.js +0 -125
  36. data/lib/learn_test/strategies/jasmine/runners/SpecRunner.html +0 -35
  37. data/lib/learn_test/strategies/jasmine/runners/run-jasmine.js +0 -229
  38. data/lib/learn_test/strategies/jasmine/templates/SpecRunnerTemplate.html.erb +0 -35
  39. data/lib/learn_test/strategies/jasmine/templates/SpecRunnerTemplateNoColor.html.erb +0 -35
  40. data/lib/learn_test/strategies/jasmine/templates/requires.yml.example +0 -7
  41. data/lib/learn_test/strategies/jasmine/vendor/require.js +0 -2077
  42. data/spec/features/jasmine_jquery_fixtures_spec.rb +0 -10
  43. data/spec/fixtures/jasmine-jquery-fixtures/index.html +0 -10
  44. data/spec/fixtures/jasmine-jquery-fixtures/requires.yml +0 -4
  45. data/spec/fixtures/jasmine-jquery-fixtures/spec/jasmine-jquery-fixtures-spec.js +0 -11
@@ -1,26 +0,0 @@
1
- require 'selenium-webdriver'
2
-
3
- module LearnTest
4
- module Dependencies
5
- class Firefox < LearnTest::Dependency
6
- def missing?
7
- begin
8
- Selenium::WebDriver::Firefox::Binary.path
9
-
10
- false
11
- rescue Selenium::WebDriver::Error::WebDriverError
12
- true
13
- end
14
- end
15
-
16
- def install
17
- die('Please download and install Firefox: https://www.mozilla.org/en-US/firefox'.red)
18
- end
19
-
20
- def die(message)
21
- puts message
22
- exit
23
- end
24
- end
25
- end
26
- end
@@ -1,14 +0,0 @@
1
- module LearnTest
2
- module Dependencies
3
- class GreenOnion < LearnTest::Dependency
4
- def missing?
5
- `gem list | grep green_onion`.empty?
6
- end
7
-
8
- def install
9
- print_installing('green_onion')
10
- run_install('gem install green_onion -v 0.1.4')
11
- end
12
- end
13
- end
14
- end
@@ -1,57 +0,0 @@
1
- module LearnTest
2
- module Strategies
3
- class GreenOnion < LearnTest::Strategy
4
- attr_reader :rspec_runner
5
-
6
- def initialize(runner)
7
- @rspec_runner = Strategies::Rspec.new(runner)
8
- super
9
- end
10
-
11
- def service_endpoint
12
- '/e/flatiron_rspec'
13
- end
14
-
15
- def detect
16
- runner.files.include?('.learn') && green_onion_lab?
17
- end
18
-
19
- def configure
20
- rspec_runner.configure
21
- end
22
-
23
- def check_dependencies
24
- Dependencies::Imagemagick.new.execute
25
- Dependencies::SeleniumServer.new.execute
26
- Dependencies::GreenOnion.new.execute
27
- Dependencies::Firefox.new.execute
28
- end
29
-
30
- def run
31
- rspec_runner.run
32
- end
33
-
34
- def output
35
- rspec_runner.output
36
- end
37
-
38
- def results
39
- rspec_runner.results
40
- end
41
-
42
- def cleanup
43
- rspec_runner.cleanup
44
- end
45
-
46
- private
47
-
48
- def green_onion_lab?
49
- yaml['tests'] && yaml['tests'].include?('green_onion')
50
- end
51
-
52
- def yaml
53
- @yaml ||= YAML.load(File.read('.learn'))
54
- end
55
- end
56
- end
57
- end
@@ -1,181 +0,0 @@
1
- require_relative 'jasmine/initializer'
2
-
3
- module LearnTest
4
- module Strategies
5
- class Jasmine < LearnTest::Strategy
6
- def service_endpoint
7
- '/e/flatiron_jasmine'
8
- end
9
-
10
- def detect
11
- runner.files.include?('requires.yml')
12
- end
13
-
14
- def check_dependencies
15
- Dependencies::PhantomJS.new.execute unless options[:skip]
16
- end
17
-
18
- def run
19
- require 'crack'
20
- require 'erb'
21
- require 'yaml'
22
- require 'json'
23
-
24
- if options[:init]
25
- LearnTest::Jasmine::Initializer.run
26
- else
27
- set_up_runner
28
- run_jasmine
29
- make_json
30
- end
31
- end
32
-
33
- def results
34
- @results ||= {
35
- username: username,
36
- github_user_id: user_id,
37
- learn_oauth_token: learn_oauth_token,
38
- repo_name: runner.repo,
39
- build: {
40
- test_suite: [{
41
- framework: 'jasmine',
42
- formatted_output: [],
43
- duration: 0.0
44
- }]
45
- },
46
- tests: 0,
47
- errors: 0,
48
- failures: 0
49
- }
50
- end
51
-
52
- def push_results?
53
- !local? && !browser?
54
- end
55
-
56
- def cleanup
57
- test_xml_files.each do |file|
58
- FileUtils.rm(file)
59
- end
60
-
61
- FileUtils.rm_rf("#{Dir.pwd}/tmpTestSupport") if !browser?
62
- end
63
-
64
- def username
65
- options[:skip] ? "jasmine-flatiron" : super
66
- end
67
-
68
- def user_id
69
- options[:skip] ? "none" : super
70
- end
71
-
72
- def learn_oauth_token
73
- options[:skip] ? nil : super
74
- end
75
-
76
- private
77
-
78
- def set_up_runner
79
- template = ERB.new(File.read("#{LearnTest::FileFinder.location_to_dir('strategies/jasmine/templates')}/SpecRunnerTemplate#{color_option}.html.erb"))
80
-
81
- yaml = YAML.load(File.read('requires.yml'))["javascripts"]
82
-
83
- required_files = yaml["files"]
84
- required_specs = yaml["specs"]
85
-
86
- @javascripts = []
87
- @javascripts << (required_files && required_files.map {|f| "#{test_path}/#{f}"})
88
- @javascripts << (required_specs && required_specs.map {|f| "#{test_path}/#{f}"} )
89
- @javascripts.flatten!.compact!
90
-
91
- copy_support_files
92
-
93
- File.open("#{Dir.pwd}/tmpTestSupport/SpecRunner#{color_option}.html", "w+") do |f|
94
- f << template.result(binding)
95
- end
96
- end
97
-
98
- def copy_support_files
99
- FileUtils.mkdir("#{Dir.pwd}/tmpTestSupport") if !File.exist?("#{Dir.pwd}/tmpTestSupport")
100
-
101
- FileUtils.cp("#{LearnTest::FileFinder.location_to_dir('strategies/jasmine')}/jasmine.js","#{Dir.pwd}/tmpTestSupport/")
102
- FileUtils.cp("#{LearnTest::FileFinder.location_to_dir('strategies/jasmine')}/jasmine-html.js","#{Dir.pwd}/tmpTestSupport/")
103
- FileUtils.cp("#{LearnTest::FileFinder.location_to_dir('strategies/jasmine')}/console.js","#{Dir.pwd}/tmpTestSupport/")
104
- FileUtils.cp("#{LearnTest::FileFinder.location_to_dir('strategies/jasmine')}/boot.js","#{Dir.pwd}/tmpTestSupport/")
105
- FileUtils.cp("#{LearnTest::FileFinder.location_to_dir('strategies/jasmine')}/jquery-1.8.0.min.js","#{Dir.pwd}/tmpTestSupport/")
106
- FileUtils.cp("#{LearnTest::FileFinder.location_to_dir('strategies/jasmine')}/jquery-ui-1.8.23.custom.min.js","#{Dir.pwd}/tmpTestSupport/")
107
- FileUtils.cp("#{LearnTest::FileFinder.location_to_dir('strategies/jasmine')}/jasmine-jquery.js","#{Dir.pwd}/tmpTestSupport/")
108
- FileUtils.cp("#{LearnTest::FileFinder.location_to_dir('strategies/jasmine')}/jasmine.css","#{Dir.pwd}/tmpTestSupport/")
109
- FileUtils.cp("#{LearnTest::FileFinder.location_to_dir('strategies/jasmine')}/jasmine_favicon.png","#{Dir.pwd}/tmpTestSupport/")
110
- FileUtils.cp("#{LearnTest::FileFinder.location_to_dir('strategies/jasmine/formatters')}/jasmine2-junit.js","#{Dir.pwd}/tmpTestSupport/")
111
- FileUtils.cp("#{LearnTest::FileFinder.location_to_dir('strategies/jasmine/helpers')}/ConsoleHelper.js","#{Dir.pwd}/tmpTestSupport/")
112
- end
113
-
114
- def run_jasmine
115
- if browser?
116
- chrome_on_mac_path ="\"/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome\""
117
- chrome_on_linux_path = "google-chrome"
118
- jasmine_lab_path_for_chrome = "\"#{Dir.pwd}/tmpTestSupport/SpecRunner#{color_option}.html\" --allow-file-access-from-files"
119
-
120
- if RUBY_PLATFORM.include?("linux")
121
- system("#{chrome_on_linux_path} #{jasmine_lab_path_for_chrome}")
122
- else
123
- system("#{chrome_on_mac_path} #{jasmine_lab_path_for_chrome}")
124
- end
125
- else
126
- system("phantomjs #{LearnTest::FileFinder.location_to_dir('strategies/jasmine/runners')}/run-jasmine.js #{Dir.pwd}/tmpTestSupport/SpecRunner#{color_option}.html")
127
- end
128
- end
129
-
130
- def test_xml_files
131
- Dir.entries(test_path).keep_if { |f| f.match(/TEST/) }
132
- end
133
-
134
- def make_json
135
- if local? || !browser?
136
- test_xml_files.each do |f|
137
- parsed = JSON.parse(Crack::XML.parse(File.read(f)).to_json)["testsuites"]["testsuite"]
138
- results[:build][:test_suite][0][:formatted_output] << parsed["testcase"]
139
- results[:build][:test_suite][0][:formatted_output].flatten!
140
- results[:tests] += parsed["tests"].to_i
141
- results[:errors] += parsed["errors"].to_i
142
- results[:failures] += parsed["failures"].to_i
143
- results[:build][:test_suite][0][:duration] += parsed["time"].to_f
144
- end
145
- results[:passing_count] = results[:tests] - results[:failures] - results[:errors]
146
- end
147
-
148
- if out || runner.keep_results?
149
- output_file = out ? out : '.results.json'
150
- write_json_output(output_file: output_file)
151
- end
152
- end
153
-
154
- def write_json_output(output_file:)
155
- File.open(output_file, 'w+') do |f|
156
- f.write(results.to_json)
157
- end
158
- end
159
-
160
- def color_option
161
- !options[:color] ? '' : 'NoColor'
162
- end
163
-
164
- def local?
165
- !!options[:local]
166
- end
167
-
168
- def browser?
169
- !!options[:browser]
170
- end
171
-
172
- def out
173
- options[:out]
174
- end
175
-
176
- def test_path
177
- @test_path ||= FileUtils.pwd
178
- end
179
- end
180
- end
181
- end
@@ -1,184 +0,0 @@
1
- /**
2
- Starting with version 2.0, this file "boots" Jasmine, performing all of the necessary initialization before executing the loaded environment and all of a project's specs. This file should be loaded after `jasmine.js`, but before any project source files or spec files are loaded. Thus this file can also be used to customize Jasmine for a project.
3
-
4
- If a project is using Jasmine via the standalone distribution, this file can be customized directly. If a project is using Jasmine via the [Ruby gem][jasmine-gem], this file can be copied into the support directory via `jasmine copy_boot_js`. Other environments (e.g., Python) will have different mechanisms.
5
-
6
- The location of `boot.js` can be specified and/or overridden in `jasmine.yml`.
7
-
8
- [jasmine-gem]: http://github.com/pivotal/jasmine-gem
9
- */
10
-
11
- (function() {
12
-
13
- /**
14
- * ## Require &amp; Instantiate
15
- *
16
- * Require Jasmine's core files. Specifically, this requires and attaches all of Jasmine's code to the `jasmine` reference.
17
- */
18
- window.jasmine = jasmineRequire.core(jasmineRequire);
19
-
20
- /**
21
- * Since this is being run in a browser and the results should populate to an HTML page, require the HTML-specific Jasmine code, injecting the same reference.
22
- */
23
- jasmineRequire.html(jasmine);
24
-
25
- /**
26
- * Create the Jasmine environment. This is used to run all specs in a project.
27
- */
28
- var env = jasmine.getEnv();
29
-
30
- /**
31
- * ## The Global Interface
32
- *
33
- * Build up the functions that will be exposed as the Jasmine public interface. A project can customize, rename or alias any of these functions as desired, provided the implementation remains unchanged.
34
- */
35
- var jasmineInterface = {
36
- describe: function(description, specDefinitions) {
37
- return env.describe(description, specDefinitions);
38
- },
39
-
40
- xdescribe: function(description, specDefinitions) {
41
- return env.xdescribe(description, specDefinitions);
42
- },
43
-
44
- it: function(desc, func) {
45
- return env.it(desc, func);
46
- },
47
-
48
- xit: function(desc, func) {
49
- return env.xit(desc, func);
50
- },
51
-
52
- beforeEach: function(beforeEachFunction) {
53
- return env.beforeEach(beforeEachFunction);
54
- },
55
-
56
- afterEach: function(afterEachFunction) {
57
- return env.afterEach(afterEachFunction);
58
- },
59
-
60
- expect: function(actual) {
61
- return env.expect(actual);
62
- },
63
-
64
- pending: function() {
65
- return env.pending();
66
- },
67
-
68
- spyOn: function(obj, methodName) {
69
- return env.spyOn(obj, methodName);
70
- },
71
-
72
- jsApiReporter: new jasmine.JsApiReporter({
73
- timer: new jasmine.Timer()
74
- })
75
- };
76
-
77
- /**
78
- * Add all of the Jasmine global/public interface to the proper global, so a project can use the public interface directly. For example, calling `describe` in specs instead of `jasmine.getEnv().describe`.
79
- */
80
- if (typeof window == "undefined" && typeof exports == "object") {
81
- extend(exports, jasmineInterface);
82
- } else {
83
- extend(window, jasmineInterface);
84
- }
85
-
86
- /**
87
- * Expose the interface for adding custom equality testers.
88
- */
89
- jasmine.addCustomEqualityTester = function(tester) {
90
- env.addCustomEqualityTester(tester);
91
- };
92
-
93
- /**
94
- * Expose the interface for adding custom expectation matchers
95
- */
96
- jasmine.addMatchers = function(matchers) {
97
- return env.addMatchers(matchers);
98
- };
99
-
100
- /**
101
- * Expose the mock interface for the JavaScript timeout functions
102
- */
103
- jasmine.clock = function() {
104
- return env.clock;
105
- };
106
-
107
- /**
108
- * ## Runner Parameters
109
- *
110
- * More browser specific code - wrap the query string in an object and to allow for getting/setting parameters from the runner user interface.
111
- */
112
-
113
- var queryString = new jasmine.QueryString({
114
- getWindowLocation: function() { return window.location; }
115
- });
116
-
117
- var catchingExceptions = queryString.getParam("catch");
118
- env.catchExceptions(typeof catchingExceptions === "undefined" ? true : catchingExceptions);
119
-
120
- /**
121
- * ## Reporters
122
- * The `HtmlReporter` builds all of the HTML UI for the runner page. This reporter paints the dots, stars, and x's for specs, as well as all spec names and all failures (if any).
123
- */
124
- var htmlReporter = new jasmine.HtmlReporter({
125
- env: env,
126
- onRaiseExceptionsClick: function() { queryString.setParam("catch", !env.catchingExceptions()); },
127
- getContainer: function() { return document.body; },
128
- createElement: function() { return document.createElement.apply(document, arguments); },
129
- createTextNode: function() { return document.createTextNode.apply(document, arguments); },
130
- timer: new jasmine.Timer()
131
- });
132
-
133
- /**
134
- * The `jsApiReporter` also receives spec results, and is used by any environment that needs to extract the results from JavaScript.
135
- */
136
- env.addReporter(jasmineInterface.jsApiReporter);
137
- var JUnitXmlReporter = jasmineRequire.JUnitXmlReporter()
138
- env.addReporter(new JUnitXmlReporter());
139
- env.addReporter(htmlReporter);
140
-
141
- /**
142
- * Filter which specs will be run by matching the start of the full name against the `spec` query param.
143
- */
144
- var specFilter = new jasmine.HtmlSpecFilter({
145
- filterString: function() { return queryString.getParam("spec"); }
146
- });
147
-
148
- env.specFilter = function(spec) {
149
- return specFilter.matches(spec.getFullName());
150
- };
151
-
152
- /**
153
- * Setting up timing functions to be able to be overridden. Certain browsers (Safari, IE 8, phantomjs) require this hack.
154
- */
155
- window.setTimeout = window.setTimeout;
156
- window.setInterval = window.setInterval;
157
- window.clearTimeout = window.clearTimeout;
158
- window.clearInterval = window.clearInterval;
159
-
160
- /**
161
- * ## Execution
162
- *
163
- * Replace the browser window's `onload`, ensure it's called, and then run all of the loaded specs. This includes initializing the `HtmlReporter` instance and then executing the loaded Jasmine environment. All of this will happen after all of the specs are loaded.
164
- */
165
- var currentWindowOnload = window.onload;
166
-
167
- window.onload = function() {
168
- if (currentWindowOnload) {
169
- currentWindowOnload();
170
- }
171
- htmlReporter.initialize();
172
- env.execute();
173
- };
174
-
175
- /**
176
- * Helper function for readability above.
177
- */
178
- function extend(destination, source) {
179
- for (var property in source) destination[property] = source[property];
180
- return destination;
181
- }
182
-
183
- }());
184
-