jasmine-sinon-railsbk 0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d56676e2ca7ad613fbccdd02ad9472f39b71bb97
4
+ data.tar.gz: 2971fd013ef8710b07a7dbaff71865041f88d7ca
5
+ SHA512:
6
+ metadata.gz: de7110dac709a5ade8d432f2dcf424f96479f15242f6813027b8578c487033d377ad223711a8fcd2f97c77a630779434782fcee7553fdc918fdd76f54990f290
7
+ data.tar.gz: 2591df086ee2fb29e8b9f03b466911c3a2e0ec79590d49d5faf29731fac757877461e7e613ca16f68e2d3cc4f417ea4d8c3e29cf7e0c65c86639e18435ca2538
data/.gitignore ADDED
@@ -0,0 +1,16 @@
1
+ *.rbc
2
+ *.sassc
3
+ .sass-cache
4
+ capybara-*.html
5
+ .rspec
6
+ /.bundle
7
+ /vendor/bundle
8
+ /log/*
9
+ /tmp/*
10
+ /db/*.sqlite3
11
+ /public/system/*
12
+ /coverage/
13
+ /spec/tmp/*
14
+ **.orig
15
+ rerun.txt
16
+ pickle-email-*.html
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Mihai Tarnovan
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,12 @@
1
+ jasmine-sinon-railsbk
2
+ =====================
3
+
4
+ I am taking jasmine-sinon matchers from https://github.com/froots/jasmine-sinon for the Rails 3.1+ asset pipeline and modifying it so I can use it with the latest version of sinon. I will get a PR out for the main on but I need this to work.
5
+
6
+ Installation
7
+ ============
8
+
9
+ 1. Add ```gem 'jasmine-sinon-railsbk'``` to your gemfile
10
+ 2. Run bundle install
11
+ 3. Add ```#= require jasmine-sinon``` to your spec manifest
12
+
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,16 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+ require File.expand_path('../lib/jasmine-sinon-railsbk/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Brendan Keogh"]
6
+ gem.email = ["bkeogh123@gmail.com"]
7
+ gem.summary = %q{jasmine-sinon.js matchers via Rails 3.2+ asset pipeline}
8
+ gem.homepage = "https://github.com/beekermememe/jasmine-sinon-railsbk"
9
+
10
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
11
+ gem.files = `git ls-files`.split("\n")
12
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
13
+ gem.name = "jasmine-sinon-railsbk"
14
+ gem.require_paths = ["lib"]
15
+ gem.version = Jasmine::Sinon::Railsbk::VERSION
16
+ end
@@ -0,0 +1,9 @@
1
+ require "jasmine-sinon-railsbk/version"
2
+
3
+ module Jasmine
4
+ module Sinon
5
+ module Railsbk
6
+ require 'jasmine-sinon-railsbk/engine' if defined?(Rails)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Jasmine
2
+ module Sinon
3
+ module Railsbk
4
+ class Engine < ::Rails::Engine
5
+ # making class enables assets pipeline
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,7 @@
1
+ module Jasmine
2
+ module Sinon
3
+ module Railsbk
4
+ VERSION = "0.1"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,222 @@
1
+ (function(jasmine, beforeEach) {
2
+ 'use strict';
3
+
4
+ var sinon;
5
+
6
+ if (typeof require === 'function' && typeof module === 'object') {
7
+ sinon = require('sinon');
8
+ } else {
9
+ sinon = window.sinon;
10
+ }
11
+
12
+ var messageFactories = {
13
+ spy: function(txt) {
14
+ return function(pass, spy) {
15
+ return messageUtils.expectedSpy(pass, spy, txt) + '.';
16
+ };
17
+ },
18
+ spyWithCallCount: function(txt) {
19
+ return function(pass, spy, otherArgs) {
20
+ return messageUtils.expectedSpy(pass, spy, txt) + '. ' +
21
+ messageUtils.callCount(spy) + '.';
22
+ };
23
+ },
24
+ spyWithOtherArgs: function(txt) {
25
+ return function(pass, spy, otherArgs) {
26
+ return messageUtils.expectedSpy(pass, spy, txt) + ' ' +
27
+ messageUtils.otherArgs(otherArgs);
28
+ };
29
+ }
30
+ };
31
+
32
+ var messageUtils = {
33
+ expectedSpy: function(pass, spy, txt) {
34
+ var not = (pass ? 'not ' : '');
35
+ var printf = spy.printf || sinon.spy.printf;
36
+ return printf.call(spy, 'Expected spy "%n" %1%2', not, txt);
37
+ },
38
+ callCount: function(spy) {
39
+ var printf = spy.printf || sinon.spy.printf;
40
+ return printf.call(spy, '"%n" was called %c');
41
+ },
42
+ otherArgs: function(otherArgs) {
43
+ if (!otherArgs || !otherArgs.length) {
44
+ return '';
45
+ } else if (otherArgs.length > 1) {
46
+ return jasmine.pp(otherArgs);
47
+ } else {
48
+ return jasmine.pp(otherArgs[0]);
49
+ }
50
+ }
51
+ };
52
+
53
+ var matchers = [
54
+ {
55
+ sinonName: 'called',
56
+ jasmineName: 'toHaveBeenCalled',
57
+ message: messageFactories.spyWithCallCount('to have been called')
58
+ },
59
+ {
60
+ sinonName: 'calledOnce',
61
+ jasmineName: 'toHaveBeenCalledOnce',
62
+ message: messageFactories.spyWithCallCount('to have been called once')
63
+ },
64
+ {
65
+ sinonName: 'calledTwice',
66
+ jasmineName: 'toHaveBeenCalledTwice',
67
+ message: messageFactories.spyWithCallCount('to have been called twice')
68
+ },
69
+ {
70
+ sinonName: 'calledThrice',
71
+ jasmineName: 'toHaveBeenCalledThrice',
72
+ message: messageFactories.spyWithCallCount('to have been called thrice')
73
+ },
74
+ {
75
+ sinonName: 'calledBefore',
76
+ jasmineName: 'toHaveBeenCalledBefore',
77
+ message: messageFactories.spyWithOtherArgs('to have been called before')
78
+ },
79
+ {
80
+ sinonName: 'calledAfter',
81
+ jasmineName: 'toHaveBeenCalledAfter',
82
+ message: messageFactories.spyWithOtherArgs('to have been called after')
83
+ },
84
+ {
85
+ sinonName: 'calledOn',
86
+ jasmineName: 'toHaveBeenCalledOn',
87
+ message: messageFactories.spyWithOtherArgs('to have been called on')
88
+ },
89
+ {
90
+ sinonName: 'alwaysCalledOn',
91
+ jasmineName: 'toHaveBeenAlwaysCalledOn',
92
+ message: messageFactories.spyWithOtherArgs('to have been always called on')
93
+ },
94
+ {
95
+ sinonName: 'calledWith',
96
+ jasmineName: 'toHaveBeenCalledWith',
97
+ message: messageFactories.spyWithOtherArgs('to have been called with')
98
+ },
99
+ {
100
+ sinonName: 'alwaysCalledWith',
101
+ jasmineName: 'toHaveBeenAlwaysCalledWith',
102
+ message: messageFactories.spyWithOtherArgs('to have been always called with')
103
+ },
104
+ {
105
+ sinonName: 'calledWithExactly',
106
+ jasmineName: 'toHaveBeenCalledWithExactly',
107
+ message: messageFactories.spyWithOtherArgs('to have been called with exactly')
108
+ },
109
+ {
110
+ sinonName: 'alwaysCalledWithExactly',
111
+ jasmineName: 'toHaveBeenAlwaysCalledWithExactly',
112
+ message: messageFactories.spyWithOtherArgs('to have been always called with exactly')
113
+ },
114
+ {
115
+ sinonName: 'calledWithMatch',
116
+ jasmineName: 'toHaveBeenCalledWithMatch',
117
+ message: messageFactories.spyWithOtherArgs('to have been called with match')
118
+ },
119
+ {
120
+ sinonName: 'alwaysCalledWithMatch',
121
+ jasmineName: 'toHaveBeenAlwaysCalledWithMatch',
122
+ message: messageFactories.spyWithOtherArgs('to have been always called with match')
123
+ },
124
+ {
125
+ sinonName: 'calledWithNew',
126
+ jasmineName: 'toHaveBeenCalledWithNew',
127
+ message: messageFactories.spy('to have been called with new')
128
+ },
129
+ {
130
+ sinonName: 'neverCalledWith',
131
+ jasmineName: 'toHaveBeenNeverCalledWith',
132
+ message: messageFactories.spyWithOtherArgs('to have been never called with')
133
+ },
134
+ {
135
+ sinonName: 'neverCalledWithMatch',
136
+ jasmineName: 'toHaveBeenNeverCalledWithMatch',
137
+ message: messageFactories.spyWithOtherArgs('to have been never called with match')
138
+ },
139
+ {
140
+ sinonName: 'threw',
141
+ jasmineName: 'toHaveThrown',
142
+ message: messageFactories.spyWithOtherArgs('to have thrown an error')
143
+ },
144
+ {
145
+ sinonName: 'alwaysThrew',
146
+ jasmineName: 'toHaveAlwaysThrown',
147
+ message: messageFactories.spyWithOtherArgs('to have always thrown an error')
148
+ },
149
+ {
150
+ sinonName: 'returned',
151
+ jasmineName: 'toHaveReturned',
152
+ message: messageFactories.spyWithOtherArgs('to have returned')
153
+ },
154
+ {
155
+ sinonName: 'alwaysReturned',
156
+ jasmineName: 'toHaveAlwaysReturned',
157
+ message: messageFactories.spyWithOtherArgs('to have always returned')
158
+ }
159
+ ];
160
+
161
+ function createCustomMatcher(arg, util, customEqualityTesters) {
162
+ return sinon.match(function (val) {
163
+ return util.equals(val, arg, customEqualityTesters);
164
+ });
165
+ }
166
+
167
+ function createMatcher(matcher) {
168
+ var original = jasmine.matchers[matcher.jasmineName];
169
+
170
+ return function (util, customEqualityTesters) {
171
+ return {
172
+ compare: function() {
173
+ var sinonProperty, arg, pass;
174
+ var args = [].slice.call(arguments, 0);
175
+ var actual = args[0];
176
+
177
+ if (jasmine.isSpy(actual) && original) {
178
+ return original(util, customEqualityTesters).compare.apply(null, args);
179
+ }
180
+
181
+ for (var i = 0, len = args.length; i < len; i++) {
182
+ arg = args[i];
183
+ if (arg && (typeof arg.jasmineMatches === 'function' || arg instanceof jasmine.ObjectContaining)) {
184
+ args[i] = createCustomMatcher(arg, util, customEqualityTesters);
185
+ }
186
+ }
187
+
188
+ sinonProperty = actual[matcher.sinonName];
189
+
190
+ if (typeof sinonProperty === 'function') {
191
+ pass = sinonProperty.apply(actual, args.slice(1));
192
+ } else {
193
+ pass = sinonProperty;
194
+ }
195
+
196
+ return {
197
+ pass: pass,
198
+ message: matcher.message(pass, actual, args.slice(1))
199
+ };
200
+ }
201
+ };
202
+ };
203
+ }
204
+
205
+ function createJasmineSinonMatchers(matchers) {
206
+ var matcher, jasmineSinonMatchers = {};
207
+ for (var i = 0, len = matchers.length; i < len; i++) {
208
+ matcher = matchers[i];
209
+ jasmineSinonMatchers[matcher.jasmineName] = createMatcher(matcher);
210
+ }
211
+ return jasmineSinonMatchers;
212
+ }
213
+
214
+ beforeEach(function() {
215
+ jasmine.addMatchers(createJasmineSinonMatchers(matchers));
216
+ });
217
+
218
+ jasmine.jasmineSinon = {
219
+ messageFactories: messageFactories
220
+ };
221
+
222
+ })(jasmine, beforeEach);
metadata ADDED
@@ -0,0 +1,53 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jasmine-sinon-railsbk
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ platform: ruby
6
+ authors:
7
+ - Brendan Keogh
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-02 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email:
15
+ - bkeogh123@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - ".gitignore"
21
+ - Gemfile
22
+ - LICENSE
23
+ - README.md
24
+ - Rakefile
25
+ - jasmine-sinon-railsbk.gemspec
26
+ - lib/jasmine-sinon-railsbk.rb
27
+ - lib/jasmine-sinon-railsbk/engine.rb
28
+ - lib/jasmine-sinon-railsbk/version.rb
29
+ - vendor/assets/javascripts/jasmine-sinon.js
30
+ homepage: https://github.com/beekermememe/jasmine-sinon-railsbk
31
+ licenses: []
32
+ metadata: {}
33
+ post_install_message:
34
+ rdoc_options: []
35
+ require_paths:
36
+ - lib
37
+ required_ruby_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ required_rubygems_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ requirements: []
48
+ rubyforge_project:
49
+ rubygems_version: 2.4.3
50
+ signing_key:
51
+ specification_version: 4
52
+ summary: jasmine-sinon.js matchers via Rails 3.2+ asset pipeline
53
+ test_files: []