jasmine-stealth-rails 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +19 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +35 -0
- data/Rakefile +14 -0
- data/jasmine-stealth-rails.gemspec +19 -0
- data/lib/jasmine-stealth-rails.rb +11 -0
- data/lib/jasmine-stealth-rails/engine.rb +8 -0
- data/lib/jasmine-stealth-rails/railtie.rb +8 -0
- data/lib/jasmine-stealth-rails/version.rb +7 -0
- data/vendor/assets/javascripts/jasmine-stealth.js +244 -0
- metadata +57 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Navin Peiris
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# jasmine-stealth for Rails
|
2
|
+
|
3
|
+
[jasmine-stealth](https://github.com/searls/jasmine-stealth) is a Jasmine helper that adds a little sugar to Jasmine's spies written by [Justin Searls](https://github.com/searls/jasmine-stealth).
|
4
|
+
|
5
|
+
Please see the jasmine-stealth [repository](https://github.com/searls/jasmine-stealth) for more information.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'jasmine-stealth-rails'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install jasmine-stealth-rails
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Add this line to your test manifest file:
|
24
|
+
|
25
|
+
//= require jasmine-stealth
|
26
|
+
|
27
|
+
Or alternatively include `/assets/jasmine-stealth.js`
|
28
|
+
|
29
|
+
## Contributing
|
30
|
+
|
31
|
+
1. Fork it
|
32
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
33
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
34
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
35
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
require 'bundler'
|
3
|
+
Bundler::GemHelper.install_tasks
|
4
|
+
|
5
|
+
desc "Bundle the gem"
|
6
|
+
task :bundle do
|
7
|
+
sh('bundle install')
|
8
|
+
sh 'gem build *.gemspec'
|
9
|
+
sh 'gem install *.gem'
|
10
|
+
sh 'rm *.gem'
|
11
|
+
end
|
12
|
+
|
13
|
+
task(:default).clear
|
14
|
+
task :default => :bundle
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'jasmine-stealth-rails/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = 'jasmine-stealth-rails'
|
8
|
+
gem.version = Jasmine::Stealth::Rails::VERSION
|
9
|
+
gem.authors = ['Navin Peiris']
|
10
|
+
gem.email = ['navin.peiris@gmail.com']
|
11
|
+
gem.description = %q{jasmine-stealth for Rails 3.1 Asset Pipeline}
|
12
|
+
gem.summary = %q{jasmine-stealth is a Jasmine helper that adds a little sugar to Jasmine's spies developed by Justin Searls integrated for Rails 3.1 asset pipeline.}
|
13
|
+
gem.homepage = 'https://github.com/navinpeiris/jasmine-stealth-rails'
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ['lib']
|
19
|
+
end
|
@@ -0,0 +1,244 @@
|
|
1
|
+
// Generated by CoffeeScript 1.3.3
|
2
|
+
|
3
|
+
/*
|
4
|
+
jasmine-stealth 0.0.12
|
5
|
+
Makes Jasmine spies a bit more robust
|
6
|
+
site: https://github.com/searls/jasmine-stealth
|
7
|
+
*/
|
8
|
+
|
9
|
+
|
10
|
+
(function() {
|
11
|
+
var Captor, fake, root, unfakes, whatToDoWhenTheSpyGetsCalled, _,
|
12
|
+
__hasProp = {}.hasOwnProperty,
|
13
|
+
__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; };
|
14
|
+
|
15
|
+
root = this;
|
16
|
+
|
17
|
+
_ = function(obj) {
|
18
|
+
return {
|
19
|
+
each: function(iterator) {
|
20
|
+
var item, _i, _len, _results;
|
21
|
+
_results = [];
|
22
|
+
for (_i = 0, _len = obj.length; _i < _len; _i++) {
|
23
|
+
item = obj[_i];
|
24
|
+
_results.push(iterator(item));
|
25
|
+
}
|
26
|
+
return _results;
|
27
|
+
},
|
28
|
+
isFunction: function() {
|
29
|
+
return Object.prototype.toString.call(obj) === "[object Function]";
|
30
|
+
},
|
31
|
+
isString: function() {
|
32
|
+
return Object.prototype.toString.call(obj) === "[object String]";
|
33
|
+
}
|
34
|
+
};
|
35
|
+
};
|
36
|
+
|
37
|
+
root.spyOnConstructor = function(owner, classToFake, methodsToSpy) {
|
38
|
+
var fakeClass, spies;
|
39
|
+
if (methodsToSpy == null) {
|
40
|
+
methodsToSpy = [];
|
41
|
+
}
|
42
|
+
if (_(methodsToSpy).isString()) {
|
43
|
+
methodsToSpy = [methodsToSpy];
|
44
|
+
}
|
45
|
+
spies = {
|
46
|
+
constructor: jasmine.createSpy("" + classToFake + "'s constructor")
|
47
|
+
};
|
48
|
+
fakeClass = (function() {
|
49
|
+
|
50
|
+
function _Class() {
|
51
|
+
spies.constructor.apply(this, arguments);
|
52
|
+
}
|
53
|
+
|
54
|
+
return _Class;
|
55
|
+
|
56
|
+
})();
|
57
|
+
_(methodsToSpy).each(function(methodName) {
|
58
|
+
spies[methodName] = jasmine.createSpy("" + classToFake + "#" + methodName);
|
59
|
+
return fakeClass.prototype[methodName] = function() {
|
60
|
+
return spies[methodName].apply(this, arguments);
|
61
|
+
};
|
62
|
+
});
|
63
|
+
fake(owner, classToFake, fakeClass);
|
64
|
+
return spies;
|
65
|
+
};
|
66
|
+
|
67
|
+
unfakes = [];
|
68
|
+
|
69
|
+
afterEach(function() {
|
70
|
+
_(unfakes).each(function(u) {
|
71
|
+
return u();
|
72
|
+
});
|
73
|
+
return unfakes = [];
|
74
|
+
});
|
75
|
+
|
76
|
+
fake = function(owner, thingToFake, newThing) {
|
77
|
+
var originalThing;
|
78
|
+
originalThing = owner[thingToFake];
|
79
|
+
owner[thingToFake] = newThing;
|
80
|
+
return unfakes.push(function() {
|
81
|
+
return owner[thingToFake] = originalThing;
|
82
|
+
});
|
83
|
+
};
|
84
|
+
|
85
|
+
root.stubFor = root.spyOn;
|
86
|
+
|
87
|
+
jasmine.createStub = jasmine.createSpy;
|
88
|
+
|
89
|
+
jasmine.createStubObj = function(baseName, stubbings) {
|
90
|
+
var name, obj, stubbing;
|
91
|
+
if (stubbings.constructor === Array) {
|
92
|
+
return jasmine.createSpyObj(baseName, stubbings);
|
93
|
+
} else {
|
94
|
+
obj = {};
|
95
|
+
for (name in stubbings) {
|
96
|
+
stubbing = stubbings[name];
|
97
|
+
obj[name] = jasmine.createSpy(baseName + "." + name);
|
98
|
+
if (_(stubbing).isFunction()) {
|
99
|
+
obj[name].andCallFake(stubbing);
|
100
|
+
} else {
|
101
|
+
obj[name].andReturn(stubbing);
|
102
|
+
}
|
103
|
+
}
|
104
|
+
return obj;
|
105
|
+
}
|
106
|
+
};
|
107
|
+
|
108
|
+
whatToDoWhenTheSpyGetsCalled = function(spy) {
|
109
|
+
var matchesStub, priorStubbing;
|
110
|
+
matchesStub = function(stubbing, args, context) {
|
111
|
+
switch (stubbing.type) {
|
112
|
+
case "args":
|
113
|
+
return jasmine.getEnv().equals_(stubbing.ifThis, jasmine.util.argsToArray(args));
|
114
|
+
case "context":
|
115
|
+
return jasmine.getEnv().equals_(stubbing.ifThis, context);
|
116
|
+
}
|
117
|
+
};
|
118
|
+
priorStubbing = spy.plan();
|
119
|
+
return spy.andCallFake(function() {
|
120
|
+
var i, stubbing;
|
121
|
+
i = 0;
|
122
|
+
while (i < spy._stealth_stubbings.length) {
|
123
|
+
stubbing = spy._stealth_stubbings[i];
|
124
|
+
if (matchesStub(stubbing, arguments, this)) {
|
125
|
+
if (Object.prototype.toString.call(stubbing.thenThat) === "[object Function]") {
|
126
|
+
return stubbing.thenThat();
|
127
|
+
} else {
|
128
|
+
return stubbing.thenThat;
|
129
|
+
}
|
130
|
+
}
|
131
|
+
i++;
|
132
|
+
}
|
133
|
+
return priorStubbing;
|
134
|
+
});
|
135
|
+
};
|
136
|
+
|
137
|
+
jasmine.Spy.prototype.whenContext = function(context) {
|
138
|
+
var addStubbing, spy;
|
139
|
+
spy = this;
|
140
|
+
spy._stealth_stubbings || (spy._stealth_stubbings = []);
|
141
|
+
whatToDoWhenTheSpyGetsCalled(spy);
|
142
|
+
addStubbing = function(thenThat) {
|
143
|
+
spy._stealth_stubbings.push({
|
144
|
+
type: 'context',
|
145
|
+
ifThis: context,
|
146
|
+
thenThat: thenThat
|
147
|
+
});
|
148
|
+
return spy;
|
149
|
+
};
|
150
|
+
return {
|
151
|
+
thenReturn: addStubbing,
|
152
|
+
thenCallFake: addStubbing
|
153
|
+
};
|
154
|
+
};
|
155
|
+
|
156
|
+
jasmine.Spy.prototype.when = function() {
|
157
|
+
var addStubbing, ifThis, spy;
|
158
|
+
spy = this;
|
159
|
+
ifThis = jasmine.util.argsToArray(arguments);
|
160
|
+
spy._stealth_stubbings || (spy._stealth_stubbings = []);
|
161
|
+
whatToDoWhenTheSpyGetsCalled(spy);
|
162
|
+
addStubbing = function(thenThat) {
|
163
|
+
spy._stealth_stubbings.push({
|
164
|
+
type: 'args',
|
165
|
+
ifThis: ifThis,
|
166
|
+
thenThat: thenThat
|
167
|
+
});
|
168
|
+
return spy;
|
169
|
+
};
|
170
|
+
return {
|
171
|
+
thenReturn: addStubbing,
|
172
|
+
thenCallFake: addStubbing
|
173
|
+
};
|
174
|
+
};
|
175
|
+
|
176
|
+
jasmine.Spy.prototype.mostRecentCallThat = function(callThat, context) {
|
177
|
+
var i;
|
178
|
+
i = this.calls.length - 1;
|
179
|
+
while (i >= 0) {
|
180
|
+
if (callThat.call(context || this, this.calls[i]) === true) {
|
181
|
+
return this.calls[i];
|
182
|
+
}
|
183
|
+
i--;
|
184
|
+
}
|
185
|
+
};
|
186
|
+
|
187
|
+
jasmine.Matchers.ArgThat = (function(_super) {
|
188
|
+
|
189
|
+
__extends(ArgThat, _super);
|
190
|
+
|
191
|
+
function ArgThat(matcher) {
|
192
|
+
this.matcher = matcher;
|
193
|
+
}
|
194
|
+
|
195
|
+
ArgThat.prototype.jasmineMatches = function(actual) {
|
196
|
+
return this.matcher(actual);
|
197
|
+
};
|
198
|
+
|
199
|
+
return ArgThat;
|
200
|
+
|
201
|
+
})(jasmine.Matchers.Any);
|
202
|
+
|
203
|
+
jasmine.Matchers.ArgThat.prototype.matches = jasmine.Matchers.ArgThat.prototype.jasmineMatches;
|
204
|
+
|
205
|
+
jasmine.argThat = function(expected) {
|
206
|
+
return new jasmine.Matchers.ArgThat(expected);
|
207
|
+
};
|
208
|
+
|
209
|
+
jasmine.Matchers.Capture = (function(_super) {
|
210
|
+
|
211
|
+
__extends(Capture, _super);
|
212
|
+
|
213
|
+
function Capture(captor) {
|
214
|
+
this.captor = captor;
|
215
|
+
}
|
216
|
+
|
217
|
+
Capture.prototype.jasmineMatches = function(actual) {
|
218
|
+
this.captor.value = actual;
|
219
|
+
return true;
|
220
|
+
};
|
221
|
+
|
222
|
+
return Capture;
|
223
|
+
|
224
|
+
})(jasmine.Matchers.Any);
|
225
|
+
|
226
|
+
jasmine.Matchers.Capture.prototype.matches = jasmine.Matchers.Capture.prototype.jasmineMatches;
|
227
|
+
|
228
|
+
Captor = (function() {
|
229
|
+
|
230
|
+
function Captor() {}
|
231
|
+
|
232
|
+
Captor.prototype.capture = function() {
|
233
|
+
return new jasmine.Matchers.Capture(this);
|
234
|
+
};
|
235
|
+
|
236
|
+
return Captor;
|
237
|
+
|
238
|
+
})();
|
239
|
+
|
240
|
+
jasmine.captor = function() {
|
241
|
+
return new Captor();
|
242
|
+
};
|
243
|
+
|
244
|
+
}).call(this);
|
metadata
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jasmine-stealth-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.12
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Navin Peiris
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-02-02 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: jasmine-stealth for Rails 3.1 Asset Pipeline
|
15
|
+
email:
|
16
|
+
- navin.peiris@gmail.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- .gitignore
|
22
|
+
- Gemfile
|
23
|
+
- LICENSE.txt
|
24
|
+
- README.md
|
25
|
+
- Rakefile
|
26
|
+
- jasmine-stealth-rails.gemspec
|
27
|
+
- lib/jasmine-stealth-rails.rb
|
28
|
+
- lib/jasmine-stealth-rails/engine.rb
|
29
|
+
- lib/jasmine-stealth-rails/railtie.rb
|
30
|
+
- lib/jasmine-stealth-rails/version.rb
|
31
|
+
- vendor/assets/javascripts/jasmine-stealth.js
|
32
|
+
homepage: https://github.com/navinpeiris/jasmine-stealth-rails
|
33
|
+
licenses: []
|
34
|
+
post_install_message:
|
35
|
+
rdoc_options: []
|
36
|
+
require_paths:
|
37
|
+
- lib
|
38
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
45
|
+
none: false
|
46
|
+
requirements:
|
47
|
+
- - ! '>='
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
requirements: []
|
51
|
+
rubyforge_project:
|
52
|
+
rubygems_version: 1.8.25
|
53
|
+
signing_key:
|
54
|
+
specification_version: 3
|
55
|
+
summary: jasmine-stealth is a Jasmine helper that adds a little sugar to Jasmine's
|
56
|
+
spies developed by Justin Searls integrated for Rails 3.1 asset pipeline.
|
57
|
+
test_files: []
|