lackie 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -25,11 +25,12 @@ Feature: Remote Control
|
|
25
25
|
When I tell the lackie to log "yipee"
|
26
26
|
Then I should see a result with the value "yipee"
|
27
27
|
|
28
|
-
Scenario:
|
29
|
-
When I tell the lackie to send the command "window.foo = '123'"
|
30
|
-
Then I should see a result with the value "OK"
|
28
|
+
Scenario: Reload The Browser
|
31
29
|
When I tell the lackie to execute "window.foo = 99"
|
32
|
-
|
30
|
+
When I tell the lackie to execute "Lackie.reload()"
|
31
|
+
Then I should see a result with the value "reloading"
|
32
|
+
When I tell the lackie to execute "typeof window.foo"
|
33
|
+
Then I should see a result with the value "undefined"
|
33
34
|
|
34
35
|
Scenario: Await Result
|
35
36
|
When I tell the lackie to execute "setTimeout(function() { window.foo = 666 }, 500)"
|
@@ -7,6 +7,7 @@ When /^I tell the lackie to log "([^\"]*)"$/ do |message|
|
|
7
7
|
end
|
8
8
|
|
9
9
|
When /^I tell the lackie to execute "([^\"]*)"$/ do |script|
|
10
|
+
@error = nil
|
10
11
|
begin
|
11
12
|
@response = remote_control.exec(script)
|
12
13
|
rescue => e
|
@@ -14,11 +15,8 @@ When /^I tell the lackie to execute "([^\"]*)"$/ do |script|
|
|
14
15
|
end
|
15
16
|
end
|
16
17
|
|
17
|
-
When /^I tell the lackie to send the command "([^"]*)"$/ do |script|
|
18
|
-
@response = remote_control.send_command(script)
|
19
|
-
end
|
20
|
-
|
21
18
|
When /^I await the result of "([^"]*)" to equal "([^"]*)"$/ do |script, value|
|
19
|
+
@error = nil
|
22
20
|
begin
|
23
21
|
@response = remote_control.await(script, :timeout_seconds => 1) do |current_value|
|
24
22
|
current_value.to_s == value
|
@@ -29,6 +27,7 @@ When /^I await the result of "([^"]*)" to equal "([^"]*)"$/ do |script, value|
|
|
29
27
|
end
|
30
28
|
|
31
29
|
Then /^I should see a result with the value "([^\"]*)"$/ do |value|
|
30
|
+
@error.should == nil
|
32
31
|
@response.to_s.should == value
|
33
32
|
end
|
34
33
|
|
@@ -3,50 +3,25 @@ Lackie = {
|
|
3
3
|
enabled: true,
|
4
4
|
baseUrl: "/lackie",
|
5
5
|
|
6
|
-
createXMLHttpRequest: function() {
|
7
|
-
try {
|
8
|
-
return new XMLHttpRequest();
|
9
|
-
} catch(e) {}
|
10
|
-
try {
|
11
|
-
return new ActiveXObject("Msxml2.XMLHTTP");
|
12
|
-
} catch(e) {}
|
13
|
-
throw new Error("XMLHttpRequest not supported");
|
14
|
-
},
|
15
|
-
|
16
6
|
yield: function() {
|
17
7
|
if (Lackie.wip || !Lackie.enabled) {
|
18
8
|
return;
|
19
9
|
}
|
20
|
-
|
21
|
-
|
22
|
-
|
10
|
+
Lackie.get("/yield", function(body) {
|
11
|
+
if (body.indexOf('Lackie.reload()') == 0) {
|
12
|
+
Lackie.reload();
|
23
13
|
return;
|
24
14
|
}
|
25
15
|
Lackie.wip = true;
|
26
|
-
|
27
|
-
|
28
|
-
}
|
29
|
-
finally {
|
30
|
-
try {
|
31
|
-
xhReq.destroy();
|
32
|
-
xhReq = null;
|
33
|
-
} catch(e) {}
|
34
|
-
}
|
35
|
-
}
|
36
|
-
xhReq.open("GET", Lackie.url("/yield"), true);
|
37
|
-
xhReq.onreadystatechange = readyStateChange;
|
38
|
-
xhReq.send(null);
|
16
|
+
Lackie.execute(body);
|
17
|
+
});
|
39
18
|
},
|
40
|
-
|
19
|
+
|
41
20
|
result: function(value) {
|
42
|
-
var xhReq = Lackie.createXMLHttpRequest();
|
43
21
|
var params = JSON.stringify(value);
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
xhReq.setRequestHeader("Connection", "close");
|
48
|
-
xhReq.send(params);
|
49
|
-
Lackie.wip = false;
|
22
|
+
Lackie.post("/result", params, function() {
|
23
|
+
Lackie.wip = false;
|
24
|
+
});
|
50
25
|
},
|
51
26
|
|
52
27
|
execute: function(command) {
|
@@ -59,7 +34,14 @@ Lackie = {
|
|
59
34
|
}
|
60
35
|
Lackie.result(result);
|
61
36
|
},
|
62
|
-
|
37
|
+
|
38
|
+
reload: function() {
|
39
|
+
Lackie.enabled = false;
|
40
|
+
Lackie.post("/result", '{ "value": "reloading" }', function() {
|
41
|
+
window.location.reload(true);
|
42
|
+
});
|
43
|
+
},
|
44
|
+
|
63
45
|
log: function(message) {
|
64
46
|
var logElement = document.getElementById("LackieLog");
|
65
47
|
if (logElement) {
|
@@ -68,6 +50,59 @@ Lackie = {
|
|
68
50
|
return message;
|
69
51
|
},
|
70
52
|
|
53
|
+
get: function(path, bodyCallback) {
|
54
|
+
Lackie.usingAjax(function(xhReq) {
|
55
|
+
xhReq.open("GET", Lackie.url(path), true);
|
56
|
+
xhReq.onreadystatechange = function () {
|
57
|
+
if (xhReq.readyState != 4 || xhReq.status != 200) {
|
58
|
+
return;
|
59
|
+
}
|
60
|
+
bodyCallback(xhReq.responseText);
|
61
|
+
};
|
62
|
+
xhReq.send(null);
|
63
|
+
});
|
64
|
+
},
|
65
|
+
|
66
|
+
post: function(path, params, callback) {
|
67
|
+
Lackie.usingAjax(function(xhReq) {
|
68
|
+
xhReq.open("POST", Lackie.url(path), true);
|
69
|
+
xhReq.onreadystatechange = function () {
|
70
|
+
if (xhReq.readyState != 2 || xhReq.status != 200) {
|
71
|
+
return;
|
72
|
+
}
|
73
|
+
callback();
|
74
|
+
};
|
75
|
+
xhReq.setRequestHeader("Content-type", "application/json");
|
76
|
+
xhReq.setRequestHeader("Content-length", params.length);
|
77
|
+
xhReq.setRequestHeader("Connection", "close");
|
78
|
+
xhReq.send(params);
|
79
|
+
});
|
80
|
+
},
|
81
|
+
|
82
|
+
createXMLHttpRequest: function() {
|
83
|
+
try {
|
84
|
+
return new XMLHttpRequest();
|
85
|
+
} catch(e) {}
|
86
|
+
try {
|
87
|
+
return new ActiveXObject("Msxml2.XMLHTTP");
|
88
|
+
} catch(e) {}
|
89
|
+
throw new Error("XMLHttpRequest not supported");
|
90
|
+
},
|
91
|
+
|
92
|
+
usingAjax: function(callback) {
|
93
|
+
var xhReq = Lackie.createXMLHttpRequest();
|
94
|
+
try {
|
95
|
+
callback(xhReq);
|
96
|
+
}
|
97
|
+
finally {
|
98
|
+
try {
|
99
|
+
if (typeof xhReq.destroy == 'function')
|
100
|
+
xhReq.destroy();
|
101
|
+
delete xhReq;
|
102
|
+
} catch(e) {}
|
103
|
+
}
|
104
|
+
},
|
105
|
+
|
71
106
|
url: function(path) {
|
72
107
|
var now = new Date();
|
73
108
|
return Lackie.baseUrl + path + '?' + now.getTime().toString();
|
data/lib/lackie/poller.rb
CHANGED
@@ -14,7 +14,7 @@ module Lackie
|
|
14
14
|
@sleeper.sleep @interval_seconds
|
15
15
|
seconds_waited += @interval_seconds
|
16
16
|
end
|
17
|
-
raise TimeoutError.new("Timed out after #{
|
17
|
+
raise TimeoutError.new("Timed out after #{timeout_seconds} seconds awaiting #{outcome}")
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
data/lib/lackie.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lackie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 6
|
10
|
+
version: 0.1.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Josh Chisholm
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-01-
|
18
|
+
date: 2011-01-26 00:00:00 +00:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -197,7 +197,7 @@ rubyforge_project:
|
|
197
197
|
rubygems_version: 1.3.7
|
198
198
|
signing_key:
|
199
199
|
specification_version: 3
|
200
|
-
summary: lackie-0.1.
|
200
|
+
summary: lackie-0.1.6
|
201
201
|
test_files:
|
202
202
|
- features/remote_control.feature
|
203
203
|
- features/step_definitions/lackie_steps.rb
|