Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adding more test coverage

  • Loading branch information...
commit 3fc02aafa8b910e06cb14215faa22ae54fc2595f 1 parent f4ae494
Stephen Cresswell authored
View
18 examples/classic/classic-steps.js
@@ -1,21 +1,21 @@
var steps = new Steps()
.given("that I like repetitive, mechanical test specifications", function() {
- document.write("<li>Yawn</li>");
+ document.write("<li>Mmmm, mechanical</li>");
})
-.when("I use given, when, or then instead of addStep", function() {
- document.write("<li>Stretch</li>");
+.when("I use given, when, or then", function() {
+ document.write("<li>Given, when then baby</li>");
})
-.then("anyone reading the specification will fall asleep", function() {
- document.write("<li>Zzzzz</li>");
+.then("anyone reading the specification will start to doze", function() {
+ document.write("<li>Yawn</li>");
})
-.then("probably fall off their chair", function() {
- document.write("<li>Bump</li>");
+.then("probably fall asleep", function() {
+ document.write("<li>Time for some shut eye</li>");
})
-.then("not wake up", function() {
- document.write("<li>Snore</li>");
+.then("hopefully not snore", function() {
+ document.write("<li>Zzzzzz</li>");
});
View
8 examples/classic/test.html
@@ -6,10 +6,10 @@
new Yadda(steps).yadda().yadda().yadda([
"Given that I like repetitive, mechanical test specifications",
- "When I use given, when, or then instead of addStep",
- "Then anyone reading the specification will fall asleep",
- "And probably fall off their chair",
- "But not wake up"
+ "When I use given, when, or then",
+ "Then anyone reading the specification will start to doze",
+ "And probably fall asleep",
+ "But hopefully not snore"
]);
</script>
</head>
View
31 test/test-scenarios.js
@@ -1,36 +1,49 @@
var yadda = new Yadda(steps);
-test('Developer adds and runs a test step', function() {
+test('Developer runs a test step', function() {
yadda.yadda([
"Given a new Yadda instance",
- "when Dirk adds a new test step, 'Blah blah blah'",
+ "when Dirk adds a test step, 'Blah blah blah'",
"and runs 'Blah blah blah'",
"then 'Blah blah blah' is executed 1 time"
])
});
-test('Developer adds a conflicting literal step', function() {
+test('Developer adds a conflicting literal test step', function() {
yadda.yadda([
"Given a new Yadda instance",
- "when Dirk adds a new test step, 'Blah blah blah'",
+ "when Dirk adds a test step, 'Blah blah blah'",
"then he is prevented from adding a conflicting test step, 'Blah blah blah'"
])
});
-test('Developer adds a conflicting regex step', function() {
+test('Developer adds a conflicting regex test step', function() {
yadda.yadda([
"Given a new Yadda instance",
- "when Dirk adds a new test step, 'Blah (.+) blah'",
+ "when Dirk adds a test step, 'Blah (.+) blah'",
"then he is prevented from adding a conflicting test step, 'Blah (.+) blah'"
])
});
-test('Developer runs an ambiguous step', function() {
+test('Developer attempts to runs a test step with an ambiguous template, where a best match cannot be determined', function() {
yadda.yadda([
"Given a new Yadda instance",
- "when Dirk adds a new test step, 'Blah (.+) blah'",
- "and adds a new test step, 'Blah (.*) blah'",
+ "when Dirk adds a test step, 'Blah (.+) blah'",
+ "and adds another test step, 'Blah (.*) blah'",
"then he is prevented from running an ambiguous test step, 'Blah blah blah'"
])
});
+test('Developer runs a test step with an ambiguous template, where a best match can be determined', function() {
+ yadda.yadda([
+ "Given a new Yadda instance",
+ "when Dirk adds a test step, 'Given pirate (.+) parrot has green feathers'",
+ "and adds another test step, 'Given pirate (.+) old parrot has green feathers'",
+ "and runs 'Given pirate Rob\'s parrot has green feathers'",
+ "then 'Given pirate (.+) parrot has green feathers' is executed 1 time",
+ "but when Dirk runs 'Given pirate Rob\'s old parrot has green feathers' is run'",
+ "then 'Given pirate (.+) old parrot has green feathers' is executed 1 time"
+ ])
+});
+
+// Literals
View
2  test/test-steps.js
@@ -5,7 +5,7 @@ var steps = new Steps()
shared.yadda = new Yadda();
})
-.when("(?:Dirk adds|adds) a (?:new test|test) step, '(.+)'", function(template) {
+.when("(?:Dirk adds|adds) (?:a|another) test step, '(.+)'", function(template) {
shared.executions[template] = 0;
shared.yadda.steps.addStep(template, function() {
shared.executions[template]++;
Please sign in to comment.
Something went wrong with that request. Please try again.