/
index.html
85 lines (70 loc) · 2.45 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Cucumber.js</title>
<link href="example.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="vendor/jquery-1.6.1.min.js"></script>
<script type="text/javascript" src="/cucumber.js"></script>
<script type="text/javascript" src="/example.js"></script>
</head>
<body>
<h1><a href="https://github.com/cucumber/cucumber-js">Cucumber.js</a> demo</h1>
<p>Find more on the <a href="https://github.com/cucumber/cucumber-js">Cucumber.js repository</a>.</p>
<h2>Feature source</h2>
<textarea id="feature">Feature: Simple maths
In order to do maths
As a developer
I want to increment variables
Scenario: easy maths
Given a variable set to 1
When I increment the variable by 1
Then the variable should contain 2
Scenario: much more complex stuff
Given a variable set to 100
When I increment the variable by 6
Then the variable should contain 106</textarea>
<h2>Step definitions</h2>
<textarea id="step-definitions">///// Your World /////
// Provide a custom World constructor. It's optional, a default one is supplied.
this.World = function(callback) {
callback();
};
// Define your World!
this.World.prototype.variable = 0;
this.World.prototype.setTo = function(number) {
this.variable = parseInt(number);
};
this.World.prototype.incrementBy = function(number) {
this.variable += parseInt(number);
};
///// Your step definitions /////
// use this.Given(), this.When() and this.Then() to declare step definitions
// Alternatively you can use this.defineStep and even use it
// like this:
var Given = When = Then = this.defineStep;
Given(/^a variable set to (\d+)$/, function(number, callback) {
this.setTo(number);
callback();
});
When(/^I increment the variable by (\d+)$/, function(number, callback) {
this.incrementBy(number);
callback();
});
Then(/^the variable should contain (\d+)$/, function(number, callback) {
if (this.variable != parseInt(number))
callback.fail(new Error('Variable should contain ' + number +
' but it contains ' + this.variable + '.'));
else
callback();
});</textarea>
<h2>Output</h2>
<p><button id="run-feature">Run feature</button></p>
<div id="output" class="cucumber-report"></div>
<div id="errors-container">
<h3>Errors</h3>
<pre id="errors"></pre>
</div>
</body>
</html>