nibjs 1.0.0
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.
- data/CHANGELOG.md +5 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +45 -0
- data/LICENCE.js +7 -0
- data/LICENCE.md +22 -0
- data/Manifest.txt +16 -0
- data/README.md +64 -0
- data/Rakefile +53 -0
- data/bin/nibjs +4 -0
- data/lib/nibjs/loader.rb +2 -0
- data/lib/nibjs/main.rb +288 -0
- data/lib/nibjs/version.rb +14 -0
- data/lib/nibjs.rb +9 -0
- data/nibjs.gemspec +194 -0
- data/nibjs.noespec +41 -0
- data/src/nibjs.coffee +124 -0
- data/tasks/debug_mail.rake +78 -0
- data/tasks/debug_mail.txt +13 -0
- data/tasks/dist.rake +14 -0
- data/tasks/gem.rake +68 -0
- data/tasks/test.rake +72 -0
- data/tasks/yard.rake +51 -0
- data/test/command/header.js +1 -0
- data/test/command/nibjs_spec.rb +52 -0
- data/test/command/run.rb +3 -0
- data/test/command/sc_coffee_1.exp +31 -0
- data/test/command/sc_coffee_2.exp +26 -0
- data/test/command/sc_coffee_3.exp +25 -0
- data/test/command/sc_coffee_4.exp +26 -0
- data/test/command/sc_coffee_5.exp +24 -0
- data/test/command/sc_common_0.exp +31 -0
- data/test/command/sc_common_1.exp +31 -0
- data/test/command/sc_common_2.exp +32 -0
- data/test/command/sc_common_3.exp +32 -0
- data/test/command/sc_common_4.exp +1 -0
- data/test/command/sc_common_5.exp +1 -0
- data/test/command/scenarios.rb +73 -0
- data/test/fixture.coffee/app.coffee +6 -0
- data/test/fixture.coffee/dependent.coffee +8 -0
- data/test/fixture.coffee/index.coffee +3 -0
- data/test/fixture.js/app.js +9 -0
- data/test/fixture.js/dependent.js +10 -0
- data/test/fixture.js/index.js +3 -0
- data/test/fixture.min.js +28 -0
- data/test/integration/index.html +42 -0
- data/test/integration/integration_test.coffee +29 -0
- data/test/integration/integration_test.js +34 -0
- data/test/integration/integration_test.rb +37 -0
- data/test/integration/jquery-1.4.4.min.js +167 -0
- data/test/jasmine/nibjs_spec.coffee +31 -0
- data/test/jasmine/run.coffee +14 -0
- data/test/nibjs.js +74 -0
- metadata +325 -0
@@ -0,0 +1,52 @@
|
|
1
|
+
require File.expand_path('../scenarios', __FILE__)
|
2
|
+
describe "nibjs command" do
|
3
|
+
|
4
|
+
def nibjs_real(*args)
|
5
|
+
nibjs = File.expand_path('../../../bin/nibjs', __FILE__)
|
6
|
+
`#{nibjs} #{args.flatten.join(' ')}`
|
7
|
+
end
|
8
|
+
|
9
|
+
def nibjs(*args)
|
10
|
+
require File.expand_path('../../../lib/nibjs/main', __FILE__)
|
11
|
+
command = NibJS::Main.new
|
12
|
+
command.output = []
|
13
|
+
command.run(args.flatten)
|
14
|
+
command.output.join('')
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should have a --version' do
|
18
|
+
x = nibjs_real %w{--version}
|
19
|
+
x.should =~ /(c)/
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should have a --help' do
|
23
|
+
x = nibjs_real %w{--help}
|
24
|
+
x.should =~ /DESCRIPTION/
|
25
|
+
end
|
26
|
+
|
27
|
+
NibJS::Scenarios.new.common_tests_with_index('.js') do |options, i|
|
28
|
+
|
29
|
+
it "should behave as expected on #{i}" do
|
30
|
+
nibjs(options).should == File.read(File.expand_path("../#{i}.exp", __FILE__))
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
NibJS::Scenarios.new.common_tests_with_index('.coffee') do |options, i|
|
36
|
+
|
37
|
+
it "should behave as expected on #{i}" do
|
38
|
+
opts = ["--coffee"] + options
|
39
|
+
nibjs(opts).should == File.read(File.expand_path("../#{i}.exp", __FILE__))
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
NibJS::Scenarios.new.coffee_tests_with_index do |options, i|
|
45
|
+
|
46
|
+
it "should behave as expected on #{i}" do
|
47
|
+
nibjs(options).should == File.read(File.expand_path("../#{i}.exp", __FILE__))
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
data/test/command/run.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
NibJS.define('FixtureApp', function(nibjs) {
|
2
|
+
nibjs.register('./app', function(exports, require) {
|
3
|
+
var App;
|
4
|
+
exports.App = App = (function() {
|
5
|
+
function App() {}
|
6
|
+
App.prototype.say_hello = function() {
|
7
|
+
return "Hello from App";
|
8
|
+
};
|
9
|
+
return App;
|
10
|
+
})();
|
11
|
+
return exports;
|
12
|
+
});
|
13
|
+
nibjs.register('./dependent', function(exports, require) {
|
14
|
+
var App, Dependent;
|
15
|
+
App = require('./app').App;
|
16
|
+
exports.Dependent = Dependent = (function() {
|
17
|
+
function Dependent() {}
|
18
|
+
Dependent.prototype.say_hello = function() {
|
19
|
+
return "Hello from Dependent";
|
20
|
+
};
|
21
|
+
return Dependent;
|
22
|
+
})();
|
23
|
+
return exports;
|
24
|
+
});
|
25
|
+
nibjs.register('./index', function(exports, require) {
|
26
|
+
exports.App = require('./app').App;
|
27
|
+
exports.Dependent = require('./dependent').Dependent;
|
28
|
+
return exports;
|
29
|
+
});
|
30
|
+
return nibjs.require('./index');
|
31
|
+
});
|
@@ -0,0 +1,26 @@
|
|
1
|
+
NibJS.define('FixtureApp', function(nibjs) {
|
2
|
+
nibjs.register('./index', function(exports, require) {
|
3
|
+
var App, Dependent;
|
4
|
+
exports.App = App = (function() {
|
5
|
+
function App() {}
|
6
|
+
App.prototype.say_hello = function() {
|
7
|
+
return "Hello from App";
|
8
|
+
};
|
9
|
+
return App;
|
10
|
+
})();
|
11
|
+
return exports;
|
12
|
+
App = require('./app').App;
|
13
|
+
exports.Dependent = Dependent = (function() {
|
14
|
+
function Dependent() {}
|
15
|
+
Dependent.prototype.say_hello = function() {
|
16
|
+
return "Hello from Dependent";
|
17
|
+
};
|
18
|
+
return Dependent;
|
19
|
+
})();
|
20
|
+
return exports;
|
21
|
+
exports.App = require('./app').App;
|
22
|
+
exports.Dependent = require('./dependent').Dependent;
|
23
|
+
return exports;
|
24
|
+
});
|
25
|
+
return nibjs.require('./index');
|
26
|
+
});
|
@@ -0,0 +1,25 @@
|
|
1
|
+
NibJS.define 'FixtureApp', (nibjs)->
|
2
|
+
nibjs.register './app', (exports, require)->
|
3
|
+
exports.App = class App
|
4
|
+
|
5
|
+
say_hello: ->
|
6
|
+
"Hello from App"
|
7
|
+
|
8
|
+
return exports
|
9
|
+
|
10
|
+
nibjs.register './dependent', (exports, require)->
|
11
|
+
{App} = require('./app')
|
12
|
+
|
13
|
+
exports.Dependent = class Dependent
|
14
|
+
|
15
|
+
say_hello: ->
|
16
|
+
"Hello from Dependent"
|
17
|
+
|
18
|
+
return exports
|
19
|
+
|
20
|
+
nibjs.register './index', (exports, require)->
|
21
|
+
exports.App = require('./app').App
|
22
|
+
exports.Dependent = require('./dependent').Dependent
|
23
|
+
return exports
|
24
|
+
|
25
|
+
nibjs.require './index'
|
@@ -0,0 +1,26 @@
|
|
1
|
+
NibJS.define 'FixtureApp', (nibjs)->
|
2
|
+
nibjs.register './app', (exports, require)->
|
3
|
+
exports.App = class App
|
4
|
+
|
5
|
+
say_hello: ->
|
6
|
+
"Hello from App"
|
7
|
+
|
8
|
+
return exports
|
9
|
+
|
10
|
+
nibjs.register './dependent', (exports, require)->
|
11
|
+
{App} = require('./app')
|
12
|
+
|
13
|
+
exports.Dependent = class Dependent
|
14
|
+
|
15
|
+
say_hello: ->
|
16
|
+
"Hello from Dependent"
|
17
|
+
|
18
|
+
return exports
|
19
|
+
|
20
|
+
nibjs.register './index', (exports, require)->
|
21
|
+
exports.App = require('./app').App
|
22
|
+
exports.Dependent = require('./dependent').Dependent
|
23
|
+
return exports
|
24
|
+
|
25
|
+
nibjs.require './index'
|
26
|
+
FixtureApp = NibJS.require 'FixtureApp'
|
@@ -0,0 +1,24 @@
|
|
1
|
+
NibJS.define 'FixtureApp', (nibjs)->
|
2
|
+
nibjs.register './index', (exports, require)->
|
3
|
+
exports.App = class App
|
4
|
+
|
5
|
+
say_hello: ->
|
6
|
+
"Hello from App"
|
7
|
+
|
8
|
+
return exports
|
9
|
+
|
10
|
+
{App} = require('./app')
|
11
|
+
|
12
|
+
exports.Dependent = class Dependent
|
13
|
+
|
14
|
+
say_hello: ->
|
15
|
+
"Hello from Dependent"
|
16
|
+
|
17
|
+
return exports
|
18
|
+
|
19
|
+
exports.App = require('./app').App
|
20
|
+
exports.Dependent = require('./dependent').Dependent
|
21
|
+
return exports
|
22
|
+
|
23
|
+
nibjs.require './index'
|
24
|
+
FixtureApp = NibJS.require 'FixtureApp'
|
@@ -0,0 +1,31 @@
|
|
1
|
+
NibJS.define('fixture', function(nibjs) {
|
2
|
+
nibjs.register('./app', function(exports, require) {
|
3
|
+
var App;
|
4
|
+
exports.App = App = (function() {
|
5
|
+
function App() {}
|
6
|
+
App.prototype.say_hello = function() {
|
7
|
+
return "Hello from App";
|
8
|
+
};
|
9
|
+
return App;
|
10
|
+
})();
|
11
|
+
return exports;
|
12
|
+
});
|
13
|
+
nibjs.register('./dependent', function(exports, require) {
|
14
|
+
var App, Dependent;
|
15
|
+
App = require('./app').App;
|
16
|
+
exports.Dependent = Dependent = (function() {
|
17
|
+
function Dependent() {}
|
18
|
+
Dependent.prototype.say_hello = function() {
|
19
|
+
return "Hello from Dependent";
|
20
|
+
};
|
21
|
+
return Dependent;
|
22
|
+
})();
|
23
|
+
return exports;
|
24
|
+
});
|
25
|
+
nibjs.register('./index', function(exports, require) {
|
26
|
+
exports.App = require('./app').App;
|
27
|
+
exports.Dependent = require('./dependent').Dependent;
|
28
|
+
return exports;
|
29
|
+
});
|
30
|
+
return nibjs.require('./index');
|
31
|
+
});
|
@@ -0,0 +1,31 @@
|
|
1
|
+
NibJS.define('FixtureApp', function(nibjs) {
|
2
|
+
nibjs.register('./app', function(exports, require) {
|
3
|
+
var App;
|
4
|
+
exports.App = App = (function() {
|
5
|
+
function App() {}
|
6
|
+
App.prototype.say_hello = function() {
|
7
|
+
return "Hello from App";
|
8
|
+
};
|
9
|
+
return App;
|
10
|
+
})();
|
11
|
+
return exports;
|
12
|
+
});
|
13
|
+
nibjs.register('./dependent', function(exports, require) {
|
14
|
+
var App, Dependent;
|
15
|
+
App = require('./app').App;
|
16
|
+
exports.Dependent = Dependent = (function() {
|
17
|
+
function Dependent() {}
|
18
|
+
Dependent.prototype.say_hello = function() {
|
19
|
+
return "Hello from Dependent";
|
20
|
+
};
|
21
|
+
return Dependent;
|
22
|
+
})();
|
23
|
+
return exports;
|
24
|
+
});
|
25
|
+
nibjs.register('./index', function(exports, require) {
|
26
|
+
exports.App = require('./app').App;
|
27
|
+
exports.Dependent = require('./dependent').Dependent;
|
28
|
+
return exports;
|
29
|
+
});
|
30
|
+
return nibjs.require('./index');
|
31
|
+
});
|
@@ -0,0 +1,32 @@
|
|
1
|
+
NibJS.define('fixture', function(nibjs) {
|
2
|
+
nibjs.register('./app', function(exports, require) {
|
3
|
+
var App;
|
4
|
+
exports.App = App = (function() {
|
5
|
+
function App() {}
|
6
|
+
App.prototype.say_hello = function() {
|
7
|
+
return "Hello from App";
|
8
|
+
};
|
9
|
+
return App;
|
10
|
+
})();
|
11
|
+
return exports;
|
12
|
+
});
|
13
|
+
nibjs.register('./dependent', function(exports, require) {
|
14
|
+
var App, Dependent;
|
15
|
+
App = require('./app').App;
|
16
|
+
exports.Dependent = Dependent = (function() {
|
17
|
+
function Dependent() {}
|
18
|
+
Dependent.prototype.say_hello = function() {
|
19
|
+
return "Hello from Dependent";
|
20
|
+
};
|
21
|
+
return Dependent;
|
22
|
+
})();
|
23
|
+
return exports;
|
24
|
+
});
|
25
|
+
nibjs.register('./index', function(exports, require) {
|
26
|
+
exports.App = require('./app').App;
|
27
|
+
exports.Dependent = require('./dependent').Dependent;
|
28
|
+
return exports;
|
29
|
+
});
|
30
|
+
return nibjs.require('./index');
|
31
|
+
});
|
32
|
+
var fixture = NibJS.require('fixture');
|
@@ -0,0 +1,32 @@
|
|
1
|
+
NibJS.define('FixtureApp', function(nibjs) {
|
2
|
+
nibjs.register('./app', function(exports, require) {
|
3
|
+
var App;
|
4
|
+
exports.App = App = (function() {
|
5
|
+
function App() {}
|
6
|
+
App.prototype.say_hello = function() {
|
7
|
+
return "Hello from App";
|
8
|
+
};
|
9
|
+
return App;
|
10
|
+
})();
|
11
|
+
return exports;
|
12
|
+
});
|
13
|
+
nibjs.register('./dependent', function(exports, require) {
|
14
|
+
var App, Dependent;
|
15
|
+
App = require('./app').App;
|
16
|
+
exports.Dependent = Dependent = (function() {
|
17
|
+
function Dependent() {}
|
18
|
+
Dependent.prototype.say_hello = function() {
|
19
|
+
return "Hello from Dependent";
|
20
|
+
};
|
21
|
+
return Dependent;
|
22
|
+
})();
|
23
|
+
return exports;
|
24
|
+
});
|
25
|
+
nibjs.register('./index', function(exports, require) {
|
26
|
+
exports.App = require('./app').App;
|
27
|
+
exports.Dependent = require('./dependent').Dependent;
|
28
|
+
return exports;
|
29
|
+
});
|
30
|
+
return nibjs.require('./index');
|
31
|
+
});
|
32
|
+
var FixtureApp = NibJS.require('FixtureApp');
|
@@ -0,0 +1 @@
|
|
1
|
+
NibJS.define("FixtureApp",function(a){a.register("./app",function(a,b){var c;a.App=c=function(){function a(){}a.prototype.say_hello=function(){return"Hello from App"};return a}();return a}),a.register("./dependent",function(a,b){var c,d;c=b("./app").App,a.Dependent=d=function(){function a(){}a.prototype.say_hello=function(){return"Hello from Dependent"};return a}();return a}),a.register("./index",function(a,b){a.App=b("./app").App,a.Dependent=b("./dependent").Dependent;return a});return a.require("./index")});var FixtureApp=NibJS.require("FixtureApp")
|
@@ -0,0 +1 @@
|
|
1
|
+
/* this is a header */NibJS.define("fixture",function(a){a.register("./app",function(a,b){var c;a.App=c=function(){function a(){}a.prototype.say_hello=function(){return"Hello from App"};return a}();return a}),a.register("./dependent",function(a,b){var c,d;c=b("./app").App,a.Dependent=d=function(){function a(){}a.prototype.say_hello=function(){return"Hello from Dependent"};return a}();return a}),a.register("./index",function(a,b){a.App=b("./app").App,a.Dependent=b("./dependent").Dependent;return a});return a.require("./index")})
|
@@ -0,0 +1,73 @@
|
|
1
|
+
module NibJS
|
2
|
+
class Scenarios
|
3
|
+
|
4
|
+
def _(file)
|
5
|
+
File.expand_path("../#{file}", __FILE__)
|
6
|
+
end
|
7
|
+
|
8
|
+
def common_tests_with_index(ext = '.js', &block)
|
9
|
+
(0..100).each{|i|
|
10
|
+
source = _("../fixture#{ext}")
|
11
|
+
name = "sc_common_#{i}"
|
12
|
+
if self.respond_to?(name.to_sym)
|
13
|
+
yield(self.send(name.to_sym, source), name)
|
14
|
+
end
|
15
|
+
}
|
16
|
+
end
|
17
|
+
|
18
|
+
def coffee_tests_with_index(&block)
|
19
|
+
(0..100).each{|i|
|
20
|
+
source = _("../fixture.coffee")
|
21
|
+
name = "sc_coffee_#{i}"
|
22
|
+
if self.respond_to?(name.to_sym)
|
23
|
+
yield(self.send(name.to_sym, source), name)
|
24
|
+
end
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
def sc_common_0(src)
|
29
|
+
[ src ]
|
30
|
+
end
|
31
|
+
|
32
|
+
def sc_common_1(src)
|
33
|
+
[ "--libname=FixtureApp", src ]
|
34
|
+
end
|
35
|
+
|
36
|
+
def sc_common_2(src)
|
37
|
+
[ "--autorequire", src ]
|
38
|
+
end
|
39
|
+
|
40
|
+
def sc_common_3(src)
|
41
|
+
[ "--libname=FixtureApp", "--autorequire", src ]
|
42
|
+
end
|
43
|
+
|
44
|
+
def sc_common_4(src)
|
45
|
+
[ "--libname=FixtureApp", "--autorequire", "--uglify", src ]
|
46
|
+
end
|
47
|
+
|
48
|
+
def sc_common_5(src)
|
49
|
+
[ "--header=#{_('header.js')}", "--uglify", src ]
|
50
|
+
end
|
51
|
+
|
52
|
+
def sc_coffee_1(src)
|
53
|
+
[ "--libname=FixtureApp", "--coffee", src ]
|
54
|
+
end
|
55
|
+
|
56
|
+
def sc_coffee_2(src)
|
57
|
+
[ "--libname=FixtureApp", "--coffee", "--join", src ]
|
58
|
+
end
|
59
|
+
|
60
|
+
def sc_coffee_3(src)
|
61
|
+
[ "--libname=FixtureApp", "--coffee", "--no-coffee-compile", src ]
|
62
|
+
end
|
63
|
+
|
64
|
+
def sc_coffee_4(src)
|
65
|
+
[ "--libname=FixtureApp", "--autorequire", "--coffee", "--no-coffee-compile", src ]
|
66
|
+
end
|
67
|
+
|
68
|
+
def sc_coffee_5(src)
|
69
|
+
[ "--libname=FixtureApp", "--join", "--autorequire", "--coffee", "--no-coffee-compile", src ]
|
70
|
+
end
|
71
|
+
|
72
|
+
end # class Scenarios
|
73
|
+
end # module NibJS
|
data/test/fixture.min.js
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
NibJS.define('fixture', function(nibjs){
|
2
|
+
nibjs.register('./app', function(exports, require){
|
3
|
+
var App;
|
4
|
+
exports.App = App = (function() {
|
5
|
+
function App() {}
|
6
|
+
App.prototype.say_hello = function() {
|
7
|
+
return "Hello from App";
|
8
|
+
};
|
9
|
+
return App;
|
10
|
+
})();
|
11
|
+
});
|
12
|
+
nibjs.register('./dependent', function(exports, require){
|
13
|
+
var App, Dependent;
|
14
|
+
App = require('./app').App;
|
15
|
+
exports.Dependent = Dependent = (function() {
|
16
|
+
function Dependent() {}
|
17
|
+
Dependent.prototype.say_hello = function() {
|
18
|
+
return "Hello from Dependent";
|
19
|
+
};
|
20
|
+
return Dependent;
|
21
|
+
})();
|
22
|
+
});
|
23
|
+
nibjs.register('./index', function(exports, require){
|
24
|
+
exports.App = require('./app').App;
|
25
|
+
exports.Dependent = require('./dependent').Dependent;
|
26
|
+
});
|
27
|
+
return nibjs.require('./index');
|
28
|
+
});
|
@@ -0,0 +1,42 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
|
5
|
+
<title>NibJS - Test Suite</title>
|
6
|
+
<script src="/jquery.js" type="text/javascript"></script>
|
7
|
+
<script src="/nibjs.js" type="text/javascript"></script>
|
8
|
+
<script src="/fixture.js" type="text/javascript"></script>
|
9
|
+
<script src="/integration_test.js" type="text/javascript"></script>
|
10
|
+
<style>
|
11
|
+
body{
|
12
|
+
margin: 50px;
|
13
|
+
font-family: corbel, 'lucida grande', helvetica, sans-serif;
|
14
|
+
width: 600px;
|
15
|
+
margin: auto;
|
16
|
+
}
|
17
|
+
.success {
|
18
|
+
width: 100%;
|
19
|
+
padding: 2px;
|
20
|
+
background: green;
|
21
|
+
color: white;
|
22
|
+
border: 2px solid white;
|
23
|
+
}
|
24
|
+
.error {
|
25
|
+
width: 100%;
|
26
|
+
padding: 2px;
|
27
|
+
background: red;
|
28
|
+
color: white;
|
29
|
+
border: 2px solid white;
|
30
|
+
}
|
31
|
+
#theend {
|
32
|
+
margin-top: 50px;
|
33
|
+
}
|
34
|
+
</style>
|
35
|
+
</head>
|
36
|
+
<body>
|
37
|
+
<div id="results">
|
38
|
+
</div>
|
39
|
+
<div id="theend">
|
40
|
+
</div>
|
41
|
+
</body>
|
42
|
+
</html>
|
@@ -0,0 +1,29 @@
|
|
1
|
+
success = (message)->
|
2
|
+
$('#results').append("<p class='success'>#{message}</p>")
|
3
|
+
|
4
|
+
error = (message)->
|
5
|
+
$('#results').append("<p class='error'>#{message}</p>")
|
6
|
+
|
7
|
+
$.post '/error', (data)->
|
8
|
+
$('#theend').append("<p class='error'>#{data}</p>")
|
9
|
+
|
10
|
+
$(document).ready ->
|
11
|
+
try
|
12
|
+
|
13
|
+
Fix = NibJS.require('fixture')
|
14
|
+
if Fix?
|
15
|
+
success("Fix is correctly loaded and defined!")
|
16
|
+
else
|
17
|
+
error("NibJS.require seems buggy")
|
18
|
+
|
19
|
+
app = new Fix.App()
|
20
|
+
if app.say_hello() is "Hello from App"
|
21
|
+
success("Building an App instance seems working!")
|
22
|
+
else
|
23
|
+
error("Building an App instance has failed")
|
24
|
+
|
25
|
+
$.post '/success', (data)->
|
26
|
+
$('#theend').append("<p class='success'>#{data}</p>")
|
27
|
+
|
28
|
+
catch err
|
29
|
+
error(err.message)
|
@@ -0,0 +1,34 @@
|
|
1
|
+
(function() {
|
2
|
+
var error, success;
|
3
|
+
success = function(message) {
|
4
|
+
return $('#results').append("<p class='success'>" + message + "</p>");
|
5
|
+
};
|
6
|
+
error = function(message) {
|
7
|
+
$('#results').append("<p class='error'>" + message + "</p>");
|
8
|
+
return $.post('/error', function(data) {
|
9
|
+
return $('#theend').append("<p class='error'>" + data + "</p>");
|
10
|
+
});
|
11
|
+
};
|
12
|
+
$(document).ready(function() {
|
13
|
+
var Fix, app;
|
14
|
+
try {
|
15
|
+
Fix = NibJS.require('fixture');
|
16
|
+
if (Fix != null) {
|
17
|
+
success("Fix is correctly loaded and defined!");
|
18
|
+
} else {
|
19
|
+
error("NibJS.require seems buggy");
|
20
|
+
}
|
21
|
+
app = new Fix.App();
|
22
|
+
if (app.say_hello() === "Hello from App") {
|
23
|
+
success("Building an App instance seems working!");
|
24
|
+
} else {
|
25
|
+
error("Building an App instance has failed");
|
26
|
+
}
|
27
|
+
return $.post('/success', function(data) {
|
28
|
+
return $('#theend').append("<p class='success'>" + data + "</p>");
|
29
|
+
});
|
30
|
+
} catch (err) {
|
31
|
+
return error(err.message);
|
32
|
+
}
|
33
|
+
});
|
34
|
+
}).call(this);
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "sinatra/base"
|
3
|
+
class MyApp < Sinatra::Base
|
4
|
+
|
5
|
+
def _(file)
|
6
|
+
File.expand_path("../#{file}", __FILE__)
|
7
|
+
end
|
8
|
+
|
9
|
+
get '/' do
|
10
|
+
send_file _("index.html")
|
11
|
+
end
|
12
|
+
get '/jquery.js' do
|
13
|
+
send_file _('jquery-1.4.4.min.js')
|
14
|
+
end
|
15
|
+
get '/nibjs.js' do
|
16
|
+
send_file _('../nibjs.js')
|
17
|
+
end
|
18
|
+
get '/fixture.js' do
|
19
|
+
send_file _('../fixture.min.js')
|
20
|
+
end
|
21
|
+
get '/integration_test.js' do
|
22
|
+
send_file _('integration_test.js')
|
23
|
+
end
|
24
|
+
post '/success' do
|
25
|
+
puts "Everything seems fine!"
|
26
|
+
body("Everything seems fine!")
|
27
|
+
response.finish
|
28
|
+
Process.kill("TERM", Process.pid)
|
29
|
+
end
|
30
|
+
post '/error' do
|
31
|
+
puts "An error occured!"
|
32
|
+
body("An error occured!")
|
33
|
+
response.finish
|
34
|
+
Process.kill("TERM", Process.pid)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
MyApp.run!
|