-
Notifications
You must be signed in to change notification settings - Fork 15
/
matcher.js
50 lines (37 loc) · 1.12 KB
/
matcher.js
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
// Generated by CoffeeScript 1.3.1
(function() {
window.Capybara || (window.Capybara = {});
Capybara.Generators || (Capybara.Generators = {});
Capybara.Generators.Matcher = (function() {
Matcher.name = 'Matcher';
Matcher.prototype.templates = {
shouldHaveSelector: function(data) {
return "page.should have_selector('" + data.selector + "')";
},
shouldHaveContent: function(data) {
return "page.should have_content('" + data.options.content + "')";
}
};
Matcher.prototype.scopeTemplate = function(locator) {
return ["within_form('" + locator + "') do", "end"];
};
function Matcher(data) {
if (data == null) {
data = {};
}
this.data = data;
}
Matcher.prototype.isScoped = function() {
return this.data.scope != null;
};
Matcher.prototype.scopeToPartials = function() {
if (this.isScoped) {
return this.scopeTemplate(this.data.scope);
}
};
Matcher.prototype.toString = function() {
return this.templates[this.data.name](this.data);
};
return Matcher;
})();
}).call(this);