Skip to content

Commit

Permalink
Keeping the Javascript libraries in the plugin.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lawrence Karnowski committed Oct 31, 2008
1 parent 85fc75f commit f22c87d
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 12 deletions.
9 changes: 0 additions & 9 deletions generators/javascript_testing/templates/config.js

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ Expectation = (function() {
});
};

extend(Array, Date, Function, Number, RegExp, String);
extend(Array, Boolean, Date, Function, Number, RegExp, String);
Class.create = Class.create.wrap(function() {
var args = $A(arguments), proceed = args.shift(), klass = proceed.apply(Class, args);
extend(klass);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* Allows prototype to run headless in Rhino. */
Event.extend = (function() {
var methods = Object.keys(Event.Methods).inject({ }, function(m, name) {
m[name] = Event.Methods[name].methodize();
Expand Down
30 changes: 30 additions & 0 deletions lib/test_runner.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// NOTE: This script expects to be ran from the #{RAILS_ROOT}/test/javascript directory!

if(arguments.length == 0) {
print("Usage: test_runner.js /test/javascript/spec_file.js");
quit(1);
}

function require(file) {
load(file);
}

spec_file = arguments[0];
fixture = "html/" + spec_file.replace(/^spec_(.*?)\.js$/, "$1.html");
print("Running " + spec_file + " with fixture '" + fixture + "'...");

RAILS_ROOT_PREFIX = "../../";
PLUGIN_PREFIX = RAILS_ROOT_PREFIX + "/vendor/plugins/javascript_testing/";

load(PLUGIN_PREFIX + "lib/env.js");
window.location = fixture;
load(RAILS_ROOT_PREFIX + "public/javascripts/prototype.js");
load(PLUGIN_PREFIX + "lib/prototypeForJsspec.js");
load(PLUGIN_PREFIX + "lib/jsspec.js");
load(PLUGIN_PREFIX + "lib/consoleReportForRake.js");

// load("test_helper.js")
load(spec_file);

Specs.report = "ConsoleReport";
Specs.run();
7 changes: 5 additions & 2 deletions tasks/javascript_testing_tasks.rake
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
namespace :test do
desc "Runs all the JSSpec tests and collects the results"
task :javascript do
plugin_prefix = "#{RAILS_ROOT}/vendor/plugins/javascript_testing"
test_runner_command = "java -jar #{plugin_prefix}/lib/js.jar #{plugin_prefix}/lib/test_runner.js"

Dir.chdir("test/javascripts") do
all_fine = true
if ENV["TEST"]
all_fine = false unless system("java -jar #{RAILS_ROOT}/vendor/plugins/javascript_testing/lib/js.jar #{ENV["TEST"]}")
all_fine = false unless system("#{test_runner_command} #{ENV["TEST"]}")
else
Dir.glob("spec*.js").each do |file|
all_fine = false unless system("java -jar #{RAILS_ROOT}/vendor/plugins/javascript_testing/lib/js.jar #{file}")
all_fine = false unless system("#{test_runner_command} #{file}")
end
end
raise "JSSpec test failures" unless all_fine
Expand Down

0 comments on commit f22c87d

Please sign in to comment.