look at that, jquery
This commit is contained in:
parent
230034ed16
commit
e5dd9634a8
2
.gitignore
vendored
2
.gitignore
vendored
@ -16,4 +16,4 @@ test/tmp
|
||||
test/version_tmp
|
||||
tmp
|
||||
.tmp
|
||||
|
||||
node_modules/
|
||||
|
@ -8,17 +8,18 @@ module Flowerbox
|
||||
def run(sprockets)
|
||||
super
|
||||
|
||||
file = Tempfile.new("node")
|
||||
file.print template
|
||||
file.close
|
||||
file = File.join(Dir.pwd, ".node-tmp.#{Time.now.to_i}.js")
|
||||
File.open(file, 'wb') { |fh| fh.print template.tap { |o| puts o } }
|
||||
|
||||
server.start
|
||||
|
||||
system %{node #{file.path}}
|
||||
system %{node #{file}}
|
||||
|
||||
server.stop
|
||||
|
||||
$?.exitstatus
|
||||
ensure
|
||||
File.unlink(file) if file
|
||||
end
|
||||
|
||||
def template
|
||||
@ -27,18 +28,21 @@ module Flowerbox
|
||||
<<-JS
|
||||
var fs = require('fs'),
|
||||
vm = require('vm'),
|
||||
http = require('http');
|
||||
http = require('http'),
|
||||
jsdom = require('jsdom');
|
||||
|
||||
// expand the sandbox a bit
|
||||
var context = function() {};
|
||||
context.window = true;
|
||||
for (method in global) { context[method] = global[method]; }
|
||||
|
||||
jsdom.env(
|
||||
"<html><head><title></title></head><body></body></html>", [], function(errors, window) {
|
||||
context.window = window;
|
||||
|
||||
var files = #{sprockets.files.to_json};
|
||||
var fileRunner = function() {
|
||||
if (files.length > 0) {
|
||||
var file = files.shift();
|
||||
console.log(file);
|
||||
|
||||
var options = {
|
||||
host: "localhost",
|
||||
@ -56,6 +60,11 @@ var fileRunner = function() {
|
||||
|
||||
response.on('end', function() {
|
||||
vm.runInNewContext(data, context, file);
|
||||
|
||||
for (thing in window) {
|
||||
if (!context[thing]) { context[thing] = window[thing] }
|
||||
}
|
||||
|
||||
fileRunner();
|
||||
});
|
||||
});
|
||||
@ -66,6 +75,7 @@ var fileRunner = function() {
|
||||
}
|
||||
};
|
||||
fileRunner();
|
||||
});
|
||||
JS
|
||||
end
|
||||
end
|
||||
|
@ -1,10 +1,10 @@
|
||||
Flowerbox.configure do |c|
|
||||
c.test_with :jasmine
|
||||
c.run_with :selenium
|
||||
c.run_with :node
|
||||
|
||||
c.spec_patterns << "*_spec.*"
|
||||
c.spec_patterns << "**/*_spec.*"
|
||||
|
||||
c.test_environment.reporters << "SimpleSeleniumReporter"
|
||||
c.test_environment.reporters << "SimpleNodeReporter"
|
||||
end
|
||||
|
||||
|
@ -1,5 +1,9 @@
|
||||
describe("cats", function() {
|
||||
it("should hiss", function() {
|
||||
$("body").append("<div /");
|
||||
|
||||
console.log($('body').html())
|
||||
|
||||
expect("hiss").toEqual("hiss");
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user