diff --git a/contrib/ruby/run.html b/contrib/ruby/run.html index da2e1dd..db74351 100644 --- a/contrib/ruby/run.html +++ b/contrib/ruby/run.html @@ -10,25 +10,23 @@ <% spec_files.each do |spec_file| %> diff --git a/lib/TrivialReporter.js b/lib/TrivialReporter.js index c236480..396c636 100644 --- a/lib/TrivialReporter.js +++ b/lib/TrivialReporter.js @@ -59,6 +59,22 @@ jasmine.TrivialReporter.prototype.log = function() { console.log.apply(console, arguments); }; +jasmine.TrivialReporter.prototype.getLocation = function() { + return document.location; +}; + +jasmine.TrivialReporter.prototype.specFilter = function(spec) { + var paramMap = {}; + var params = this.getLocation().search.substring(1).split('&'); + for (var i = 0; i < params.length; i++) { + var p = params[i].split('='); + paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]); + } + + if (!paramMap["spec"]) return true; + return spec.getFullName().indexOf(paramMap["spec"]) > -1; +}; + //protect against console.log incidents if (!("console" in window) || !("firebug" in console)) { var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"]; diff --git a/spec/runner.html b/spec/runner.html index 41c87bd..3f68374 100644 --- a/spec/runner.html +++ b/spec/runner.html @@ -37,31 +37,11 @@ jasmine.include('suites/RunnerTest.js', true); jasmine.include('suites/SpecRunningTest.js', true); jasmine.include('suites/SpyTest.js', true); + jasmine.include('suites/TrivialReporterTest.js', true); - +
diff --git a/spec/suites/TrivialReporterTest.js b/spec/suites/TrivialReporterTest.js new file mode 100644 index 0000000..2a1ec7c --- /dev/null +++ b/spec/suites/TrivialReporterTest.js @@ -0,0 +1,19 @@ +describe("TrivialReporter", function() { + function fakeSpec(name) { + return { + getFullName: function() { return name; } + }; + } + + it("should allow for focused spec running", function() { + var trivialReporter = new jasmine.TrivialReporter(); + spyOn(trivialReporter, 'getLocation').andReturn({search: "?spec=run%20this"}); + expect(trivialReporter.specFilter(fakeSpec("run this"))).toBeTruthy(); + }); + + it("should not run specs that don't match the filter", function() { + var trivialReporter = new jasmine.TrivialReporter(); + spyOn(trivialReporter, 'getLocation').andReturn({search: "?spec=run%20this"}); + expect(trivialReporter.specFilter(fakeSpec("not the right spec"))).toBeFalsy(); + }); +}); \ No newline at end of file