newjs 1.5.1 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +11 -0
- data/Manifest.txt +162 -14
- data/{README.txt → README.rdoc} +1 -1
- data/Rakefile +25 -3
- data/app_generators/newjs_iphone/templates/Html/test/assets/jsunittest.js +41 -13
- data/app_generators/newjs_iphone/templates/Html/test/assets/unittest.css +4 -0
- data/features/development.feature +13 -0
- data/features/imported_files_for_generators.feature +19 -0
- data/features/steps/common.rb +205 -0
- data/features/steps/env.rb +6 -0
- data/javascript_test_generators/functional_test/functional_test_generator.rb +9 -1
- data/javascript_test_generators/functional_test/templates/test/assets/jshoulda.js +186 -0
- data/javascript_test_generators/functional_test/templates/test/test.html.erb +15 -1
- data/javascript_test_generators/unit_test/templates/test/assets/jshoulda.js +186 -0
- data/javascript_test_generators/unit_test/templates/test/test.html.erb +18 -20
- data/javascript_test_generators/unit_test/templates/test/test_jshoulda.html.erb +45 -0
- data/javascript_test_generators/unit_test/unit_test_generator.rb +11 -3
- data/lib/newjs.rb +3 -2
- data/newjs_iphone_generators/page/USAGE +5 -0
- data/newjs_iphone_generators/page/page_generator.rb +36 -0
- data/newjs_iphone_generators/page/templates/src/name.css.erb +0 -0
- data/newjs_iphone_generators/page/templates/src/name.html.erb +13 -0
- data/newjs_iphone_generators/page/templates/src/name.js.erb +4 -0
- data/newjs_iphone_generators/page/templates/test/fixtures/name.js.erb +5 -0
- data/newjs_iphone_generators/page/templates/test/unit/name_test.html.erb +61 -0
- data/rack_generators/javascript_test/USAGE +5 -0
- data/rack_generators/javascript_test/javascript_test_generator.rb +88 -0
- data/rack_generators/javascript_test/templates/assets/jshoulda.js +186 -0
- data/rack_generators/javascript_test/templates/assets/jsunittest.js +1004 -0
- data/rack_generators/javascript_test/templates/assets/unittest.css +54 -0
- data/rack_generators/javascript_test/templates/ext/jquery.js +3408 -0
- data/{app_generators/newjs_iphone/templates/Html/test/assets → rack_generators/javascript_test/templates/ext}/prototype.js +56 -122
- data/rack_generators/javascript_test/templates/library.js.erb +3 -0
- data/rack_generators/javascript_test/templates/test.html.erb +59 -0
- data/rack_generators/javascript_test/templates/test_jshoulda.html.erb +48 -0
- data/rails_generators/javascript_test/javascript_test_generator.rb +15 -3
- data/rails_generators/javascript_test/templates/assets/jshoulda.js +186 -0
- data/rails_generators/javascript_test/templates/test_jshoulda.html.erb +48 -0
- data/script/console +10 -0
- data/script/destroy +1 -1
- data/tasks/vendor/update/jshoulda.rake +18 -0
- data/tasks/vendor/update/jsunittest.rake +18 -0
- data/test/test_functional_test_generator.rb +13 -0
- data/test/test_generator_helper.rb +10 -1
- data/test/test_page_generator.rb +50 -0
- data/test/test_rack_javascript_test.rb +166 -0
- data/test/{test_javascript_test_generator.rb → test_rails_javascript_test_generator.rb} +15 -1
- data/test/test_unit_test_generator.rb +13 -0
- data/vendor/jshoulda/History.txt +108 -0
- data/vendor/jshoulda/License.txt +20 -0
- data/vendor/jshoulda/README.mdown +34 -0
- data/vendor/jshoulda/Rakefile +120 -0
- data/vendor/jshoulda/config/javascript_test_autotest.yml.sample +15 -0
- data/vendor/jshoulda/dist/jshoulda-0.0.1.js +62 -0
- data/vendor/jshoulda/dist/jshoulda-0.0.2.js +72 -0
- data/vendor/jshoulda/dist/jshoulda-0.0.3.js +72 -0
- data/vendor/jshoulda/dist/jshoulda-1.0.1.js +74 -0
- data/vendor/jshoulda/dist/jshoulda-1.0.js +72 -0
- data/vendor/jshoulda/dist/jshoulda-1.1.js +110 -0
- data/vendor/jshoulda/dist/jshoulda-1.2.1.js +186 -0
- data/vendor/jshoulda/dist/jshoulda-1.2.js +141 -0
- data/vendor/jshoulda/dist/jshoulda-1.2.x.js +142 -0
- data/vendor/jshoulda/dist/jshoulda.js +186 -0
- data/vendor/jshoulda/jshoulda/test/basic_test.html +42 -0
- data/vendor/jshoulda/lib/jstest.rb +382 -0
- data/vendor/jshoulda/lib/protodoc.rb +36 -0
- data/vendor/jshoulda/script/destroy +14 -0
- data/vendor/jshoulda/script/generate +14 -0
- data/vendor/jshoulda/script/js_autotest +1 -0
- data/vendor/jshoulda/script/rstakeout +97 -0
- data/vendor/jshoulda/site/asset_defaults.yaml +6 -0
- data/vendor/jshoulda/site/config.yaml +3 -0
- data/vendor/jshoulda/site/content/content.html +27 -0
- data/vendor/jshoulda/site/content/content.yaml +4 -0
- data/vendor/jshoulda/site/content/tutorial/tutorial.html +268 -0
- data/vendor/jshoulda/site/content/tutorial/tutorial.yaml +4 -0
- data/vendor/jshoulda/site/css/blackboard.css +88 -0
- data/vendor/jshoulda/site/css/jshoulda_site.css +33 -0
- data/vendor/jshoulda/site/css/unittest.css +42 -0
- data/vendor/jshoulda/site/example/minimal.html +55 -0
- data/vendor/jshoulda/site/js/editable.js +42 -0
- data/vendor/jshoulda/site/layouts/default/default.html +29 -0
- data/vendor/jshoulda/site/layouts/default/default.yaml +4 -0
- data/vendor/jshoulda/site/layouts/home_test/home_test.js +18 -0
- data/vendor/jshoulda/site/layouts/home_test/home_test.yaml +4 -0
- data/vendor/jshoulda/site/lib/analytics.rb +12 -0
- data/vendor/jshoulda/site/lib/default.rb +2 -0
- data/vendor/jshoulda/site/lib/example.rb +10 -0
- data/vendor/jshoulda/site/lib/hash.rb +11 -0
- data/vendor/jshoulda/site/lib/highlight.rb +17 -0
- data/vendor/jshoulda/site/page_defaults.yaml +10 -0
- data/vendor/jshoulda/site/templates/default/default.html +1 -0
- data/vendor/jshoulda/site/templates/default/default.yaml +4 -0
- data/vendor/jshoulda/src/HEADER +8 -0
- data/vendor/jshoulda/src/jshoulda.js +177 -0
- data/vendor/jshoulda/src/jshoulda.js.erb +3 -0
- data/vendor/jshoulda/tasks/bundle.rake +12 -0
- data/vendor/jshoulda/tasks/demo.rake +9 -0
- data/vendor/jshoulda/tasks/deploy.rake +29 -0
- data/{tasks → vendor/jshoulda/tasks}/environment.rake +0 -0
- data/vendor/jshoulda/tasks/javascript_test_autotest_tasks.rake +45 -0
- data/vendor/jshoulda/tasks/site.rake +74 -0
- data/vendor/jshoulda/test/assets/jsunittest.js +1004 -0
- data/vendor/jshoulda/test/assets/prototype.js +4324 -0
- data/{app_generators/newjs_iphone/templates/Html/test/assets/unittest.js → vendor/jshoulda/test/assets/prototype_unittest.js} +15 -9
- data/vendor/jshoulda/test/assets/unittest.css +50 -0
- data/vendor/jshoulda/test/unit/factory_test.html +82 -0
- data/vendor/jshoulda/test/unit/jshoulda2_test.html +85 -0
- data/vendor/jshoulda/test/unit/jshoulda_prototype_test.html +87 -0
- data/vendor/jshoulda/test/unit/jshoulda_test.html +86 -0
- data/vendor/jshoulda/test/unit/merge_methods_test.html +77 -0
- data/vendor/jshoulda/test/unit/names_and_count.html +68 -0
- data/vendor/jshoulda/test/unit/no_config_test.html +57 -0
- data/vendor/jshoulda/test/unit/styles_test.html +77 -0
- data/vendor/jshoulda/test/unit/unify_runners.html +69 -0
- data/vendor/jshoulda/test/unit/unnamed_context_test.html +67 -0
- data/vendor/jsunittest/Capfile +4 -0
- data/vendor/jsunittest/History.txt +37 -0
- data/{License.txt → vendor/jsunittest/License.txt} +0 -0
- data/vendor/jsunittest/README.txt +21 -0
- data/vendor/jsunittest/Rakefile +118 -0
- data/vendor/jsunittest/config/deploy.rb +20 -0
- data/vendor/jsunittest/config/website.yml.sample +2 -0
- data/vendor/jsunittest/dist/jsunittest-0.7.2.js +1004 -0
- data/vendor/jsunittest/dist/jsunittest.js +1004 -0
- data/vendor/jsunittest/dist/unittest.css +54 -0
- data/vendor/jsunittest/lib/jstest.rb +390 -0
- data/vendor/jsunittest/lib/protodoc.rb +36 -0
- data/vendor/jsunittest/script/destroy +14 -0
- data/vendor/jsunittest/script/generate +14 -0
- data/vendor/jsunittest/script/js_autotest +1 -0
- data/vendor/jsunittest/script/rstakeout +97 -0
- data/vendor/jsunittest/script/txt2html +75 -0
- data/vendor/jsunittest/src/HEADER +8 -0
- data/vendor/jsunittest/src/ajax.js +121 -0
- data/vendor/jsunittest/src/assertions.js +244 -0
- data/vendor/jsunittest/src/common.js +191 -0
- data/vendor/jsunittest/src/jsunittest.js +1004 -0
- data/vendor/jsunittest/src/logger.js +86 -0
- data/vendor/jsunittest/src/message_template.js +17 -0
- data/vendor/jsunittest/src/orig/unittest.js +484 -0
- data/vendor/jsunittest/src/prototype/event.js +72 -0
- data/vendor/jsunittest/src/prototype/template.js +33 -0
- data/vendor/jsunittest/src/runner.js +120 -0
- data/vendor/jsunittest/src/test_case.js +106 -0
- data/vendor/jsunittest/tasks/deploy.rake +29 -0
- data/vendor/jsunittest/tasks/environment.rake +7 -0
- data/vendor/jsunittest/tasks/javascript_test_autotest_tasks.rake +44 -0
- data/vendor/jsunittest/tasks/tmbundle.rake +24 -0
- data/vendor/jsunittest/tasks/website.rake +53 -0
- data/vendor/jsunittest/test/assets/example_test.html +50 -0
- data/{app_generators/newjs/templates → vendor/jsunittest}/test/assets/prototype.js +0 -0
- data/vendor/jsunittest/test/assets/unittest.css +54 -0
- data/{app_generators/newjs/templates → vendor/jsunittest}/test/assets/unittest.js +0 -0
- data/vendor/jsunittest/test/functional/jsunittest_test.html +209 -0
- data/vendor/jsunittest/test/unit/assertions_test.html +202 -0
- data/vendor/jsunittest/test/unit/common_test.html +61 -0
- data/vendor/jsunittest/test/unit/logger_test.html +98 -0
- data/vendor/jsunittest/test/unit/message_template_test.html +44 -0
- data/vendor/jsunittest/test/unit/runner_test.html +77 -0
- data/vendor/jsunittest/test/unit/template_test.html +57 -0
- data/vendor/jsunittest/test/unit/test_case_test.html +97 -0
- data/vendor/jsunittest/website/dist/jsunittest-0.7.2.js +1004 -0
- data/vendor/jsunittest/website/dist/jsunittest-getting-started.tar.gz +0 -0
- data/vendor/jsunittest/website/dist/jsunittest-getting-started.zip +0 -0
- data/vendor/jsunittest/website/dist/jsunittest-getting-started/assets/jsunittest.js +1004 -0
- data/vendor/jsunittest/website/dist/jsunittest-getting-started/assets/unittest.css +54 -0
- data/vendor/jsunittest/website/dist/jsunittest-getting-started/example_test.html +50 -0
- data/vendor/jsunittest/website/dist/jsunittest.js +1004 -0
- data/vendor/jsunittest/website/images/logo_bundle.png +0 -0
- data/vendor/jsunittest/website/images/passing_prototypejs_unittest_tests.jpg +0 -0
- data/vendor/jsunittest/website/index.html +94 -0
- data/vendor/jsunittest/website/index.txt +80 -0
- data/vendor/jsunittest/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/vendor/jsunittest/website/stylesheets/screen.css +138 -0
- data/vendor/jsunittest/website/template.html.erb +46 -0
- data/vendor/jsunittest/website/tmbundle/JavaScript Unit Testing.tmbundle.tar.gz +0 -0
- metadata +189 -24
- data/config/hoe.rb +0 -75
- data/config/requirements.rb +0 -17
- data/lib/newjs/version.rb +0 -9
- data/tasks/deployment.rake +0 -34
- data/tasks/jsunittest/update.rake +0 -18
- data/tasks/website.rake +0 -17
@@ -0,0 +1,120 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
begin
|
3
|
+
require 'rake'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'This script should only be accessed via the "rake" command.'
|
6
|
+
puts 'Installation: gem install rake -y'
|
7
|
+
exit
|
8
|
+
end
|
9
|
+
require 'rake'
|
10
|
+
require 'rake/clean'
|
11
|
+
require 'rake/packagetask'
|
12
|
+
|
13
|
+
$:.unshift File.dirname(__FILE__) + "/lib"
|
14
|
+
|
15
|
+
APP_VERSION = '1.2.1'
|
16
|
+
APP_NAME = 'jshoulda'
|
17
|
+
RUBYFORGE_PROJECT = APP_NAME
|
18
|
+
APP_TEMPLATE = "#{APP_NAME}.js.erb"
|
19
|
+
APP_FILE_NAME= "#{APP_NAME}.js"
|
20
|
+
|
21
|
+
APP_ROOT = File.expand_path(File.dirname(__FILE__))
|
22
|
+
APP_SRC_DIR = File.join(APP_ROOT, 'src')
|
23
|
+
APP_DIST_DIR = File.join(APP_ROOT, 'dist')
|
24
|
+
APP_PKG_DIR = File.join(APP_ROOT, 'pkg')
|
25
|
+
|
26
|
+
|
27
|
+
unless ENV['rakefile_just_config']
|
28
|
+
|
29
|
+
|
30
|
+
CLEAN.include [ "#{APP_DIST_DIR}/#{APP_NAME}.js", "#{APP_DIST_DIR}/#{APP_NAME}-#{APP_VERSION}.js" ]
|
31
|
+
|
32
|
+
task :default => [:dist, :package, :clean_package_source]
|
33
|
+
|
34
|
+
desc "Builds the distribution"
|
35
|
+
task :dist do
|
36
|
+
$:.unshift File.join(APP_ROOT, 'lib')
|
37
|
+
require 'protodoc'
|
38
|
+
require 'fileutils'
|
39
|
+
FileUtils.mkdir_p APP_DIST_DIR
|
40
|
+
|
41
|
+
Dir.chdir(APP_SRC_DIR) do
|
42
|
+
File.open(File.join(APP_DIST_DIR, APP_FILE_NAME), 'w+') do |dist|
|
43
|
+
dist << Protodoc::Preprocessor.new(APP_TEMPLATE)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
Dir.chdir(APP_DIST_DIR) do
|
47
|
+
FileUtils.copy_file APP_FILE_NAME, "#{APP_NAME}-#{APP_VERSION}.js"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
Rake::PackageTask.new(APP_NAME, APP_VERSION) do |package|
|
52
|
+
package.need_tar_gz = true
|
53
|
+
package.package_dir = APP_PKG_DIR
|
54
|
+
package.package_files.include(
|
55
|
+
'[A-Z]*',
|
56
|
+
'config/*.sample',
|
57
|
+
"dist/#{APP_FILE_NAME}",
|
58
|
+
'lib/**',
|
59
|
+
'src/**',
|
60
|
+
'script/**',
|
61
|
+
'tasks/**',
|
62
|
+
'test/**',
|
63
|
+
'website/**'
|
64
|
+
)
|
65
|
+
end
|
66
|
+
|
67
|
+
desc "Builds the distribution, runs the JavaScript unit + functional tests and collects their results."
|
68
|
+
task :test => [:dist, :test_units, :test_functionals]
|
69
|
+
|
70
|
+
require 'jstest'
|
71
|
+
desc "Runs all the JavaScript unit tests and collects the results"
|
72
|
+
JavaScriptTestTask.new(:test_units, 4711) do |t|
|
73
|
+
testcases = ENV['TESTCASES']
|
74
|
+
tests_to_run = ENV['TESTS'] && ENV['TESTS'].split(',')
|
75
|
+
browsers_to_test = ENV['BROWSERS'] && ENV['BROWSERS'].split(',')
|
76
|
+
|
77
|
+
t.mount("/dist")
|
78
|
+
t.mount("/src")
|
79
|
+
t.mount("/test")
|
80
|
+
|
81
|
+
Dir["test/unit/*_test.html"].sort.each do |test_file|
|
82
|
+
tests = testcases ? { :url => "/#{test_file}", :testcases => testcases } : "/#{test_file}"
|
83
|
+
test_filename = test_file[/.*\/(.+?)\.html/, 1]
|
84
|
+
t.run(tests) unless tests_to_run && !tests_to_run.include?(test_filename)
|
85
|
+
end
|
86
|
+
|
87
|
+
%w( safari firefox ie konqueror opera ).each do |browser|
|
88
|
+
t.browser(browser.to_sym) unless browsers_to_test && !browsers_to_test.include?(browser)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
desc "Runs all the JavaScript functional tests and collects the results"
|
93
|
+
JavaScriptTestTask.new(:test_functionals, 4712) do |t|
|
94
|
+
testcases = ENV['TESTCASES']
|
95
|
+
tests_to_run = ENV['TESTS'] && ENV['TESTS'].split(',')
|
96
|
+
browsers_to_test = ENV['BROWSERS'] && ENV['BROWSERS'].split(',')
|
97
|
+
|
98
|
+
t.mount("/dist")
|
99
|
+
t.mount("/src")
|
100
|
+
t.mount("/test")
|
101
|
+
|
102
|
+
Dir["test/functional/*_test.html"].sort.each do |test_file|
|
103
|
+
tests = testcases ? { :url => "/#{test_file}", :testcases => testcases } : "/#{test_file}"
|
104
|
+
test_filename = test_file[/.*\/(.+?)\.html/, 1]
|
105
|
+
t.run(tests) unless tests_to_run && !tests_to_run.include?(test_filename)
|
106
|
+
end
|
107
|
+
|
108
|
+
%w( safari firefox ie konqueror opera ).each do |browser|
|
109
|
+
t.browser(browser.to_sym) unless browsers_to_test && !browsers_to_test.include?(browser)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
|
114
|
+
task :clean_package_source do
|
115
|
+
rm_rf File.join(APP_PKG_DIR, "#{APP_NAME}-#{APP_VERSION}")
|
116
|
+
end
|
117
|
+
|
118
|
+
Dir['tasks/**/*.rake'].each { |rake| load rake }
|
119
|
+
|
120
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# This file has been copied here by the javascript_test_autotest plugin.
|
2
|
+
# Comment/uncomment the browsers you wish to autotest with.
|
3
|
+
# Same schema as per selenium-on-rails plugin, which is nice.
|
4
|
+
browsers:
|
5
|
+
# Windows
|
6
|
+
# firefox: 'c:\Program Files\Mozilla Firefox\firefox.exe'
|
7
|
+
# ie: 'c:\Program Files\Internet Explorer\iexplore.exe'
|
8
|
+
|
9
|
+
# Mac OS X
|
10
|
+
# firefox: '/Applications/Firefox.app/Contents/MacOS/firefox-bin'
|
11
|
+
safari: '/Applications/Safari.app/Contents/MacOS/Safari'
|
12
|
+
|
13
|
+
# Unix
|
14
|
+
# ?
|
15
|
+
# ?
|
@@ -0,0 +1,62 @@
|
|
1
|
+
/* Jshoulda, version 0.0.1
|
2
|
+
* (c) 2008 Choan Galvez
|
3
|
+
*
|
4
|
+
* Jshoulda is freely distributable under
|
5
|
+
* the terms of an MIT-style license.
|
6
|
+
* For details, see the web site: http://jshoulda.scriptia.net
|
7
|
+
*
|
8
|
+
*--------------------------------------------------------------------------*/
|
9
|
+
|
10
|
+
var context, should;
|
11
|
+
(function() {
|
12
|
+
// the test runner
|
13
|
+
var tr;
|
14
|
+
|
15
|
+
function dummy() {
|
16
|
+
};
|
17
|
+
|
18
|
+
function runQueue(queue, name, before, after) {
|
19
|
+
var i, tests;
|
20
|
+
for (i = 0; i < queue.length; i += 1) {
|
21
|
+
tests = queue[i](name, before, after);
|
22
|
+
if (tests)
|
23
|
+
tr.tests.push(tests);
|
24
|
+
}
|
25
|
+
before.pop();
|
26
|
+
after.pop();
|
27
|
+
}
|
28
|
+
|
29
|
+
function makeBatch(fn_a) {
|
30
|
+
var copy = fn_a.slice(0);
|
31
|
+
return function() {
|
32
|
+
for (var i = 0; i < copy.length; i += 1) {
|
33
|
+
copy[i].call(this);
|
34
|
+
}
|
35
|
+
};
|
36
|
+
}
|
37
|
+
|
38
|
+
context = function(name, obj) {
|
39
|
+
obj.before = obj.before || dummy;
|
40
|
+
obj.after = obj.after || dummy;
|
41
|
+
var queue = Array.prototype.slice.call(arguments, 2);
|
42
|
+
var beforeQueue;
|
43
|
+
var afterQueue;
|
44
|
+
tr = tr || new JsUnitTest.Unit.Runner({}, {testLog: 'testlog'});
|
45
|
+
return function(outerName, before, after) {
|
46
|
+
beforeQueue = before ? before.push(obj.before) && before : [obj.before];
|
47
|
+
afterQueue = after ? after.push(obj.after) && after : [obj.after];
|
48
|
+
runQueue(queue, [outerName, name].join(' '), beforeQueue, afterQueue);
|
49
|
+
return false; // do not add to the tests queue
|
50
|
+
};
|
51
|
+
};
|
52
|
+
|
53
|
+
should = function(name, fn) {
|
54
|
+
return function(prefix, before, after) {
|
55
|
+
var beforeBatch = makeBatch(before);
|
56
|
+
var afterBatch = makeBatch(after);
|
57
|
+
return new JsUnitTest.Unit.Testcase([prefix, name].join(' should '), fn, beforeBatch, afterBatch);
|
58
|
+
};
|
59
|
+
};
|
60
|
+
|
61
|
+
|
62
|
+
})();
|
@@ -0,0 +1,72 @@
|
|
1
|
+
/* Jshoulda, version 0.0.2
|
2
|
+
* (c) 2008 Choan Galvez
|
3
|
+
*
|
4
|
+
* Jshoulda is freely distributable under
|
5
|
+
* the terms of an MIT-style license.
|
6
|
+
* For details, see the web site: http://jshoulda.scriptia.net
|
7
|
+
*
|
8
|
+
*--------------------------------------------------------------------------*/
|
9
|
+
|
10
|
+
var context, should;
|
11
|
+
(function() {
|
12
|
+
// the test runner
|
13
|
+
var tr;
|
14
|
+
|
15
|
+
function dummy() {
|
16
|
+
};
|
17
|
+
|
18
|
+
function runQueue(queue, name, before, after) {
|
19
|
+
var i, tests;
|
20
|
+
for (i = 0; i < queue.length; i += 1) {
|
21
|
+
tests = queue[i](name, before, after);
|
22
|
+
if (tests)
|
23
|
+
tr.tests.push(tests);
|
24
|
+
}
|
25
|
+
before.pop();
|
26
|
+
after.pop();
|
27
|
+
}
|
28
|
+
|
29
|
+
function makeBatch(fn_a) {
|
30
|
+
var copy = fn_a.slice(0);
|
31
|
+
return function() {
|
32
|
+
for (var i = 0; i < copy.length; i += 1) {
|
33
|
+
copy[i].call(this);
|
34
|
+
}
|
35
|
+
};
|
36
|
+
}
|
37
|
+
|
38
|
+
context = function(name, obj) {
|
39
|
+
obj.before = obj.setup || obj.before || dummy;
|
40
|
+
obj.after = obj.teardown || obj.after || dummy;
|
41
|
+
var queue = Array.prototype.slice.call(arguments, 2);
|
42
|
+
var beforeQueue;
|
43
|
+
var afterQueue;
|
44
|
+
return function(outerName, before, after) {
|
45
|
+
// the root context gets no outerName or a configuration object
|
46
|
+
// as its first argument
|
47
|
+
var prefix = outerName;
|
48
|
+
var is_root = !!(outerName == undefined || typeof outerName == 'object');
|
49
|
+
if (is_root) {
|
50
|
+
tr = new JsUnitTest.Unit.Runner({}, outerName || {});
|
51
|
+
prefix = '';
|
52
|
+
}
|
53
|
+
beforeQueue = before ? before.push(obj.before) && before : [obj.before];
|
54
|
+
afterQueue = after ? after.push(obj.after) && after : [obj.after];
|
55
|
+
runQueue(queue, [prefix, name].join(' '), beforeQueue, afterQueue);
|
56
|
+
if (is_root) {
|
57
|
+
return tr;
|
58
|
+
}
|
59
|
+
return false; // do not add to the tests queue
|
60
|
+
};
|
61
|
+
};
|
62
|
+
|
63
|
+
should = function(name, fn) {
|
64
|
+
return function(prefix, before, after) {
|
65
|
+
var beforeBatch = makeBatch(before);
|
66
|
+
var afterBatch = makeBatch(after);
|
67
|
+
return new Test.Unit.Testcase([prefix, name].join(' should '), fn, beforeBatch, afterBatch);
|
68
|
+
};
|
69
|
+
};
|
70
|
+
|
71
|
+
|
72
|
+
})();
|
@@ -0,0 +1,72 @@
|
|
1
|
+
/* jShoulda, version 0.0.3
|
2
|
+
* (c) 2008 Choan Galvez
|
3
|
+
*
|
4
|
+
* jShoulda is freely distributable under
|
5
|
+
* the terms of an MIT-style license.
|
6
|
+
* For details, see the web site: http://jshoulda.scriptia.net
|
7
|
+
*
|
8
|
+
*--------------------------------------------------------------------------*/
|
9
|
+
|
10
|
+
var context, should;
|
11
|
+
(function() {
|
12
|
+
// the test runner
|
13
|
+
var tr;
|
14
|
+
|
15
|
+
function dummy() {
|
16
|
+
};
|
17
|
+
|
18
|
+
function runQueue(queue, name, before, after) {
|
19
|
+
var i, tests;
|
20
|
+
for (i = 0; i < queue.length; i += 1) {
|
21
|
+
tests = queue[i](name, before, after);
|
22
|
+
if (tests)
|
23
|
+
tr.tests.push(tests);
|
24
|
+
}
|
25
|
+
before.pop();
|
26
|
+
after.pop();
|
27
|
+
}
|
28
|
+
|
29
|
+
function makeBatch(fn_a) {
|
30
|
+
var copy = fn_a.slice(0);
|
31
|
+
return function() {
|
32
|
+
for (var i = 0; i < copy.length; i += 1) {
|
33
|
+
copy[i].call(this);
|
34
|
+
}
|
35
|
+
};
|
36
|
+
}
|
37
|
+
|
38
|
+
context = function(name, obj) {
|
39
|
+
obj.before = obj.setup || obj.before || dummy;
|
40
|
+
obj.after = obj.teardown || obj.after || dummy;
|
41
|
+
var queue = Array.prototype.slice.call(arguments, 2);
|
42
|
+
var beforeQueue;
|
43
|
+
var afterQueue;
|
44
|
+
return function(outerName, before, after) {
|
45
|
+
// the root context gets no outerName or a configuration object
|
46
|
+
// as its first argument
|
47
|
+
var prefix = outerName;
|
48
|
+
var is_root = !!(outerName == undefined || typeof outerName == 'object');
|
49
|
+
if (is_root) {
|
50
|
+
tr = new Test.Unit.Runner({}, outerName || {});
|
51
|
+
prefix = '';
|
52
|
+
}
|
53
|
+
beforeQueue = before ? before.push(obj.before) && before : [obj.before];
|
54
|
+
afterQueue = after ? after.push(obj.after) && after : [obj.after];
|
55
|
+
runQueue(queue, [prefix, name].join(' '), beforeQueue, afterQueue);
|
56
|
+
if (is_root) {
|
57
|
+
return tr;
|
58
|
+
}
|
59
|
+
return false; // do not add to the tests queue
|
60
|
+
};
|
61
|
+
};
|
62
|
+
|
63
|
+
should = function(name, fn) {
|
64
|
+
return function(prefix, before, after) {
|
65
|
+
var beforeBatch = makeBatch(before);
|
66
|
+
var afterBatch = makeBatch(after);
|
67
|
+
return new Test.Unit.Testcase([prefix, name].join(' should '), fn, beforeBatch, afterBatch);
|
68
|
+
};
|
69
|
+
};
|
70
|
+
|
71
|
+
|
72
|
+
})();
|
@@ -0,0 +1,74 @@
|
|
1
|
+
/* jShoulda, version 1.0.1
|
2
|
+
* (c) 2008 Choan Galvez
|
3
|
+
*
|
4
|
+
* jShoulda is freely distributable under
|
5
|
+
* the terms of an MIT-style license.
|
6
|
+
* For details, see the web site: http://jshoulda.scriptia.net
|
7
|
+
*
|
8
|
+
*--------------------------------------------------------------------------*/
|
9
|
+
|
10
|
+
var context, should;
|
11
|
+
(function() {
|
12
|
+
// the test runner
|
13
|
+
var tr;
|
14
|
+
|
15
|
+
function dummy() {
|
16
|
+
};
|
17
|
+
|
18
|
+
function runQueue(queue, name, before, after) {
|
19
|
+
var i, tests;
|
20
|
+
for (i = 0; i < queue.length; i += 1) {
|
21
|
+
tests = queue[i](name, before, after);
|
22
|
+
if (tests)
|
23
|
+
tr.tests.push(tests);
|
24
|
+
}
|
25
|
+
before.pop();
|
26
|
+
after.pop();
|
27
|
+
}
|
28
|
+
|
29
|
+
function makeBatch(fn_a) {
|
30
|
+
var copy = fn_a.slice(0);
|
31
|
+
return function() {
|
32
|
+
for (var i = 0; i < copy.length; i += 1) {
|
33
|
+
copy[i].call(this);
|
34
|
+
}
|
35
|
+
};
|
36
|
+
}
|
37
|
+
|
38
|
+
context = function(name, obj) {
|
39
|
+
obj.before = obj.setup || obj.before || dummy;
|
40
|
+
obj.after = obj.teardown || obj.after || dummy;
|
41
|
+
var queue = Array.prototype.slice.call(arguments, 2);
|
42
|
+
var beforeQueue;
|
43
|
+
var afterQueue;
|
44
|
+
return function(outerName, before, after) {
|
45
|
+
// the root context gets no outerName or a configuration object
|
46
|
+
// as its first argument
|
47
|
+
var prefix = outerName;
|
48
|
+
var is_root = !!(outerName == undefined || typeof outerName == 'object');
|
49
|
+
if (is_root) {
|
50
|
+
tr = new Test.Unit.Runner({}, outerName || {});
|
51
|
+
prefix = '';
|
52
|
+
}
|
53
|
+
beforeQueue = before ? before.push(obj.before) && before : [obj.before];
|
54
|
+
afterQueue = after ? after.push(obj.after) && after : [obj.after];
|
55
|
+
runQueue(queue, [prefix, name].join(' '), beforeQueue, afterQueue);
|
56
|
+
if (is_root) {
|
57
|
+
return tr;
|
58
|
+
}
|
59
|
+
return false; // do not add to the tests queue
|
60
|
+
};
|
61
|
+
};
|
62
|
+
|
63
|
+
should = function(name, fn) {
|
64
|
+
return function(prefix, before, after) {
|
65
|
+
var beforeBatch = makeBatch(before);
|
66
|
+
var afterBatch = makeBatch(after);
|
67
|
+
return new Test.Unit.Testcase([prefix, name].join(' ' + should.connector + ' '), fn, beforeBatch, afterBatch);
|
68
|
+
};
|
69
|
+
};
|
70
|
+
|
71
|
+
should.connector = 'should';
|
72
|
+
|
73
|
+
|
74
|
+
})();
|
@@ -0,0 +1,72 @@
|
|
1
|
+
/* jShoulda, version 1.0
|
2
|
+
* (c) 2008 Choan Galvez
|
3
|
+
*
|
4
|
+
* jShoulda is freely distributable under
|
5
|
+
* the terms of an MIT-style license.
|
6
|
+
* For details, see the web site: http://jshoulda.scriptia.net
|
7
|
+
*
|
8
|
+
*--------------------------------------------------------------------------*/
|
9
|
+
|
10
|
+
var context, should;
|
11
|
+
(function() {
|
12
|
+
// the test runner
|
13
|
+
var tr;
|
14
|
+
|
15
|
+
function dummy() {
|
16
|
+
};
|
17
|
+
|
18
|
+
function runQueue(queue, name, before, after) {
|
19
|
+
var i, tests;
|
20
|
+
for (i = 0; i < queue.length; i += 1) {
|
21
|
+
tests = queue[i](name, before, after);
|
22
|
+
if (tests)
|
23
|
+
tr.tests.push(tests);
|
24
|
+
}
|
25
|
+
before.pop();
|
26
|
+
after.pop();
|
27
|
+
}
|
28
|
+
|
29
|
+
function makeBatch(fn_a) {
|
30
|
+
var copy = fn_a.slice(0);
|
31
|
+
return function() {
|
32
|
+
for (var i = 0; i < copy.length; i += 1) {
|
33
|
+
copy[i].call(this);
|
34
|
+
}
|
35
|
+
};
|
36
|
+
}
|
37
|
+
|
38
|
+
context = function(name, obj) {
|
39
|
+
obj.before = obj.setup || obj.before || dummy;
|
40
|
+
obj.after = obj.teardown || obj.after || dummy;
|
41
|
+
var queue = Array.prototype.slice.call(arguments, 2);
|
42
|
+
var beforeQueue;
|
43
|
+
var afterQueue;
|
44
|
+
return function(outerName, before, after) {
|
45
|
+
// the root context gets no outerName or a configuration object
|
46
|
+
// as its first argument
|
47
|
+
var prefix = outerName;
|
48
|
+
var is_root = !!(outerName == undefined || typeof outerName == 'object');
|
49
|
+
if (is_root) {
|
50
|
+
tr = new Test.Unit.Runner({}, outerName || {});
|
51
|
+
prefix = '';
|
52
|
+
}
|
53
|
+
beforeQueue = before ? before.push(obj.before) && before : [obj.before];
|
54
|
+
afterQueue = after ? after.push(obj.after) && after : [obj.after];
|
55
|
+
runQueue(queue, [prefix, name].join(' '), beforeQueue, afterQueue);
|
56
|
+
if (is_root) {
|
57
|
+
return tr;
|
58
|
+
}
|
59
|
+
return false; // do not add to the tests queue
|
60
|
+
};
|
61
|
+
};
|
62
|
+
|
63
|
+
should = function(name, fn) {
|
64
|
+
return function(prefix, before, after) {
|
65
|
+
var beforeBatch = makeBatch(before);
|
66
|
+
var afterBatch = makeBatch(after);
|
67
|
+
return new Test.Unit.Testcase([prefix, name].join(' should '), fn, beforeBatch, afterBatch);
|
68
|
+
};
|
69
|
+
};
|
70
|
+
|
71
|
+
|
72
|
+
})();
|