From 0bd4a473a717d5ed9b9c07fbdbc5c336beeef4e5 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Tue, 2 Nov 2010 16:23:12 -0700 Subject: adding regular expressions support for binding() DSL --- CHANGELOG.md | 10 +++++++--- src/scenario/dsl.js | 4 +++- test/scenario/dslSpec.js | 6 ++++++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9067d87c..fc9baa3c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,12 +4,16 @@ - binding DSL in Scenario can now match bindings without specifying filters - dsl statements now accept a label argument to make test output more readable (issue #94) - dsl element() statement now implements most of the jQuery API (issue #106) -- file:// URLs are no longer supported for running a scenario. You must use a web server that implements HEAD - new browser() dsl statement for getting info about the emulated browser running the app (issue #109) -- navigateTo() is now browser().navigateTo(). Old code must be updated -- navigating to about:blank is no longer supported. It results in a sandbox error - scenario runner is now compatible with IE8 (issue #93) - scenarior runner checks if URL would return a non-success status code (issue #100) +- binding() DSL now accepts regular expressions + +### Breaking changes +#### Scenario Runner +- navigating to about:blank is no longer supported. It results in a sandbox error +- navigateTo() is now browser().navigateTo(). Old code must be updated +- file:// URLs are no longer supported for running a scenario. You must use a web server that implements HEAD # 0.9.1 repulsion-field (2010-10-26) # diff --git a/src/scenario/dsl.js b/src/scenario/dsl.js index 7974f4ad..28e05724 100644 --- a/src/scenario/dsl.js +++ b/src/scenario/dsl.js @@ -156,7 +156,9 @@ angular.scenario.dsl('using', function() { */ angular.scenario.dsl('binding', function() { function contains(text, value) { - return text && text.indexOf(value) >= 0; + return value instanceof RegExp ? + value.test(text) : + text && text.indexOf(value) >= 0; } return function(name) { return this.addFutureAction("select binding '" + name + "'", function($window, $document, done) { diff --git a/test/scenario/dslSpec.js b/test/scenario/dslSpec.js index 9f7bf085..fd22303e 100644 --- a/test/scenario/dslSpec.js +++ b/test/scenario/dslSpec.js @@ -370,6 +370,12 @@ describe("angular.scenario.dsl", function() { expect($root.futureResult).toEqual('some value'); }); + it('should select binding by regexp', function() { + doc.append('some value'); + $root.dsl.binding(/^foo\..+/); + expect($root.futureResult).toEqual('some value'); + }); + it('should select binding in template by name', function() { doc.append('
foo some baz
'); $root.dsl.binding('bar'); -- cgit v1.2.3