paloma 4.1.1 → 4.1.2
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.
- checksums.yaml +7 -0
- data/Changelog.md +4 -1
- data/DEVELOPMENT.md +14 -0
- data/app/views/paloma/_hook.html.erb +10 -4
- data/paloma.gemspec +1 -1
- data/test_app/app/assets/javascripts/application.js +2 -2
- data/test_app/app/controllers/main_controller.rb +1 -1
- data/test_app/spec/integration/advanced_spec.rb +21 -17
- data/test_app/spec/integration/basic_spec.rb +26 -18
- data/test_app/spec/tmp/assets/jasmine-boot.js +27 -0
- data/test_app/spec/tmp/assets/jasmine-console-reporter.js +111 -0
- data/test_app/spec/tmp/assets/jasmine-console-shims.js +31 -0
- data/test_app/spec/tmp/assets/jasmine-html.js +681 -0
- data/test_app/spec/tmp/assets/jasmine-specs.js +11793 -0
- data/test_app/spec/tmp/assets/jasmine.css +82 -0
- data/test_app/spec/tmp/assets/jasmine.js +2600 -0
- data/test_app/spec/tmp/assets/json2.js +479 -0
- data/test_app/spec/tmp/runner.html +44 -0
- data/vendor/assets/javascripts/paloma/engine.js +28 -2
- metadata +36 -46
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: fb171dd2c32755bd619029e3e93a859f8888f666
|
4
|
+
data.tar.gz: 9184bb4268f33cdc3f8581426f3a48e7a6acd95d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8c5d9ae6c6f97388e55d0f625733f2b145c4653612e6ee09eb8c2ce5760531c8ad212457f4c942320706ab9e3c27dbdd45bf370d728844c3e6249a6685713d48
|
7
|
+
data.tar.gz: be6d27412b201fcecd6af8ca6ab8d18eb5889524aff9f7402d30571c715726f61030a83efd1ffd49a3d93a171ba78d72d4734bf1a23f5f4bb027815edd9d553b
|
data/Changelog.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
|
+
## 4.1.2
|
2
|
+
* https://github.com/kbparagua/paloma/issues/73 - Fix `js false` issue.
|
3
|
+
|
1
4
|
## 4.1.1
|
2
|
-
* https://github.com/kbparagua/paloma/pull/57 - Fix Turbolinks Issues.
|
5
|
+
* https://github.com/kbparagua/paloma/pull/57 - Fix Turbolinks Issues.
|
3
6
|
* https://github.com/kbparagua/paloma/pull/55 - Fix issues when Paloma hook is not found.
|
4
7
|
|
5
8
|
## 4.1.0
|
data/DEVELOPMENT.md
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# Development
|
2
|
+
|
3
|
+
## Testing
|
4
|
+
|
5
|
+
1. Go to `test_app`
|
6
|
+
1. Comment out `turbolinks.js` on `applciation.js`
|
7
|
+
1. Run `rake spec:javascript`.
|
8
|
+
1. Run `rake spec:units`.
|
9
|
+
1. Run `rake spec:integration`.
|
10
|
+
|
11
|
+
## TODO
|
12
|
+
|
13
|
+
1. Improve tests.
|
14
|
+
1. Testing for turbolinks.
|
@@ -3,6 +3,11 @@
|
|
3
3
|
<div class="js-paloma-hook" data-id="<%= id %>">
|
4
4
|
<script type="text/javascript">
|
5
5
|
(function(){
|
6
|
+
// Do not continue if Paloma not found.
|
7
|
+
if (window['Paloma'] === undefined) {
|
8
|
+
return true;
|
9
|
+
}
|
10
|
+
|
6
11
|
Paloma.env = '<%= Rails.env %>';
|
7
12
|
|
8
13
|
// Remove any callback details if any
|
@@ -10,10 +15,11 @@
|
|
10
15
|
|
11
16
|
var request = <%= request.to_json.html_safe %>;
|
12
17
|
|
13
|
-
Paloma.engine.setRequest(
|
14
|
-
|
15
|
-
request['
|
16
|
-
request['
|
18
|
+
Paloma.engine.setRequest({
|
19
|
+
id: "<%= id %>",
|
20
|
+
resource: request['resource'],
|
21
|
+
action: request['action'],
|
22
|
+
params: request['params']});
|
17
23
|
})();
|
18
24
|
</script>
|
19
25
|
</div>
|
data/paloma.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'paloma'
|
3
|
-
s.version = '4.1.
|
3
|
+
s.version = '4.1.2'
|
4
4
|
s.summary = "Provides an easy way to execute page-specific javascript for Rails."
|
5
5
|
s.description = "Page-specific javascript for Rails done right"
|
6
6
|
s.authors = ['Karl Paragua']
|
@@ -13,7 +13,7 @@
|
|
13
13
|
//= require jquery
|
14
14
|
//= require jquery.turbolinks
|
15
15
|
//= require jquery_ujs
|
16
|
-
|
16
|
+
//=# require turbolinks
|
17
17
|
//= require paloma
|
18
18
|
//= require_tree .
|
19
19
|
|
@@ -51,4 +51,4 @@ Foos.prototype.otherAction = function(){};
|
|
51
51
|
|
52
52
|
var NotFoos = Paloma.controller('NotAdmin/Foos');
|
53
53
|
NotFoos.prototype.show = function(){};
|
54
|
-
NotFoos.prototype.otherAction = function(){};
|
54
|
+
NotFoos.prototype.otherAction = function(){};
|
@@ -13,10 +13,11 @@ feature 'executing Paloma controller', :js => true do
|
|
13
13
|
it 'executes the same namespace/controller/action' do
|
14
14
|
visit admin_foos_path
|
15
15
|
|
16
|
-
expect(
|
17
|
-
'controller'
|
18
|
-
'action'
|
19
|
-
'params'
|
16
|
+
expect(
|
17
|
+
request['controller'] == 'Admin/Foos' &&
|
18
|
+
request['action'] == 'index' &&
|
19
|
+
request['params'] == {}
|
20
|
+
).to be_truthy
|
20
21
|
end
|
21
22
|
end
|
22
23
|
|
@@ -25,10 +26,11 @@ feature 'executing Paloma controller', :js => true do
|
|
25
26
|
it 'executes the specified controller' do
|
26
27
|
visit admin_foo_path(1)
|
27
28
|
|
28
|
-
expect(
|
29
|
-
'controller'
|
30
|
-
'action'
|
31
|
-
'params'
|
29
|
+
expect(
|
30
|
+
request['controller'] == 'NotAdmin/Foos' &&
|
31
|
+
request['action'] == 'show' &&
|
32
|
+
request['params'] == {'x' => 99}
|
33
|
+
).to be_truthy
|
32
34
|
end
|
33
35
|
end
|
34
36
|
|
@@ -37,10 +39,11 @@ feature 'executing Paloma controller', :js => true do
|
|
37
39
|
it 'executes the specified action' do
|
38
40
|
visit new_admin_foo_path
|
39
41
|
|
40
|
-
expect(
|
41
|
-
'controller'
|
42
|
-
'action'
|
43
|
-
'params'
|
42
|
+
expect(
|
43
|
+
request['controller'] == 'Admin/Foos' &&
|
44
|
+
request['action'] == 'otherAction' &&
|
45
|
+
request['params'] == {'x' => 99}
|
46
|
+
).to be_truthy
|
44
47
|
end
|
45
48
|
end
|
46
49
|
|
@@ -49,12 +52,13 @@ feature 'executing Paloma controller', :js => true do
|
|
49
52
|
it 'executes the specified controller/action' do
|
50
53
|
visit edit_admin_foo_path(1)
|
51
54
|
|
52
|
-
expect(
|
53
|
-
'controller'
|
54
|
-
'action'
|
55
|
-
'params'
|
55
|
+
expect(
|
56
|
+
request['controller'] == 'NotAdmin/Foos' &&
|
57
|
+
request['action'] == 'otherAction' &&
|
58
|
+
request['params'] == {'x' => 99}
|
59
|
+
).to be_truthy
|
56
60
|
end
|
57
61
|
end
|
58
62
|
|
59
63
|
|
60
|
-
end
|
64
|
+
end
|
@@ -19,10 +19,11 @@ feature 'executing Paloma controller', :js => true do
|
|
19
19
|
it 'executes the same controller/action' do
|
20
20
|
visit main_index_path
|
21
21
|
|
22
|
-
expect(
|
23
|
-
'controller'
|
24
|
-
'action'
|
25
|
-
'params'
|
22
|
+
expect(
|
23
|
+
request['controller'] == 'Main' &&
|
24
|
+
request['action'] == 'index' &&
|
25
|
+
request['params'] == {}
|
26
|
+
).to be_truthy
|
26
27
|
end
|
27
28
|
end
|
28
29
|
|
@@ -31,10 +32,11 @@ feature 'executing Paloma controller', :js => true do
|
|
31
32
|
it 'executes the specified controller' do
|
32
33
|
visit main_path(1)
|
33
34
|
|
34
|
-
expect(
|
35
|
-
'controller'
|
36
|
-
'action'
|
37
|
-
'params'
|
35
|
+
expect(
|
36
|
+
request['controller'] == 'OtherMain' &&
|
37
|
+
request['action'] == 'show' &&
|
38
|
+
request['params'] == {'x' => 1}
|
39
|
+
).to be_truthy
|
38
40
|
end
|
39
41
|
end
|
40
42
|
|
@@ -43,10 +45,11 @@ feature 'executing Paloma controller', :js => true do
|
|
43
45
|
it 'executes the specified action' do
|
44
46
|
visit new_main_path
|
45
47
|
|
46
|
-
expect(
|
47
|
-
'controller'
|
48
|
-
'action'
|
49
|
-
'params'
|
48
|
+
expect(
|
49
|
+
request['controller'] == 'Main' &&
|
50
|
+
request['action'] == 'otherAction' &&
|
51
|
+
request['params'] == {'x' => 1}
|
52
|
+
).to be_truthy
|
50
53
|
end
|
51
54
|
end
|
52
55
|
|
@@ -55,10 +58,11 @@ feature 'executing Paloma controller', :js => true do
|
|
55
58
|
it 'executes the specified controller/action' do
|
56
59
|
visit edit_main_path(1)
|
57
60
|
|
58
|
-
expect(
|
59
|
-
'controller'
|
60
|
-
'action'
|
61
|
-
'params'
|
61
|
+
expect(
|
62
|
+
request['controller'] == 'OtherMain' &&
|
63
|
+
request['action'] == 'otherAction' &&
|
64
|
+
request['params'] == {'x' => 1}
|
65
|
+
).to be_truthy
|
62
66
|
end
|
63
67
|
end
|
64
68
|
|
@@ -83,7 +87,7 @@ feature 'executing Paloma controller', :js => true do
|
|
83
87
|
|
84
88
|
shared_examples 'no paloma' do
|
85
89
|
it 'does not add paloma hook' do
|
86
|
-
expect(page.has_selector?('.js-paloma-hook')).to
|
90
|
+
expect(page.has_selector?('.js-paloma-hook')).to be_falsy
|
87
91
|
end
|
88
92
|
end
|
89
93
|
|
@@ -110,7 +114,11 @@ feature 'executing Paloma controller', :js => true do
|
|
110
114
|
|
111
115
|
context 'xml response' do
|
112
116
|
before { visit xml_response_main_index_path }
|
113
|
-
|
117
|
+
|
118
|
+
it 'does not add paloma hook' do
|
119
|
+
# TODO: implement this
|
120
|
+
# XML is not supported by capybara.
|
121
|
+
end
|
114
122
|
end
|
115
123
|
|
116
124
|
context 'file response' do
|
@@ -0,0 +1,27 @@
|
|
1
|
+
var jsApiReporter;
|
2
|
+
(function() {
|
3
|
+
var jasmineEnv = jasmine.getEnv();
|
4
|
+
|
5
|
+
jsApiReporter = new jasmine.JsApiReporter();
|
6
|
+
jasmineEnv.addReporter(jsApiReporter);
|
7
|
+
|
8
|
+
var htmlReporter = new jasmine.HtmlReporter();
|
9
|
+
jasmineEnv.addReporter(htmlReporter);
|
10
|
+
jasmineEnv.specFilter = function(spec) {
|
11
|
+
return htmlReporter.specFilter(spec);
|
12
|
+
};
|
13
|
+
|
14
|
+
if (jasmine.ConsoleReporter) {
|
15
|
+
jasmineEnv.addReporter(new jasmine.ConsoleReporter());
|
16
|
+
}
|
17
|
+
|
18
|
+
function execJasmine() {
|
19
|
+
jasmineEnv.execute();
|
20
|
+
}
|
21
|
+
|
22
|
+
if (window.addEventListener) { // W3C
|
23
|
+
window.addEventListener('load', execJasmine, false);
|
24
|
+
} else if (window.attachEvent) { // MSIE
|
25
|
+
window.attachEvent('onload', execJasmine);
|
26
|
+
}
|
27
|
+
})();
|
@@ -0,0 +1,111 @@
|
|
1
|
+
/**
|
2
|
+
Jasmine Reporter that outputs test results to the browser console.
|
3
|
+
Useful for running in a headless environment such as PhantomJs, ZombieJs etc.
|
4
|
+
|
5
|
+
Usage:
|
6
|
+
// From your html file that loads jasmine:
|
7
|
+
jasmine.getEnv().addReporter(new jasmine.ConsoleReporter());
|
8
|
+
jasmine.getEnv().execute();
|
9
|
+
*/
|
10
|
+
|
11
|
+
|
12
|
+
(function(jasmine, console) {
|
13
|
+
if (!jasmine) {
|
14
|
+
throw "jasmine library isn't loaded!";
|
15
|
+
}
|
16
|
+
|
17
|
+
var ANSI = {}
|
18
|
+
ANSI.color_map = {
|
19
|
+
"green" : 32,
|
20
|
+
"red" : 31
|
21
|
+
}
|
22
|
+
|
23
|
+
ANSI.colorize_text = function(text, color) {
|
24
|
+
var color_code = this.color_map[color];
|
25
|
+
return "\033[" + color_code + "m" + text + "\033[0m";
|
26
|
+
}
|
27
|
+
|
28
|
+
var ConsoleReporter = function() {
|
29
|
+
if (!console || !console.log) { throw "console isn't present!"; }
|
30
|
+
this.status = this.statuses.stopped;
|
31
|
+
};
|
32
|
+
|
33
|
+
var proto = ConsoleReporter.prototype;
|
34
|
+
proto.statuses = {
|
35
|
+
stopped : "stopped",
|
36
|
+
running : "running",
|
37
|
+
fail : "fail",
|
38
|
+
success : "success"
|
39
|
+
};
|
40
|
+
|
41
|
+
proto.reportRunnerStarting = function(runner) {
|
42
|
+
this.status = this.statuses.running;
|
43
|
+
this.start_time = (new Date()).getTime();
|
44
|
+
this.executed_specs = 0;
|
45
|
+
this.passed_specs = 0;
|
46
|
+
this.log("Starting...");
|
47
|
+
};
|
48
|
+
|
49
|
+
proto.reportRunnerResults = function(runner) {
|
50
|
+
var failed = this.executed_specs - this.passed_specs;
|
51
|
+
var spec_str = this.executed_specs + (this.executed_specs === 1 ? " spec, " : " specs, ");
|
52
|
+
var fail_str = failed + (failed === 1 ? " failure in " : " failures in ");
|
53
|
+
var color = (failed > 0)? "red" : "green";
|
54
|
+
var dur = (new Date()).getTime() - this.start_time;
|
55
|
+
|
56
|
+
this.log("");
|
57
|
+
this.log("Finished");
|
58
|
+
this.log("-----------------");
|
59
|
+
this.log(spec_str + fail_str + (dur/1000) + "s.", color);
|
60
|
+
|
61
|
+
this.status = (failed > 0)? this.statuses.fail : this.statuses.success;
|
62
|
+
|
63
|
+
/* Print something that signals that testing is over so that headless browsers
|
64
|
+
like PhantomJs know when to terminate. */
|
65
|
+
this.log("");
|
66
|
+
this.log("ConsoleReporter finished");
|
67
|
+
};
|
68
|
+
|
69
|
+
|
70
|
+
proto.reportSpecStarting = function(spec) {
|
71
|
+
this.executed_specs++;
|
72
|
+
};
|
73
|
+
|
74
|
+
proto.reportSpecResults = function(spec) {
|
75
|
+
if (spec.results().skipped) {
|
76
|
+
return;
|
77
|
+
}
|
78
|
+
if (spec.results().passed()) {
|
79
|
+
this.passed_specs++;
|
80
|
+
return;
|
81
|
+
}
|
82
|
+
|
83
|
+
var resultText = spec.suite.description + " : " + spec.description;
|
84
|
+
this.log(resultText, "red");
|
85
|
+
|
86
|
+
var items = spec.results().getItems()
|
87
|
+
for (var i = 0; i < items.length; i++) {
|
88
|
+
var item = items[i];
|
89
|
+
var output = ' ' + item.message;
|
90
|
+
this.log(output, "red");
|
91
|
+
}
|
92
|
+
};
|
93
|
+
|
94
|
+
proto.reportSuiteResults = function(suite) {
|
95
|
+
if (suite.parentSuite) { return; }
|
96
|
+
var results = suite.results();
|
97
|
+
if (results.totalCount === 0) {
|
98
|
+
return;
|
99
|
+
}
|
100
|
+
var failed = results.totalCount - results.passedCount;
|
101
|
+
var color = (failed > 0)? "red" : "green";
|
102
|
+
this.log(suite.description + ": " + results.passedCount + " of " + results.totalCount + " passed.", color);
|
103
|
+
};
|
104
|
+
|
105
|
+
proto.log = function(str, color) {
|
106
|
+
var text = (color != undefined)? ANSI.colorize_text(str, color) : str;
|
107
|
+
console.log(text)
|
108
|
+
};
|
109
|
+
|
110
|
+
jasmine.ConsoleReporter = ConsoleReporter;
|
111
|
+
})(jasmine, console);
|
@@ -0,0 +1,31 @@
|
|
1
|
+
(function() {
|
2
|
+
/**
|
3
|
+
* Function.bind for ECMAScript 5 Support
|
4
|
+
*
|
5
|
+
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind
|
6
|
+
*/
|
7
|
+
|
8
|
+
if (!Function.prototype.bind) {
|
9
|
+
Function.prototype.bind = function (oThis) {
|
10
|
+
if (typeof this !== "function") {
|
11
|
+
// closest thing possible to the ECMAScript 5 internal IsCallable function
|
12
|
+
throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");
|
13
|
+
}
|
14
|
+
|
15
|
+
var aArgs = Array.prototype.slice.call(arguments, 1),
|
16
|
+
fToBind = this,
|
17
|
+
fNOP = function () {},
|
18
|
+
fBound = function () {
|
19
|
+
return fToBind.apply(this instanceof fNOP && oThis
|
20
|
+
? this
|
21
|
+
: oThis,
|
22
|
+
aArgs.concat(Array.prototype.slice.call(arguments)));
|
23
|
+
};
|
24
|
+
|
25
|
+
fNOP.prototype = this.prototype;
|
26
|
+
fBound.prototype = new fNOP();
|
27
|
+
|
28
|
+
return fBound;
|
29
|
+
};
|
30
|
+
}
|
31
|
+
})();
|