qunited 0.0.1

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 (37) hide show
  1. data/.gitignore +13 -0
  2. data/Gemfile +4 -0
  3. data/Rakefile +9 -0
  4. data/bin/qunited +23 -0
  5. data/lib/qunited/js_runner/base.rb +34 -0
  6. data/lib/qunited/js_runner/rhino/js/env.rhino.js +14006 -0
  7. data/lib/qunited/js_runner/rhino/js/js.jar +0 -0
  8. data/lib/qunited/js_runner/rhino/js/qunit-runner.js +168 -0
  9. data/lib/qunited/js_runner/rhino/js/qunit.js +1838 -0
  10. data/lib/qunited/js_runner/rhino/js/yaml.js +22 -0
  11. data/lib/qunited/js_runner/rhino.rb +65 -0
  12. data/lib/qunited/js_runner.rb +2 -0
  13. data/lib/qunited/rake_task.rb +87 -0
  14. data/lib/qunited/results.rb +164 -0
  15. data/lib/qunited/runner.rb +23 -0
  16. data/lib/qunited/version.rb +3 -0
  17. data/lib/qunited.rb +4 -0
  18. data/qunited.gemspec +20 -0
  19. data/test/fixtures/basic_project/app/assets/javascripts/application.js +6 -0
  20. data/test/fixtures/basic_project/test/javascripts/test_basics.js +6 -0
  21. data/test/fixtures/basic_project/test/javascripts/test_math.js +12 -0
  22. data/test/fixtures/dom_project/app/assets/javascripts/application.js +6 -0
  23. data/test/fixtures/dom_project/test/javascripts/test_misc.js +5 -0
  24. data/test/fixtures/errors_project/app/assets/javascripts/no_error.js +5 -0
  25. data/test/fixtures/errors_project/app/assets/javascripts/syntax_error.js +7 -0
  26. data/test/fixtures/errors_project/app/assets/javascripts/undefined_error.js +9 -0
  27. data/test/fixtures/errors_project/test/javascripts/this_test_has_no_errors_in_it.js +5 -0
  28. data/test/fixtures/errors_project/test/javascripts/this_test_has_no_tests.js +4 -0
  29. data/test/fixtures/errors_project/test/javascripts/this_test_has_syntax_error.js +10 -0
  30. data/test/fixtures/errors_project/test/javascripts/this_test_has_undefined_error.js +10 -0
  31. data/test/fixtures/failures_project/app/assets/javascripts/application.js +5 -0
  32. data/test/fixtures/failures_project/test/javascripts/test_basics.js +11 -0
  33. data/test/fixtures/failures_project/test/javascripts/test_math.js +12 -0
  34. data/test/test_helper.rb +5 -0
  35. data/test/unit/test_results.rb +338 -0
  36. data/test/unit/test_rhino_runner.rb +114 -0
  37. metadata +100 -0
data/.gitignore ADDED
@@ -0,0 +1,13 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ *.log
6
+ .DS_Store
7
+ .DS_Store?
8
+ ._*
9
+ .Spotlight-V100
10
+ .Trashes
11
+ Icon?
12
+ ehthumbs.db
13
+ Thumbs.db
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in qunited.gemspec
4
+ gemspec
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
4
+ task :default => [:test]
5
+
6
+ Rake::TestTask.new do |t|
7
+ t.libs << 'lib'
8
+ t.pattern = 'test/unit/**/test_*.rb'
9
+ end
data/bin/qunited ADDED
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env ruby
2
+ require 'qunited'
3
+
4
+ if ARGV.empty? || ARGV.include?('-h') || ARGV.include?('--help')
5
+ puts <<-HELP_TEXT
6
+ Usage: qunited [OPTIONS] [JS_SOURCE_FILES...] -- [JS_TEST_FILES..]
7
+
8
+ Runs JavaScript unit tests with QUnit.
9
+
10
+ JS_SOURCE_FILES are the JavaScript files that you want to test. They will all be
11
+ loaded for running each test.
12
+
13
+ JS_TEST_FILES are files that contain the QUnit tests to run.
14
+ and (optional) NAME
15
+
16
+ Options:
17
+ -h, --help Show this message
18
+ HELP_TEXT
19
+ exit
20
+ end
21
+
22
+ js_source_files, js_test_files = ARGV.join(' ').split('--').map { |file_list| file_list.split(' ') }
23
+ exit QUnited::Runner.run(js_source_files, js_test_files)
@@ -0,0 +1,34 @@
1
+ module QUnited
2
+ module JsRunner
3
+ class Base
4
+ attr_reader :results
5
+
6
+ # Array of file names? Glob pattern?
7
+ def initialize(source_files, test_files)
8
+ @source_files = if source_files.is_a? String
9
+ Dir.glob(source_files)
10
+ elsif source_files.is_a? Array
11
+ source_files
12
+ end
13
+
14
+ @test_files = if test_files.is_a? String
15
+ Dir.glob(test_files)
16
+ elsif test_files.is_a? Array
17
+ test_files
18
+ end
19
+ end
20
+
21
+ def can_run?
22
+ false
23
+ end
24
+
25
+ def name
26
+ self.class.name.split('::')[-1]
27
+ end
28
+
29
+ def run
30
+ raise 'run not implemented'
31
+ end
32
+ end
33
+ end
34
+ end