Skip to content

Configuration for continuous integration service #61

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
npm-debug.log
.grunt
14 changes: 14 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
language: node_js
node_js:
- "0.8"
before_install:
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
- sleep 3 # give xvfb some time to start
- "wget http://selenium.googlecode.com/files/selenium-server-standalone-2.31.0.jar"
- "java -jar selenium-server-standalone-2.31.0.jar &"
- sleep 3 # give some time to bind to sockets, etc
before_script:
- npm install -g grunt-cli
- npm install grunt grunt-contrib-jshint grunt-contrib-uglify grunt-webdriver grunt-contrib-connect
script: grunt -v
61 changes: 61 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
module.exports = function(grunt) {
grunt.initConfig({

connect: {
server: {
options: {
port: 9001,
base: '.'
}
}
},

webdriver: {
pathjs: {
options: {
logLevel: 'silent',
browser: 'firefox',
binary: null
},
url: 'http://localhost:9001/tests/path.js.test.html',
tests: ['./tests/spec/pathjsSpec.js']
},
pathjs_min: {
options: {
logLevel: 'silent',
browser: 'firefox',
binary: null
},
url: 'http://localhost:9001/tests/path.min.js.test.html',
tests: ['./tests/spec/pathjsSpec.js']
}
},

uglify: {
my_target: {
files: {
'path.min.js': ['path.js']
}
}
},

jshint: {
options: {
"globals": {
"exports": true,
"buster": true
}
},
all: ['Gruntfile.js', 'path.js', 'tests/spec/**/*.js']
}

});

grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-webdriver');

grunt.registerTask('default', ['jshint', 'uglify', 'connect', 'webdriver']);

};
6 changes: 3 additions & 3 deletions path.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ var Path = {
window.onpopstate = Path.history.popState;
} else {
if(Path.history.fallback){
for(route in Path.routes.defined){
for( var route in Path.routes.defined){
if(route.charAt(0) != "#"){
Path.routes.defined["#"+route] = Path.routes.defined[route];
Path.routes.defined["#"+route].path = "#"+route;
Expand Down Expand Up @@ -105,7 +105,7 @@ var Path = {
}
},
'listen': function () {
var fn = function(){ Path.dispatch(location.hash); }
var fn = function(){ Path.dispatch(location.hash); };

if (location.hash === "") {
if (Path.routes.root !== null) {
Expand Down Expand Up @@ -162,7 +162,7 @@ Path.core.route.prototype = {
},
'partition': function () {
var parts = [], options = [], re = /\(([^}]+?)\)/g, text, i;
while (text = re.exec(this.path)) {
while( !!(text = re.exec(this.path)) ) {
parts.push(text[1]);
}
options.push(this.path.split("(")[0]);
Expand Down
129 changes: 41 additions & 88 deletions tests/path.js.test.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,152 +4,109 @@
<title>PathJS Test</title>
<script type="text/javascript" src="../path.js"></script>
<script type="text/javascript">
var hrefs = [
"#A",
"#B",
"#C",
"#D1",
"#D2",
"#E/params/1/parse",
"#E/params/2/parse",
"#E/params/3/check",
"#F",
"#G",
"#H",
"#H/10",
"#H/10/20"
];
var index = 0;
var timer = null;

function update(str){
var d = document.getElementById("actual");
var d = document.getElementById("actual");
text = d.innerHTML;
d.innerHTML = d.innerHTML + ((text == "") ? "" : "::") + str;
}

function run_route(){
if(index <= hrefs.length){
if(index == hrefs.length){
window.history.go(-1);
} else {
location.hash = hrefs[index];
}
index++;
} else {
clearInterval(timer);

var expected = document.getElementById("expected");
var actual = document.getElementById("actual");
var grade = document.getElementById("grade");
if(expected.innerHTML == actual.innerHTML){
grade.innerHTML = "PASS";
grade.style.color = "#00FF00";
} else {
grade.innerHTML = "FAIL";
grade.style.color = "#FF0000";
}
}
}

function define_routes(){
Path.map("#A").enter(function(){
update("A[enter]");
Path.map("#A").enter(function(){
update("A[enter]");
}).to(function(){
update("A[action]");
update("A[action]");
}).exit(function(){
update("A[exit]");
update("A[exit]");
});

Path.map("#B").to(function(){
update("B[action]");
update("B[action]");
});

Path.map("#B").enter(function(){
update("B[enter]");
update("B[enter]");
})

Path.map("#C").to(function(){
update("C[action]");
update("C[action]");
}).exit(function(){
update("C[exit]");
update("C[exit]");
});

// No map for #D1 or #D2. This checks that our rescue method works, and works multiple times in succession.

// No map for #D1 or #D2. This checks that our rescue method works, and works multiple times in succession.
Path.map("#E/params/:id/parse").to(function(){
update("E[action](parse id=" + this.params['id'] + ")");
update("E[action](parse id=" + this.params['id'] + ")");
});

Path.map("#E/params/:id/parse").enter(function(){
update("E[enter](parse id=" + this.params['id'] + ")");
update("E[enter](parse id=" + this.params['id'] + ")");
});

Path.map("#E/params/:id/check").to(function(){
update("E[action](check id=" + this.params['id'] + ")");
update("E[action](check id=" + this.params['id'] + ")");
});

Path.map("#E/params/:id/check").exit(function(){
update("E[exit](check id=" + this.params['id'] + ")");
update("E[exit](check id=" + this.params['id'] + ")");
});

Path.map("#F").enter(function(){
update("F[enter]");
update("F[enter]");
}).to(function(){
update("F[action]");
update("F[action]");
});

Path.map("#G").enter(function(){
update("G[enter 1]");
update("G[enter 1]");
}).enter(function(){
update("G[enter 2]");
update("G[enter 2]");
}).enter([
function(){
update("G[enter 3]");
},
function(){
update("G[enter 4]");
return false;
}
function(){
update("G[enter 3]");
},
function(){
update("G[enter 4]");
return false;
}
]).to(function(){
update("G[action - NOT HIT]");
update("G[action - NOT HIT]");
});

Path.map("#H(/:id_one)(/:id_two)").to(function(){
var id_one = this.params["id_one"] || "N/A";
var id_two = this.params["id_two"] || "N/A";
update("H(one=" + id_one + ", two=" + id_two + ")");
});
Path.map("#H(/:id_one)(/:id_two)").to(function(){
var id_one = this.params["id_one"] || "N/A";
var id_two = this.params["id_two"] || "N/A";
update("H(one=" + id_one + ", two=" + id_two + ")");
});

Path.rescue(function(){
update("RESCUE");
update("RESCUE");
});

Path.root("#F");
Path.listen();
timer = setInterval(run_route, 500);
}
}
</script>

<style type="text/css">
body {font-family: arial;}
p {width: 600px; text-align: justify;}
table {font-family: courier;}
body {font-family: arial;}
p {width: 600px; text-align: justify;}
table {font-family: courier;}
</style>
</head>
<body onload="define_routes();">
<div id="description">
<h2>Test Suite</h2>
<div id="description">
<h2>Test Suite</h2>
<p>
Path.js uses a very straightforward method of testing. We manually construct
Path.js uses a very straightforward method of testing. We manually construct
a series of method calls that the library should execute under normal working
conditions. We then use JavaScript to simulate the URL changes, and compare
the final result with what the result should actually be. If the end result
is anything but perfect, the test is a failure, and this version of Path.JS
is not suitable for use. The expected test results are as follows:
</p>
<table>
<tr><td><b>Token</b></td> <td><b>Reason</b></td></tr>
<tr><td><b>Token</b></td> <td><b>Reason</b></td></tr>
<tr><td>F[enter]</td> <td>Enter method of F, as it is root</td></tr>
<tr><td>F[action]</td> <td>True action of F, as it is root</td></tr>
<tr><td>A[enter]</td> <td>Enter method of A, as it is looped</td></tr>
Expand All @@ -176,16 +133,12 @@ <h2>Test Suite</h2>
<tr><td>H(one=N/A, two=N/A)</td> <td>Optional parameters with only the require part submitted</td></tr>
<tr><td>H(one=10, two=N/A)</td> <td>Optional parameters with one optional part submitted</td></tr>
<tr><td>H(one=10, two=20)</td> <td>Optional parameters two levels deep</td></tr>
<tr><td>H(one=10, two=N/A)</td> <td>Testing "back" functionality</td></tr>
<tr><td>H(one=10, two=N/A)</td> <td>Testing "back" functionality</td></tr>
</table>
</div><br /><br />
<div id="console">
<h3>Expected</h3>
<div id="expected">F[enter]::F[action]::A[enter]::A[action]::A[exit]::B[enter]::B[action]::C[action]::C[exit]::RESCUE::RESCUE::E[enter](parse id=1)::E[action](parse id=1)::E[enter](parse id=2)::E[action](parse id=2)::E[action](check id=3)::E[exit](check id=3)::F[enter]::F[action]::G[enter 1]::G[enter 2]::G[enter 3]::G[enter 4]::H(one=N/A, two=N/A)::H(one=10, two=N/A)::H(one=10, two=20)::H(one=10, two=N/A)</div>
<h3>Actual</h3>
<div id="actual"></div>
<h3>Grade</h3>
<div id="grade"></div>
</div>
</body>
</html>
Loading