learn-test 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +14 -0
  3. data/.rspec +2 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +23 -0
  6. data/README.md +38 -0
  7. data/Rakefile +2 -0
  8. data/bin/learn-test +78 -0
  9. data/learn-test.gemspec +30 -0
  10. data/lib/learn_test.rb +26 -0
  11. data/lib/learn_test/file_finder.rb +12 -0
  12. data/lib/learn_test/github_interactor.rb +23 -0
  13. data/lib/learn_test/jasmine/boot.js +184 -0
  14. data/lib/learn_test/jasmine/console.js +161 -0
  15. data/lib/learn_test/jasmine/formatters/jasmine2-junit.js +199 -0
  16. data/lib/learn_test/jasmine/helpers/ConsoleHelper.js +12 -0
  17. data/lib/learn_test/jasmine/helpers/ConsoleHelperNoColor.js +12 -0
  18. data/lib/learn_test/jasmine/initializer.rb +27 -0
  19. data/lib/learn_test/jasmine/jasmine-html.js +360 -0
  20. data/lib/learn_test/jasmine/jasmine-jquery.js +813 -0
  21. data/lib/learn_test/jasmine/jasmine.css +56 -0
  22. data/lib/learn_test/jasmine/jasmine.js +2403 -0
  23. data/lib/learn_test/jasmine/jasmine_favicon.png +0 -0
  24. data/lib/learn_test/jasmine/jquery-1.8.0.min.js +2 -0
  25. data/lib/learn_test/jasmine/jquery-ui-1.8.23.custom.min.js +125 -0
  26. data/lib/learn_test/jasmine/phantom_checker.rb +55 -0
  27. data/lib/learn_test/jasmine/runner.rb +129 -0
  28. data/lib/learn_test/jasmine/runners/SpecRunner.html +35 -0
  29. data/lib/learn_test/jasmine/runners/run-jasmine.js +228 -0
  30. data/lib/learn_test/jasmine/templates/SpecRunnerTemplate.html.erb +35 -0
  31. data/lib/learn_test/jasmine/templates/SpecRunnerTemplateNoColor.html.erb +35 -0
  32. data/lib/learn_test/jasmine/templates/requires.yml.example +7 -0
  33. data/lib/learn_test/jasmine/vendor/require.js +2077 -0
  34. data/lib/learn_test/netrc_interactor.rb +18 -0
  35. data/lib/learn_test/python_unittest/nose_installer.rb +35 -0
  36. data/lib/learn_test/python_unittest/requirements_checker.rb +57 -0
  37. data/lib/learn_test/python_unittest/runner.rb +89 -0
  38. data/lib/learn_test/repo_parser.rb +22 -0
  39. data/lib/learn_test/rspec/runner.rb +113 -0
  40. data/lib/learn_test/spec_type_parser.rb +26 -0
  41. data/lib/learn_test/user_id_parser.rb +9 -0
  42. data/lib/learn_test/username_parser.rb +19 -0
  43. data/lib/learn_test/version.rb +3 -0
  44. data/spec/features/jasmine_jquery_fixtures_spec.rb +10 -0
  45. data/spec/features/rspec_unit_spec.rb +10 -0
  46. data/spec/fixtures/jasmine-jquery-fixtures/index.html +10 -0
  47. data/spec/fixtures/jasmine-jquery-fixtures/requires.yml +4 -0
  48. data/spec/fixtures/jasmine-jquery-fixtures/spec/jasmine-jquery-fixtures-spec.js +11 -0
  49. data/spec/fixtures/rspec-unit-spec/.rspec +2 -0
  50. data/spec/fixtures/rspec-unit-spec/lib/dog.rb +2 -0
  51. data/spec/fixtures/rspec-unit-spec/spec/dog_spec.rb +7 -0
  52. data/spec/fixtures/rspec-unit-spec/spec/spec_helper.rb +93 -0
  53. data/spec/repo_parser_spec.rb +25 -0
  54. data/spec/spec_helper.rb +10 -0
  55. metadata +237 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1fe488abc6bb75dddc1d7f2ef2e77ff023efa15a
