Commit 963d1a3b 963d1a3b10cd5cf10f467bbdc98bdaf9ba7e4eb6 by Nicolas Perriault

added casper.cli proxy property for phantom.casperArgs; updated samples

1 parent cbb88484
...@@ -64,9 +64,9 @@ ...@@ -64,9 +64,9 @@
64 timeout: null, 64 timeout: null,
65 verbose: false 65 verbose: false
66 }; 66 };
67 // privates 67 // properties
68 // local properties
69 this.checker = null; 68 this.checker = null;
69 this.cli = phantom.casperArgs;
70 this.colorizer = new phantom.Casper.Colorizer(); 70 this.colorizer = new phantom.Casper.Colorizer();
71 this.currentUrl = 'about:blank'; 71 this.currentUrl = 'about:blank';
72 this.currentHTTPStatus = 200; 72 this.currentHTTPStatus = 200;
......
...@@ -42,7 +42,7 @@ var casper = new phantom.Casper({ ...@@ -42,7 +42,7 @@ var casper = new phantom.Casper({
42 loadImages: false, 42 loadImages: false,
43 loadPlugins: false, 43 loadPlugins: false,
44 logLevel: "debug", 44 logLevel: "debug",
45 verbose: true, 45 verbose: true
46 }); 46 });
47 47
48 casper.start() 48 casper.start()
......
...@@ -26,7 +26,7 @@ phantom.Casper.extend({ ...@@ -26,7 +26,7 @@ phantom.Casper.extend({
26 26
27 var casper = new phantom.Casper({ 27 var casper = new phantom.Casper({
28 verbose: true 28 verbose: true
29 }), terms = phantom.casperArgs.args, scores = [], i = 0; 29 }), terms = casper.cli.args, scores = [], i = 0;
30 30
31 if (terms.length < 2) { 31 if (terms.length < 2) {
32 casper.echo('Usage: casperjs googlematch.js term1, term2 [, term3]...').exit(); 32 casper.echo('Usage: casperjs googlematch.js term1, term2 [, term3]...').exit();
...@@ -54,7 +54,7 @@ casper.run(function(self) { ...@@ -54,7 +54,7 @@ casper.run(function(self) {
54 return a.score - b.score; 54 return a.score - b.score;
55 }); 55 });
56 var winner = scores[scores.length - 1]; 56 var winner = scores[scores.length - 1];
57 self.echo('winner is "' + winner.term + '" with ' + winner.score + ' results') 57 self.echo('winner is "' + winner.term + '" with ' + winner.score + ' results');
58 self.exit(); 58 self.exit();
59 }); 59 });
60 60
......
...@@ -12,7 +12,7 @@ links = [] ...@@ -12,7 +12,7 @@ links = []
12 casper = new phantom.Casper 12 casper = new phantom.Casper
13 13
14 casper.start 'http://google.com', -> 14 casper.start 'http://google.com', ->
15 @fill 'form[name=f]', q: phantom.args.join(' '), true 15 @fill 'form[name=f]', q: casper.cli.args.join(' '), true
16 @click 'input[value="Google Search"]' 16 @click 'input[value="Google Search"]'
17 17
18 casper.then -> 18 casper.then ->
......
...@@ -29,7 +29,7 @@ var links = [ ...@@ -29,7 +29,7 @@ var links = [
29 'http://cdiscount.fr/' 29 'http://cdiscount.fr/'
30 ]; 30 ];
31 31
32 casper.echo('Testing with timeout=' + timeout); 32 casper.echo('Testing with timeout=' + timeout + 'ms.');
33 33
34 casper.start(); 34 casper.start();
35 35
......
...@@ -25,9 +25,13 @@ phantom.Casper.extend({ ...@@ -25,9 +25,13 @@ phantom.Casper.extend({
25 25
26 (function(casper) { 26 (function(casper) {
27 var tests = []; 27 var tests = [];
28 if (phantom.casperArgs.args.length > 2 && fs.isFile(phantom.casperArgs.args[2])) { 28 if (casper.cli.args.length) {
29 tests = [phantom.casperArgs.args[2]]; 29 tests = casper.cli.args.filter(function(path) {
30 } else { 30 return fs.isFile(path) || fs.isDirectory(path);
31 });
32 }
33 if (!tests.length) {
34 // default test suite is casperjs' one
31 tests = [fs.absolute(fs.pathJoin(phantom.casperPath, 'tests', 'suites'))]; 35 tests = [fs.absolute(fs.pathJoin(phantom.casperPath, 'tests', 'suites'))];
32 } 36 }
33 casper.test.runSuites.apply(casper.test, tests); 37 casper.test.runSuites.apply(casper.test, tests);
......