Skip to content
This repository has been archived by the owner on Nov 27, 2020. It is now read-only.

Commit

Permalink
We'll have to implement features provided by capybara >= 2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
route committed Aug 26, 2014
1 parent b7271f2 commit 9387c89
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 87 deletions.
23 changes: 11 additions & 12 deletions lib/capybara/poltergeist/client/compiled/agent.js
Expand Up @@ -174,20 +174,19 @@ PoltergeistAgent.Node = (function() {
};

Node.prototype.isObsolete = function() {
var obsolete;
obsolete = (function(_this) {
return function(element) {
if (element.parentNode != null) {
if (element.parentNode === document) {
return false;
} else {
return obsolete(element.parentNode);
}
var obsolete,
_this = this;
obsolete = function(element) {
if (element.parentNode != null) {
if (element.parentNode === document) {
return false;
} else {
return true;
return obsolete(element.parentNode);
}
};
})(this);
} else {
return true;
}
};
return obsolete(this.element);
};

Expand Down
122 changes: 55 additions & 67 deletions lib/capybara/poltergeist/client/compiled/browser.js
Expand Up @@ -12,6 +12,7 @@ Poltergeist.Browser = (function() {
}

Browser.prototype.resetPage = function() {
var _this = this;
if (this.page != null) {
this.page.release();
phantom.clearCookies();
Expand All @@ -21,52 +22,42 @@ Poltergeist.Browser = (function() {
width: this.width,
height: this.height
});
this.page.onLoadStarted = (function(_this) {
return function() {
if (_this.state === 'mouse_event') {
return _this.setState('loading');
}
};
})(this);
this.page.onNavigationRequested = (function(_this) {
return function(url, navigation) {
if (_this.state === 'mouse_event' && navigation === 'FormSubmitted') {
return _this.setState('loading');
}
};
})(this);
this.page.onLoadFinished = (function(_this) {
return function(status) {
if (_this.state === 'loading') {
_this.sendResponse({
status: status,
position: _this.last_mouse_event
});
return _this.setState('default');
} else if (_this.state === 'awaiting_frame_load') {
_this.sendResponse(true);
return _this.setState('default');
}
};
})(this);
this.page.onInitialized = (function(_this) {
return function() {
return _this.page_id += 1;
};
})(this);
return this.page.onPageCreated = (function(_this) {
return function(sub_page) {
var name;
if (_this.state === 'awaiting_sub_page') {
name = _this.page_name;
_this.page_name = null;
_this.setState('default');
return setTimeout((function() {
return _this.push_window(name);
}), 0);
}
};
})(this);
this.page.onLoadStarted = function() {
if (_this.state === 'mouse_event') {
return _this.setState('loading');
}
};
this.page.onNavigationRequested = function(url, navigation) {
if (_this.state === 'mouse_event' && navigation === 'FormSubmitted') {
return _this.setState('loading');
}
};
this.page.onLoadFinished = function(status) {
if (_this.state === 'loading') {
_this.sendResponse({
status: status,
position: _this.last_mouse_event
});
return _this.setState('default');
} else if (_this.state === 'awaiting_frame_load') {
_this.sendResponse(true);
return _this.setState('default');
}
};
this.page.onInitialized = function() {
return _this.page_id += 1;
};
return this.page.onPageCreated = function(sub_page) {
var name;
if (_this.state === 'awaiting_sub_page') {
name = _this.page_name;
_this.page_name = null;
_this.setState('default');
return setTimeout((function() {
return _this.push_window(name);
}), 0);
}
};
};

Browser.prototype.runCommand = function(name, args) {
Expand Down Expand Up @@ -224,6 +215,7 @@ Poltergeist.Browser = (function() {
};

Browser.prototype.push_frame = function(name, timeout) {
var _this = this;
if (timeout == null) {
timeout = new Date().getTime() + 2000;
}
Expand All @@ -235,11 +227,9 @@ Poltergeist.Browser = (function() {
}
} else {
if (new Date().getTime() < timeout) {
return setTimeout(((function(_this) {
return function() {
return _this.push_frame(name, timeout);
};
})(this)), 50);
return setTimeout((function() {
return _this.push_frame(name, timeout);
}), 50);
} else {
return this.owner.sendError(new Poltergeist.FrameNotFound(name));
}
Expand All @@ -255,16 +245,15 @@ Poltergeist.Browser = (function() {
};

Browser.prototype.push_window = function(name) {
var sub_page;
var sub_page,
_this = this;
sub_page = this.page.getPage(name);
if (sub_page) {
if (sub_page.currentUrl() === 'about:blank') {
return sub_page.onLoadFinished = (function(_this) {
return function() {
sub_page.onLoadFinished = null;
return _this.push_window(name);
};
})(this);
return sub_page.onLoadFinished = function() {
sub_page.onLoadFinished = null;
return _this.push_window(name);
};
} else {
this.page_stack.push(this.page);
this.page = sub_page;
Expand All @@ -287,18 +276,17 @@ Poltergeist.Browser = (function() {
};

Browser.prototype.mouse_event = function(page_id, id, name) {
var node;
var node,
_this = this;
node = this.node(page_id, id);
this.setState('mouse_event');
this.last_mouse_event = node.mouseEvent(name);
return setTimeout((function(_this) {
return function() {
if (_this.state !== 'loading') {
_this.setState('default');
return _this.sendResponse(_this.last_mouse_event);
}
};
})(this), 5);
return setTimeout(function() {
if (_this.state !== 'loading') {
_this.setState('default');
return _this.sendResponse(_this.last_mouse_event);
}
}, 5);
};

Browser.prototype.click = function(page_id, id) {
Expand Down
8 changes: 5 additions & 3 deletions lib/capybara/poltergeist/client/compiled/main.js
@@ -1,4 +1,4 @@
var Poltergeist,
var Poltergeist, _ref, _ref1,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

Expand Down Expand Up @@ -68,7 +68,8 @@ Poltergeist.ObsoleteNode = (function(_super) {
__extends(ObsoleteNode, _super);

function ObsoleteNode() {
return ObsoleteNode.__super__.constructor.apply(this, arguments);
_ref = ObsoleteNode.__super__.constructor.apply(this, arguments);
return _ref;
}

ObsoleteNode.prototype.name = "Poltergeist.ObsoleteNode";
Expand Down Expand Up @@ -178,7 +179,8 @@ Poltergeist.StatusFailError = (function(_super) {
__extends(StatusFailError, _super);

function StatusFailError() {
return StatusFailError.__super__.constructor.apply(this, arguments);
_ref1 = StatusFailError.__super__.constructor.apply(this, arguments);
return _ref1;
}

StatusFailError.prototype.name = "Poltergeist.StatusFailError";
Expand Down
5 changes: 3 additions & 2 deletions lib/capybara/poltergeist/client/compiled/node.js
@@ -1,7 +1,8 @@
var __slice = [].slice;

Poltergeist.Node = (function() {
var name, _fn, _i, _len, _ref;
var name, _fn, _i, _len, _ref,
_this = this;

Node.DELEGATES = ['allText', 'visibleText', 'getAttribute', 'value', 'set', 'setAttribute', 'isObsolete', 'removeAttribute', 'isMultiple', 'select', 'tagName', 'find', 'getAttributes', 'isVisible', 'position', 'trigger', 'parentId', 'parentIds', 'mouseEventTest', 'scrollIntoView', 'isDOMEqual', 'isDisabled', 'deleteText', 'containsSelection'];

Expand Down Expand Up @@ -68,4 +69,4 @@ Poltergeist.Node = (function() {

return Node;

})();
}).call(this);
5 changes: 3 additions & 2 deletions lib/capybara/poltergeist/client/compiled/web_page.js
@@ -1,7 +1,8 @@
var __slice = [].slice;

Poltergeist.WebPage = (function() {
var command, delegate, _fn, _fn1, _i, _j, _len, _len1, _ref, _ref1;
var command, delegate, _fn, _fn1, _i, _j, _len, _len1, _ref, _ref1,
_this = this;

WebPage.CALLBACKS = ['onAlert', 'onConsoleMessage', 'onLoadFinished', 'onInitialized', 'onLoadStarted', 'onResourceRequested', 'onResourceReceived', 'onError', 'onNavigationRequested', 'onUrlChanged', 'onPageCreated'];

Expand Down Expand Up @@ -414,4 +415,4 @@ Poltergeist.WebPage = (function() {

return WebPage;

})();
}).call(this);
2 changes: 1 addition & 1 deletion poltergeist.gemspec
Expand Up @@ -18,7 +18,7 @@ Gem::Specification.new do |s|

s.required_ruby_version = '>= 1.9.3'

s.add_dependency 'capybara', '~> 2.1'
s.add_dependency 'capybara', '~> 2.1', '< 2.3'

This comment has been minimized.

Copy link
@donaldpiret

donaldpiret Sep 4, 2014

Ugh.. this completely breaks rspec 3 compatibility. The latest capybara was working find on our end. Not sure why this had to be implemented.

This comment has been minimized.

Copy link
@route

route Sep 4, 2014

Author Contributor

How's that related to rspec?

This comment has been minimized.

Copy link
@donaldpiret

donaldpiret Sep 4, 2014

Capybara rspec3 compatibility was added in 2.3.0

This comment has been minimized.

Copy link
@route

route Sep 4, 2014

Author Contributor

Will be fixed in a few minutes

This comment has been minimized.

Copy link
@route

route Sep 4, 2014

Author Contributor

Looks like done :)

s.add_dependency 'websocket-driver', '>= 0.2.0'
s.add_dependency 'multi_json', '~> 1.0'
s.add_dependency 'cliver', '~> 0.3.1'
Expand Down

0 comments on commit 9387c89

Please sign in to comment.