4
+ data.tar.gz: 5ae0f0c51e092a96a215a493acc8a8137cc6c9da
5
+ SHA512:
6
+ metadata.gz: 7fef161c0626db5571cbb627d62fed06992633f77b6ce8edd03239d62c0785735224ee2417337176b87c60c6b42cd2a82b140cb92fb51933ac6929289c646408
7
+ data.tar.gz: 4162d0aa75136cd67bedb3c12d87c7751e22d2c478ba812d014adeaaeba7d53af8b2a6a0c023b798394130f2433988e529c2411416f18993ab70a289908e4b0f
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in learn.gemspec
4
+ gemspec
@@ -0,0 +1,23 @@
1
+ Copyright (c) 2014-2015 Flatiron School
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
+
@@ -0,0 +1,38 @@
1
+ # learn-test
2
+
3
+ Runs RSpec, Jasmine, and Python Unit Test test suites and uploads the results to Learn.
4
+
5
+ ## Installation
6
+
7
+ Install with:
8
+
9
+ ```
10
+ $ gem install learn-test
11
+ ```
12
+
13
+ Alternatively, add this line to your application's Gemfile:
14
+
15
+ ```ruby
16
+ gem 'learn-test'
17
+ ```
18
+
19
+ And then execute:
20
+
21
+ $ bundle
22
+
23
+ ## Usage
24
+
25
+ From within a directory with an RSpec, Jasmine, or Python Unit Test test suite, run:
26
+
27
+ ```
28
+ $ learn-test
29
+ ```
30
+
31
+ ## Contributing
32
+
33
+ 1. Fork it ( https://github.com/flatiron-labs/learn-test/fork )
34
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
35
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
36
+ 4. Push to the branch (`git push origin my-new-feature`)
37
+ 5. Create a new Pull Request
38
+
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,78 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'optparse'
4
+ require 'learn_test'
5
+
6
+ SERVICE_URL = 'http://ironbroker.flatironschool.com'
7
+
8
+ spec_type = LearnTest::SpecTypeParser.new.spec_type
9
+
10
+ unless spec_type == 'jasmine'
11
+ username = LearnTest::UsernameParser.get_username
12
+ user_id = LearnTest::UserIdParser.get_user_id
13
+ end
14
+
15
+ repo = ARGV.include?("--test") ? "git@github.com:flatiron-school/a-sample-repo.git" : LearnTest::RepoParser.get_repo
16
+
17
+ if spec_type == "jasmine"
18
+ SERVICE_ENDPOINT = '/e/flatiron_jasmine/build/ironboard'
19
+
20
+ options = {}
21
+ OptionParser.new do |opts|
22
+ opts.banner = "Usage: learn [options]"
23
+
24
+ opts.on("-n", "--[no-]color", "Turn off color output") do |c|
25
+ options[:color] = c
26
+ end
27
+
28
+ opts.on("-l", "--local", "Don't push results to Flatiron LMS") do |l|
29
+ options[:local] = l
30
+ end
31
+
32
+ opts.on("-b", "--browser", "Run tests in browser") do |b|
33
+ options[:browser] = b
34
+ end
35
+
36
+ opts.on("-o", "--out FILE") do |o|
37
+ options[:out] = o
38
+ end
39
+
40
+ opts.on("-s", "--skip") do |s|
41
+ options[:skip] = s
42
+ end
43
+
44
+ opts.on("-t", "--test") do |t|
45
+ options[:test] = t
46
+ end
47
+ end.parse!
48
+
49
+ if ARGV.any? { |arg| arg == "init" }
50
+ LearnTest::Jasmine::Initializer.run
51
+ else
52
+ if !options[:skip]
53
+ LearnTest::Jasmine::PhantomChecker.check_installation
54
+ username = LearnTest::UsernameParser.get_username
55
+ user_id = LearnTest::UserIdParser.get_user_id
56
+ else
57
+ username = "jasmine-flatiron"
58
+ user_id = "none"
59
+ end
60
+
61
+ LearnTest::Jasmine::Runner.run(username, user_id, repo, options)
62
+ end
63
+ elsif spec_type == "rspec"
64
+ SERVICE_ENDPOINT = '/e/flatiron_rspec/build/ironboard'
65
+
66
+ runner = LearnTest::RSpec::Runner.new(username, user_id, repo, ARGV)
67
+ runner.run
68
+ elsif spec_type == 'python_unittest'
69
+ SERVICE_ENDPOINT = '/e/flatiron_unittest/build/ironboard'
70
+
71
+ LearnTest::PythonUnittest::RequirementsChecker.check_installation
72
+ LearnTest::PythonUnittest::NoseInstaller.install
73
+
74
+ runner = LearnTest::PythonUnittest::Runner.new(username, user_id, repo, ARGV)
75
+ runner.run
76
+ else
77
+ puts "This directory doesn't appear to have any specs in it."
78
+ end
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'learn_test/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "learn-test"
8
+ spec.version = LearnTest::VERSION
9
+ spec.authors = ["Flatiron School"]
10
+ spec.email = ["info@flatironschool.com"]
11
+ spec.summary = %q{Runs RSpec, Jasmine, and Python Unit Test builds and pushes JSON output to Learn.}
12
+ spec.homepage = "http://learn.co"
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib", "bin"]
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.7"
21
+ spec.add_development_dependency "rake", "~> 10.0"
22
+ spec.add_runtime_dependency "rspec", "~> 3.0"
23
+ spec.add_runtime_dependency "netrc"
24
+ spec.add_runtime_dependency "git", "~> 1.2"
25
+ spec.add_runtime_dependency "oj", "~> 2.9"
26
+ spec.add_runtime_dependency "faraday", "~> 0.9"
27
+ spec.add_runtime_dependency "crack"
28
+ spec.add_runtime_dependency "jasmine"
29
+ end
30
+
@@ -0,0 +1,26 @@
1
+ require 'fileutils'
2
+ require 'faraday'
3
+ require 'oj'
4
+
5
+ require 'learn_test/version'
6
+ require 'learn_test/netrc_interactor'
7
+ require 'learn_test/github_interactor'
8
+ require 'learn_test/user_id_parser'
9
+ require 'learn_test/username_parser'
10
+ require 'learn_test/repo_parser'
11
+ require 'learn_test/file_finder'
12
+ require 'learn_test/spec_type_parser'
13
+
14
+ require 'learn_test/rspec/runner'
15
+
16
+ require 'learn_test/jasmine/phantom_checker'
17
+ require 'learn_test/jasmine/initializer'
18
+ require 'learn_test/jasmine/runner'
19
+
20
+ require 'learn_test/python_unittest/requirements_checker'
21
+ require 'learn_test/python_unittest/nose_installer'
22
+ require 'learn_test/python_unittest/runner'
23
+
24
+ module LearnTest
25
+ end
26
+
@@ -0,0 +1,12 @@
1
+ module LearnTest
2
+ class FileFinder
3
+ def self.location_to_dir(dir_name)
4
+ new.location_to_dir(dir_name)
5
+ end
6
+
7
+ def location_to_dir(dir_name)
8
+ File.join(File.dirname(File.expand_path(__FILE__)), "#{dir_name}")
9
+ end
10
+ end
11
+ end
12
+
@@ -0,0 +1,23 @@
1
+ require 'open-uri'
2
+
3
+ module LearnTest
4
+ class GithubInteractor
5
+ attr_reader :username, :user_id
6
+
7
+ def self.get_user_id_for(username)
8
+ new(username).get_user_id
9
+ end
10
+
11
+ def initialize(username)
12
+ @username = username
13
+ end
14
+
15
+ def get_user_id
16
+ @user_id ||= Oj.load(
17
+ open("https://api.github.com/users/#{username}").read,
18
+ symbol_keys: true
19
+ )[:id]
20
+ end
21
+ end
22
+ end
23
+
@@ -0,0 +1,184 @@
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 & 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
+