backbone-nested-attributes 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +21 -0
- data/.rvmrc +1 -0
- data/Gemfile +12 -0
- data/LICENSE.txt +22 -0
- data/README.md +187 -0
- data/Rakefile +15 -0
- data/app/assets/javascripts/backbone-nested-attributes/all.js +2 -0
- data/app/assets/javascripts/backbone-nested-attributes/model.js +175 -0
- data/app/assets/javascripts/backbone-nested-attributes/undoable.js +60 -0
- data/backbone-nested-attributes.gemspec +20 -0
- data/lib/backbone-nested-attributes.rb +6 -0
- data/lib/backbone-nested-attributes/engine.rb +7 -0
- data/lib/backbone-nested-attributes/version.rb +5 -0
- data/spec/dummy/README.rdoc +261 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +18 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.gitkeep +0 -0
- data/spec/dummy/app/models/.gitkeep +0 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +79 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +67 -0
- data/spec/dummy/config/environments/test.rb +37 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +15 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +58 -0
- data/spec/dummy/db/.gitkeep +0 -0
- data/spec/dummy/lib/assets/.gitkeep +0 -0
- data/spec/dummy/log/.gitkeep +0 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +25 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/javascripts/backbone-nested-attributes/ModelSpec.js +626 -0
- data/spec/javascripts/backbone-nested-attributes/UndoableSpec.js +489 -0
- data/spec/javascripts/helpers/SpecHelper.js +7 -0
- data/spec/javascripts/helpers/mock-ajax.js +207 -0
- data/spec/javascripts/support/jasmine.yml +76 -0
- metadata +156 -0
@@ -0,0 +1,207 @@
|
|
1
|
+
/*
|
2
|
+
Jasmine-Ajax : a set of helpers for testing AJAX requests under the Jasmine
|
3
|
+
BDD framework for JavaScript.
|
4
|
+
|
5
|
+
Supports both Prototype.js and jQuery.
|
6
|
+
|
7
|
+
http://github.com/pivotal/jasmine-ajax
|
8
|
+
|
9
|
+
Jasmine Home page: http://pivotal.github.com/jasmine
|
10
|
+
|
11
|
+
Copyright (c) 2008-2010 Pivotal Labs
|
12
|
+
|
13
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
14
|
+
a copy of this software and associated documentation files (the
|
15
|
+
"Software"), to deal in the Software without restriction, including
|
16
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
17
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
18
|
+
permit persons to whom the Software is furnished to do so, subject to
|
19
|
+
the following conditions:
|
20
|
+
|
21
|
+
The above copyright notice and this permission notice shall be
|
22
|
+
included in all copies or substantial portions of the Software.
|
23
|
+
|
24
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
25
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
26
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
27
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
28
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
29
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
30
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
31
|
+
|
32
|
+
*/
|
33
|
+
|
34
|
+
// Jasmine-Ajax interface
|
35
|
+
var ajaxRequests = [];
|
36
|
+
|
37
|
+
function mostRecentAjaxRequest() {
|
38
|
+
if (ajaxRequests.length > 0) {
|
39
|
+
return ajaxRequests[ajaxRequests.length - 1];
|
40
|
+
} else {
|
41
|
+
return null;
|
42
|
+
}
|
43
|
+
}
|
44
|
+
|
45
|
+
function clearAjaxRequests() {
|
46
|
+
ajaxRequests = [];
|
47
|
+
}
|
48
|
+
|
49
|
+
// Fake XHR for mocking Ajax Requests & Responses
|
50
|
+
function FakeXMLHttpRequest() {
|
51
|
+
var extend = Object.extend || $.extend;
|
52
|
+
extend(this, {
|
53
|
+
requestHeaders: {},
|
54
|
+
|
55
|
+
open: function() {
|
56
|
+
this.method = arguments[0];
|
57
|
+
this.url = arguments[1];
|
58
|
+
this.readyState = 1;
|
59
|
+
},
|
60
|
+
|
61
|
+
setRequestHeader: function(header, value) {
|
62
|
+
this.requestHeaders[header] = value;
|
63
|
+
},
|
64
|
+
|
65
|
+
abort: function() {
|
66
|
+
this.readyState = 0;
|
67
|
+
},
|
68
|
+
|
69
|
+
readyState: 0,
|
70
|
+
|
71
|
+
onreadystatechange: function(isTimeout) {
|
72
|
+
},
|
73
|
+
|
74
|
+
status: null,
|
75
|
+
|
76
|
+
send: function(data) {
|
77
|
+
this.params = data;
|
78
|
+
this.readyState = 2;
|
79
|
+
},
|
80
|
+
|
81
|
+
getResponseHeader: function(name) {
|
82
|
+
return this.responseHeaders[name];
|
83
|
+
},
|
84
|
+
|
85
|
+
getAllResponseHeaders: function() {
|
86
|
+
var responseHeaders = [];
|
87
|
+
for (var i in this.responseHeaders) {
|
88
|
+
if (this.responseHeaders.hasOwnProperty(i)) {
|
89
|
+
responseHeaders.push(i + ': ' + this.responseHeaders[i]);
|
90
|
+
}
|
91
|
+
}
|
92
|
+
return responseHeaders.join('\r\n');
|
93
|
+
},
|
94
|
+
|
95
|
+
responseText: null,
|
96
|
+
|
97
|
+
response: function(response) {
|
98
|
+
this.status = response.status;
|
99
|
+
this.responseText = response.responseText || "";
|
100
|
+
this.readyState = 4;
|
101
|
+
this.responseHeaders = response.responseHeaders ||
|
102
|
+
{"Content-type": response.contentType || "application/json" };
|
103
|
+
// uncomment for jquery 1.3.x support
|
104
|
+
// jasmine.Clock.tick(20);
|
105
|
+
|
106
|
+
this.onreadystatechange();
|
107
|
+
},
|
108
|
+
responseTimeout: function() {
|
109
|
+
this.readyState = 4;
|
110
|
+
jasmine.Clock.tick(jQuery.ajaxSettings.timeout || 30000);
|
111
|
+
this.onreadystatechange('timeout');
|
112
|
+
}
|
113
|
+
});
|
114
|
+
|
115
|
+
return this;
|
116
|
+
}
|
117
|
+
|
118
|
+
|
119
|
+
jasmine.Ajax = {
|
120
|
+
|
121
|
+
isInstalled: function() {
|
122
|
+
return jasmine.Ajax.installed == true;
|
123
|
+
},
|
124
|
+
|
125
|
+
assertInstalled: function() {
|
126
|
+
if (!jasmine.Ajax.isInstalled()) {
|
127
|
+
throw new Error("Mock ajax is not installed, use jasmine.Ajax.useMock()")
|
128
|
+
}
|
129
|
+
},
|
130
|
+
|
131
|
+
useMock: function() {
|
132
|
+
if (!jasmine.Ajax.isInstalled()) {
|
133
|
+
var spec = jasmine.getEnv().currentSpec;
|
134
|
+
spec.after(jasmine.Ajax.uninstallMock);
|
135
|
+
|
136
|
+
jasmine.Ajax.installMock();
|
137
|
+
}
|
138
|
+
},
|
139
|
+
|
140
|
+
installMock: function() {
|
141
|
+
if (typeof jQuery != 'undefined') {
|
142
|
+
jasmine.Ajax.installJquery();
|
143
|
+
} else if (typeof Prototype != 'undefined') {
|
144
|
+
jasmine.Ajax.installPrototype();
|
145
|
+
} else {
|
146
|
+
throw new Error("jasmine.Ajax currently only supports jQuery and Prototype");
|
147
|
+
}
|
148
|
+
jasmine.Ajax.installed = true;
|
149
|
+
},
|
150
|
+
|
151
|
+
installJquery: function() {
|
152
|
+
jasmine.Ajax.mode = 'jQuery';
|
153
|
+
jasmine.Ajax.real = jQuery.ajaxSettings.xhr;
|
154
|
+
jQuery.ajaxSettings.xhr = jasmine.Ajax.jQueryMock;
|
155
|
+
|
156
|
+
},
|
157
|
+
|
158
|
+
installPrototype: function() {
|
159
|
+
jasmine.Ajax.mode = 'Prototype';
|
160
|
+
jasmine.Ajax.real = Ajax.getTransport;
|
161
|
+
|
162
|
+
Ajax.getTransport = jasmine.Ajax.prototypeMock;
|
163
|
+
},
|
164
|
+
|
165
|
+
uninstallMock: function() {
|
166
|
+
jasmine.Ajax.assertInstalled();
|
167
|
+
if (jasmine.Ajax.mode == 'jQuery') {
|
168
|
+
jQuery.ajaxSettings.xhr = jasmine.Ajax.real;
|
169
|
+
} else if (jasmine.Ajax.mode == 'Prototype') {
|
170
|
+
Ajax.getTransport = jasmine.Ajax.real;
|
171
|
+
}
|
172
|
+
jasmine.Ajax.reset();
|
173
|
+
},
|
174
|
+
|
175
|
+
reset: function() {
|
176
|
+
jasmine.Ajax.installed = false;
|
177
|
+
jasmine.Ajax.mode = null;
|
178
|
+
jasmine.Ajax.real = null;
|
179
|
+
},
|
180
|
+
|
181
|
+
jQueryMock: function() {
|
182
|
+
var newXhr = new FakeXMLHttpRequest();
|
183
|
+
ajaxRequests.push(newXhr);
|
184
|
+
return newXhr;
|
185
|
+
},
|
186
|
+
|
187
|
+
prototypeMock: function() {
|
188
|
+
return new FakeXMLHttpRequest();
|
189
|
+
},
|
190
|
+
|
191
|
+
installed: false,
|
192
|
+
mode: null
|
193
|
+
}
|
194
|
+
|
195
|
+
|
196
|
+
// Jasmine-Ajax Glue code for Prototype.js
|
197
|
+
if (typeof Prototype != 'undefined' && Ajax && Ajax.Request) {
|
198
|
+
Ajax.Request.prototype.originalRequest = Ajax.Request.prototype.request;
|
199
|
+
Ajax.Request.prototype.request = function(url) {
|
200
|
+
this.originalRequest(url);
|
201
|
+
ajaxRequests.push(this);
|
202
|
+
};
|
203
|
+
|
204
|
+
Ajax.Request.prototype.response = function(responseOptions) {
|
205
|
+
return this.transport.response(responseOptions);
|
206
|
+
};
|
207
|
+
}
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# src_files
|
2
|
+
#
|
3
|
+
# Return an array of filepaths relative to src_dir to include before jasmine specs.
|
4
|
+
# Default: []
|
5
|
+
#
|
6
|
+
# EXAMPLE:
|
7
|
+
#
|
8
|
+
# src_files:
|
9
|
+
# - lib/source1.js
|
10
|
+
# - lib/source2.js
|
11
|
+
# - dist/**/*.js
|
12
|
+
#
|
13
|
+
src_files:
|
14
|
+
- assets/application.js
|
15
|
+
|
16
|
+
# stylesheets
|
17
|
+
#
|
18
|
+
# Return an array of stylesheet filepaths relative to src_dir to include before jasmine specs.
|
19
|
+
# Default: []
|
20
|
+
#
|
21
|
+
# EXAMPLE:
|
22
|
+
#
|
23
|
+
# stylesheets:
|
24
|
+
# - css/style.css
|
25
|
+
# - stylesheets/*.css
|
26
|
+
#
|
27
|
+
stylesheets:
|
28
|
+
- assets/application.css
|
29
|
+
|
30
|
+
# helpers
|
31
|
+
#
|
32
|
+
# Return an array of filepaths relative to spec_dir to include before jasmine specs.
|
33
|
+
# Default: ["helpers/**/*.js"]
|
34
|
+
#
|
35
|
+
# EXAMPLE:
|
36
|
+
#
|
37
|
+
# helpers:
|
38
|
+
# - helpers/**/*.js
|
39
|
+
#
|
40
|
+
helpers:
|
41
|
+
- helpers/**/*.js
|
42
|
+
|
43
|
+
# spec_files
|
44
|
+
#
|
45
|
+
# Return an array of filepaths relative to spec_dir to include.
|
46
|
+
# Default: ["**/*[sS]pec.js"]
|
47
|
+
#
|
48
|
+
# EXAMPLE:
|
49
|
+
#
|
50
|
+
# spec_files:
|
51
|
+
# - **/*[sS]pec.js
|
52
|
+
#
|
53
|
+
spec_files:
|
54
|
+
- '**/*[sS]pec.js'
|
55
|
+
|
56
|
+
# src_dir
|
57
|
+
#
|
58
|
+
# Source directory path. Your src_files must be returned relative to this path. Will use root if left blank.
|
59
|
+
# Default: project root
|
60
|
+
#
|
61
|
+
# EXAMPLE:
|
62
|
+
#
|
63
|
+
# src_dir: public
|
64
|
+
#
|
65
|
+
src_dir:
|
66
|
+
|
67
|
+
# spec_dir
|
68
|
+
#
|
69
|
+
# Spec directory path. Your spec_files must be returned relative to this path.
|
70
|
+
# Default: spec/javascripts
|
71
|
+
#
|
72
|
+
# EXAMPLE:
|
73
|
+
#
|
74
|
+
# spec_dir: spec/javascripts
|
75
|
+
#
|
76
|
+
spec_dir: spec/javascripts
|
metadata
ADDED
@@ -0,0 +1,156 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: backbone-nested-attributes
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Vicente Mundim
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-05-22 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rails
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 3.2.8
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 3.2.8
|
30
|
+
description: Add nested attributes to your Backbone models
|
31
|
+
email:
|
32
|
+
- vicente.mundim@gmail.com
|
33
|
+
executables: []
|
34
|
+
extensions: []
|
35
|
+
extra_rdoc_files: []
|
36
|
+
files:
|
37
|
+
- .gitignore
|
38
|
+
- .rvmrc
|
39
|
+
- Gemfile
|
40
|
+
- LICENSE.txt
|
41
|
+
- README.md
|
42
|
+
- Rakefile
|
43
|
+
- app/assets/javascripts/backbone-nested-attributes/all.js
|
44
|
+
- app/assets/javascripts/backbone-nested-attributes/model.js
|
45
|
+
- app/assets/javascripts/backbone-nested-attributes/undoable.js
|
46
|
+
- backbone-nested-attributes.gemspec
|
47
|
+
- lib/backbone-nested-attributes.rb
|
48
|
+
- lib/backbone-nested-attributes/engine.rb
|
49
|
+
- lib/backbone-nested-attributes/version.rb
|
50
|
+
- spec/dummy/README.rdoc
|
51
|
+
- spec/dummy/Rakefile
|
52
|
+
- spec/dummy/app/assets/javascripts/application.js
|
53
|
+
- spec/dummy/app/assets/stylesheets/application.css
|
54
|
+
- spec/dummy/app/controllers/application_controller.rb
|
55
|
+
- spec/dummy/app/helpers/application_helper.rb
|
56
|
+
- spec/dummy/app/mailers/.gitkeep
|
57
|
+
- spec/dummy/app/models/.gitkeep
|
58
|
+
- spec/dummy/app/views/layouts/application.html.erb
|
59
|
+
- spec/dummy/config.ru
|
60
|
+
- spec/dummy/config/application.rb
|
61
|
+
- spec/dummy/config/boot.rb
|
62
|
+
- spec/dummy/config/database.yml
|
63
|
+
- spec/dummy/config/environment.rb
|
64
|
+
- spec/dummy/config/environments/development.rb
|
65
|
+
- spec/dummy/config/environments/production.rb
|
66
|
+
- spec/dummy/config/environments/test.rb
|
67
|
+
- spec/dummy/config/initializers/backtrace_silencers.rb
|
68
|
+
- spec/dummy/config/initializers/inflections.rb
|
69
|
+
- spec/dummy/config/initializers/mime_types.rb
|
70
|
+
- spec/dummy/config/initializers/secret_token.rb
|
71
|
+
- spec/dummy/config/initializers/session_store.rb
|
72
|
+
- spec/dummy/config/initializers/wrap_parameters.rb
|
73
|
+
- spec/dummy/config/locales/en.yml
|
74
|
+
- spec/dummy/config/routes.rb
|
75
|
+
- spec/dummy/db/.gitkeep
|
76
|
+
- spec/dummy/lib/assets/.gitkeep
|
77
|
+
- spec/dummy/log/.gitkeep
|
78
|
+
- spec/dummy/public/404.html
|
79
|
+
- spec/dummy/public/422.html
|
80
|
+
- spec/dummy/public/500.html
|
81
|
+
- spec/dummy/public/favicon.ico
|
82
|
+
- spec/dummy/script/rails
|
83
|
+
- spec/javascripts/backbone-nested-attributes/ModelSpec.js
|
84
|
+
- spec/javascripts/backbone-nested-attributes/UndoableSpec.js
|
85
|
+
- spec/javascripts/helpers/SpecHelper.js
|
86
|
+
- spec/javascripts/helpers/mock-ajax.js
|
87
|
+
- spec/javascripts/support/jasmine.yml
|
88
|
+
homepage:
|
89
|
+
licenses: []
|
90
|
+
post_install_message:
|
91
|
+
rdoc_options: []
|
92
|
+
require_paths:
|
93
|
+
- lib
|
94
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
95
|
+
none: false
|
96
|
+
requirements:
|
97
|
+
- - ! '>='
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
segments:
|
101
|
+
- 0
|
102
|
+
hash: -971025250535870783
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
none: false
|
105
|
+
requirements:
|
106
|
+
- - ! '>='
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
segments:
|
110
|
+
- 0
|
111
|
+
hash: -971025250535870783
|
112
|
+
requirements: []
|
113
|
+
rubyforge_project:
|
114
|
+
rubygems_version: 1.8.24
|
115
|
+
signing_key:
|
116
|
+
specification_version: 3
|
117
|
+
summary: Add nested attributes to your Backbone models
|
118
|
+
test_files:
|
119
|
+
- spec/dummy/README.rdoc
|
120
|
+
- spec/dummy/Rakefile
|
121
|
+
- spec/dummy/app/assets/javascripts/application.js
|
122
|
+
- spec/dummy/app/assets/stylesheets/application.css
|
123
|
+
- spec/dummy/app/controllers/application_controller.rb
|
124
|
+
- spec/dummy/app/helpers/application_helper.rb
|
125
|
+
- spec/dummy/app/mailers/.gitkeep
|
126
|
+
- spec/dummy/app/models/.gitkeep
|
127
|
+
- spec/dummy/app/views/layouts/application.html.erb
|
128
|
+
- spec/dummy/config.ru
|
129
|
+
- spec/dummy/config/application.rb
|
130
|
+
- spec/dummy/config/boot.rb
|
131
|
+
- spec/dummy/config/database.yml
|
132
|
+
- spec/dummy/config/environment.rb
|
133
|
+
- spec/dummy/config/environments/development.rb
|
134
|
+
- spec/dummy/config/environments/production.rb
|
135
|
+
- spec/dummy/config/environments/test.rb
|
136
|
+
- spec/dummy/config/initializers/backtrace_silencers.rb
|
137
|
+
- spec/dummy/config/initializers/inflections.rb
|
138
|
+
- spec/dummy/config/initializers/mime_types.rb
|
139
|
+
- spec/dummy/config/initializers/secret_token.rb
|
140
|
+
- spec/dummy/config/initializers/session_store.rb
|
141
|
+
- spec/dummy/config/initializers/wrap_parameters.rb
|
142
|
+
- spec/dummy/config/locales/en.yml
|
143
|
+
- spec/dummy/config/routes.rb
|
144
|
+
- spec/dummy/db/.gitkeep
|
145
|
+
- spec/dummy/lib/assets/.gitkeep
|
146
|
+
- spec/dummy/log/.gitkeep
|
147
|
+
- spec/dummy/public/404.html
|
148
|
+
- spec/dummy/public/422.html
|
149
|
+
- spec/dummy/public/500.html
|
150
|
+
- spec/dummy/public/favicon.ico
|
151
|
+
- spec/dummy/script/rails
|
152
|
+
- spec/javascripts/backbone-nested-attributes/ModelSpec.js
|
153
|
+
- spec/javascripts/backbone-nested-attributes/UndoableSpec.js
|
154
|
+
- spec/javascripts/helpers/SpecHelper.js
|
155
|
+
- spec/javascripts/helpers/mock-ajax.js
|
156
|
+
- spec/javascripts/support/jasmine.yml
|