modularity-rails 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. data/.travis.yml +4 -6
  2. data/Guardfile +3 -4
  3. data/demo/.gitignore +15 -0
  4. data/demo/Gemfile +23 -0
  5. data/demo/README.rdoc +261 -0
  6. data/demo/Rakefile +7 -0
  7. data/demo/app/assets/images/rails.png +0 -0
  8. data/demo/app/assets/javascripts/application.coffee +2 -0
  9. data/demo/app/assets/stylesheets/application.css +13 -0
  10. data/demo/app/controllers/application_controller.rb +3 -0
  11. data/demo/app/helpers/application_helper.rb +2 -0
  12. data/demo/app/mailers/.gitkeep +0 -0
  13. data/demo/app/models/.gitkeep +0 -0
  14. data/demo/app/views/layouts/application.html.erb +14 -0
  15. data/demo/config.ru +4 -0
  16. data/demo/config/application.rb +59 -0
  17. data/demo/config/boot.rb +6 -0
  18. data/demo/config/database.yml +25 -0
  19. data/demo/config/environment.rb +5 -0
  20. data/demo/config/environments/development.rb +37 -0
  21. data/demo/config/environments/production.rb +67 -0
  22. data/demo/config/environments/test.rb +37 -0
  23. data/demo/config/initializers/backtrace_silencers.rb +7 -0
  24. data/demo/config/initializers/inflections.rb +15 -0
  25. data/demo/config/initializers/konacha.rb +5 -0
  26. data/demo/config/initializers/mime_types.rb +5 -0
  27. data/demo/config/initializers/secret_token.rb +7 -0
  28. data/demo/config/initializers/session_store.rb +8 -0
  29. data/demo/config/initializers/wrap_parameters.rb +14 -0
  30. data/demo/config/locales/en.yml +5 -0
  31. data/demo/config/routes.rb +58 -0
  32. data/demo/db/seeds.rb +7 -0
  33. data/demo/lib/assets/.gitkeep +0 -0
  34. data/demo/lib/tasks/.gitkeep +0 -0
  35. data/demo/log/.gitkeep +0 -0
  36. data/demo/public/404.html +26 -0
  37. data/demo/public/422.html +26 -0
  38. data/demo/public/500.html +25 -0
  39. data/demo/public/favicon.ico +0 -0
  40. data/demo/public/index.html +241 -0
  41. data/demo/public/robots.txt +5 -0
  42. data/demo/script/rails +6 -0
  43. data/demo/spec/javascripts/konacha_config.coffee +1 -0
  44. data/demo/spec/javascripts/mixins/closable_spec.coffee +98 -0
  45. data/{spec → demo/spec}/javascripts/modularity_spec.coffee +118 -109
  46. data/demo/spec/javascripts/modules/autogrow_textarea_spec.coffee +43 -0
  47. data/demo/spec/javascripts/modules/button_spec.coffee +39 -0
  48. data/demo/spec/javascripts/modules/counter_button_spec.coffee +57 -0
  49. data/demo/spec/javascripts/sinon-chai.js +116 -0
  50. data/demo/spec/javascripts/sinon.js +3555 -0
  51. data/demo/spec/javascripts/spec_helper.coffee +11 -0
  52. data/demo/spec/javascripts/templates/autogrow_textarea.jst.ejs +2 -0
  53. data/{spec/javascripts/templates/button.html → demo/spec/javascripts/templates/button.jst.ejs} +0 -0
  54. data/{spec/javascripts/templates/closable.html → demo/spec/javascripts/templates/closable.jst.ejs} +0 -0
  55. data/{spec/javascripts/templates/test.html → demo/spec/javascripts/templates/modularity.jst.ejs} +0 -0
  56. data/{spec → demo/spec}/javascripts/tools/ajax_loader_spec.coffee +21 -27
  57. data/{spec → demo/spec}/javascripts/tools/cache_spec.coffee +13 -18
  58. data/demo/vendor/assets/javascripts/.gitkeep +0 -0
  59. data/demo/vendor/assets/stylesheets/.gitkeep +0 -0
  60. data/demo/vendor/plugins/.gitkeep +0 -0
  61. data/lib/modularity-rails/version.rb +1 -1
  62. data/run_tests +6 -0
  63. data/vendor/assets/javascripts/modularity.js.coffee +2 -1
  64. data/vendor/assets/javascripts/modules/autogrow_textarea.coffee +31 -0
  65. data/vendor/assets/javascripts/modules/counter_button.coffee +2 -0
  66. metadata +73 -26
  67. data/spec/javascripts/external/coffee-script.js +0 -8
  68. data/spec/javascripts/external/jasmine-jquery.js +0 -288
  69. data/spec/javascripts/external/jquery.min.js +0 -4
  70. data/spec/javascripts/mixins/closable_spec.coffee +0 -101
  71. data/spec/javascripts/modules/button_spec.coffee +0 -45
  72. data/spec/javascripts/modules/counter_button_spec.coffee +0 -64
  73. data/spec/javascripts/spec_helper.coffee +0 -22
@@ -0,0 +1,5 @@
1
+ # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
2
+ #
3
+ # To ban all spiders from the entire site uncomment the next two lines:
4
+ # User-Agent: *
5
+ # Disallow: /
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
+ require 'rails/commands'
@@ -0,0 +1 @@
1
+ Konacha.mochaOptions.ignoreLeaks = true
@@ -0,0 +1,98 @@
1
+ #= require spec_helper
2
+ #= require mixins/closable
3
+
4
+ # A standard closable module.
5
+ class window.ClosableModule1 extends modularity.Module
6
+ @mixin modularity.closable
7
+
8
+
9
+ describe 'Closable', ->
10
+
11
+ spy_alert = null
12
+ beforeEach ->
13
+ template 'closable'
14
+ spy_alert = sinon.stub window, 'alert'
15
+
16
+ afterEach ->
17
+ spy_alert.restore()
18
+
19
+ describe 'constructor', ->
20
+ it 'shows an alert if there is no close button', ->
21
+ new ClosableModule1('#konacha #closable3')
22
+ window.alert.should.have.been.called
23
+ window.alert.args[0][0].should.match(/close button not found/i)
24
+
25
+ it 'shows no alert if there is a close button', ->
26
+ new ClosableModule1('#konacha #closable1')
27
+ window.alert.should.not.have.been.called
28
+
29
+ it 'finds the close button div automatically', ->
30
+ new ClosableModule1('#konacha #closable1')
31
+ $('#konacha #closable1 .CloseButton').click()
32
+ $('#konacha #closable1').should.have.length 0
33
+
34
+
35
+ describe 'when clicking the close button', ->
36
+
37
+ it "calls the closable_closing hook on the object if it exists", ->
38
+
39
+ # A closable module with the 'closing' hook.
40
+ class ClosableModule extends modularity.Module
41
+ @mixin modularity.closable
42
+
43
+ constructor: ->
44
+ super
45
+ @closing_hook_got_called = no
46
+
47
+ closable_closing: => @closing_hook_got_called = yes
48
+
49
+ module = new ClosableModule('#konacha #closable1')
50
+ $('#konacha #closable1 .CloseButton').click()
51
+ module.closing_hook_got_called.should.be.true
52
+
53
+
54
+ it "calls the closable_closed hook on the object if it exists", ->
55
+
56
+ # A closable module with the 'closed' hook.
57
+ class ClosableModule extends modularity.Module
58
+ @mixin modularity.closable
59
+
60
+ constructor: ->
61
+ super
62
+ @closed_hook_got_called = no
63
+
64
+ closable_closed: => @closed_hook_got_called = yes
65
+
66
+ module = new ClosableModule('#konacha #closable1')
67
+ $('#konacha #closable1 .CloseButton').click()
68
+ module.closed_hook_got_called.should.be.true
69
+
70
+
71
+ it "aborts the close operation if the closable_closing method returns false", ->
72
+
73
+ class ClosableModuleWithHookThatReturnsFalse extends modularity.Module
74
+ @mixin modularity.closable
75
+ closable_closing: -> false
76
+
77
+ module = new ClosableModuleWithHookThatReturnsFalse('#konacha #closable1')
78
+ module.bind_event('closed', (spy = sinon.spy()))
79
+
80
+ $('#konacha #closable1 .CloseButton').click()
81
+
82
+ spy.should.not.have.been.called
83
+
84
+
85
+ it 'removes the container', ->
86
+ new ClosableModule1('#konacha #closable1')
87
+ $('#konacha #closable1 .CloseButton').click()
88
+
89
+ $('#konacha #closable1').should.have.length 0
90
+
91
+
92
+ it "fires the 'closed' event", ->
93
+ closable_module = new ClosableModule1('#konacha #closable1')
94
+ closable_module.bind_event('closed', (spy = sinon.spy()))
95
+
96
+ $('#konacha #closable1 .CloseButton').click()
97
+
98
+ spy.should.have.been.calledOnce
@@ -1,267 +1,270 @@
1
1
  #= require spec_helper
2
2
 
3
- describe 'setting up test environment', ->
3
+ class window.TestModule extends modularity.Module
4
4
 
5
- it 'loading libraries', ->
6
- load_modularity()
7
5
 
8
- it 'defining test classes', ->
9
-
10
- class window.TestModule extends modularity.Module
11
- constructor: (container) ->
12
- super
6
+ describe 'modularity', ->
13
7
 
8
+ alert_stub = null
9
+ beforeEach ->
10
+ template 'modularity'
11
+ alert_stub = sinon.stub window, 'alert'
14
12
 
15
- describe 'modularity', ->
13
+ afterEach ->
14
+ alert_stub.restore()
16
15
 
17
- template 'test.html'
18
16
 
19
17
  describe 'constructor', ->
20
18
 
21
- beforeEach ->
22
- spyOn window, 'alert'
23
-
24
19
  it "is defined on the 'window' object", ->
25
- expect(modularity.Module).not.toBeUndefined()
20
+ modularity.Module.should.not.be.undefined
26
21
 
27
22
  it 'shows an error if no container is given', ->
28
23
  new TestModule()
29
- expect(alert).toHaveBeenCalled()
24
+ window.alert.should.have.been.called
30
25
 
31
26
  it 'tries to load the DOM if the given container is a string', ->
32
- new TestModule('#test #module_container')
33
- expect(alert).not.toHaveBeenCalled()
27
+ new TestModule('#konacha #module_container')
28
+ window.alert.should.not.have.been.called
34
29
 
35
30
  it 'shows an error if the container is not a jQuery object', ->
36
31
  new TestModule({})
37
- expect(alert).toHaveBeenCalled()
32
+ window.alert.should.have.been.called
38
33
 
39
34
  it 'shows an error if the container is an empty jQuery object', ->
40
- new TestModule($('#test .zonk'))
41
- expect(alert).toHaveBeenCalled()
35
+ new TestModule($('#konacha .zonk'))
36
+ window.alert.should.have.been.called
42
37
 
43
38
  it 'shows an error if the container has more than one elements', ->
44
- new TestModule($('#test .double'))
45
- expect(alert).toHaveBeenCalled()
39
+ new TestModule($('#konacha .double'))
40
+ window.alert.should.have.been.called
46
41
 
47
42
  it "allows to provide 'testing' in tests", ->
48
43
  new TestModule('testing')
49
- expect(alert).not.toHaveBeenCalled()
44
+ window.alert.should.not.have.been.called
50
45
 
51
46
 
52
47
  describe 'assert', ->
53
48
 
54
- beforeEach ->
55
- spyOn window, 'alert'
56
-
57
49
  it 'shows an alert with the given message if the given condition is false', ->
58
50
  modularity.assert false, 'Message'
59
- expect(alert).toHaveBeenCalledWith("Message")
51
+ window.alert.should.have.been.calledWith "Message"
60
52
 
61
53
  it 'fails when the condition is null', ->
62
54
  modularity.assert null, 'Message'
63
- expect(alert).toHaveBeenCalledWith("Message")
55
+ window.alert.should.have.been.calledWith "Message"
64
56
 
65
57
  it 'fails when the condition is undefined', ->
66
58
  modularity.assert undefined, 'Message'
67
- expect(alert).toHaveBeenCalledWith("Message")
59
+ window.alert.should.have.been.calledWith "Message"
68
60
 
69
61
  it 'fails when the condition is an empty array', ->
70
62
  modularity.assert [], 'Message'
71
- expect(alert).toHaveBeenCalledWith("Message")
63
+ window.alert.should.have.been.calledWith "Message"
72
64
 
73
65
  it 'fails when the condition is an empty string', ->
74
66
  modularity.assert '', 'Message'
75
- expect(alert).toHaveBeenCalledWith("Message")
67
+ window.alert.should.have.been.calledWith "Message"
76
68
 
77
69
  it 'passes when the condition is a string', ->
78
70
  modularity.assert '123', 'Message'
79
- expect(alert).not.toHaveBeenCalled()
71
+ window.alert.should.not.have.been.called
80
72
 
81
73
  it "returns false if the condition doesn't pass", ->
82
- expect(modularity.assert(false)).toBeFalsy()
74
+ modularity.assert(false).should.be.false
83
75
 
84
76
  it "returns true if the condition passes", ->
85
- expect(modularity.assert('123')).toBeTruthy()
77
+ modularity.assert('123').should.be.true
86
78
 
87
79
 
88
80
  describe 'jQuery Integration', ->
89
81
 
90
- beforeEach ->
91
- spyOn window, 'alert'
92
-
93
82
  it 'works', ->
94
- $('#test #module_container').module(TestModule)
95
- expect(alert).not.toHaveBeenCalled()
83
+ $('#konacha #module_container').module(TestModule)
84
+ window.alert.should.not.have.been.called
96
85
 
97
86
  it 'returns the created instance', ->
98
- result = $('#test #module_container').module(modularity.Module)
99
- expect(result).toBeDefined()
100
- expect(typeof result).toEqual('object')
87
+ result = $('#konacha #module_container').module(modularity.Module)
88
+ result.should.exist
89
+ result.should.be.instanceOf modularity.Module
101
90
 
102
91
  it 'returns an error if the given parameter is not a class', ->
103
- $('#test').module()
104
- expect(alert).toHaveBeenCalled()
92
+ $('#konacha').module()
93
+ window.alert.should.have.been.called
105
94
 
106
95
  it 'returns an error if the jQuery object is empty.', ->
107
- $('#test #zonk').module(modularity.Module)
108
- expect(alert).toHaveBeenCalled()
96
+ $('#konacha #zonk').module(modularity.Module)
97
+ window.alert.should.have.been.called
109
98
 
110
99
 
111
100
  describe 'event handling', ->
112
101
 
113
- # Variables that should be accessible in both the beforeEach block and the tests.
114
102
  module = null
115
103
  mockContainer = null
116
104
 
117
105
  beforeEach ->
118
- mockContainer = $('#test #module_container')
106
+ mockContainer = $('#konacha #module_container')
119
107
  module = new TestModule(mockContainer)
120
- spyOn window, 'alert'
121
-
122
108
 
123
109
  describe 'bind_event', ->
124
110
 
125
111
  beforeEach ->
126
- spyOn mockContainer, 'bind'
112
+ sinon.spy mockContainer, 'bind'
127
113
 
128
114
  it 'binds the given custom jQuery event type and the given callback to the container', ->
129
115
  myCallback = ->
130
116
  module.bind_event 'myEventType', myCallback
131
- expect(mockContainer.bind).toHaveBeenCalledWith('myEventType', myCallback)
132
- expect(window.alert).not.toHaveBeenCalled()
117
+ mockContainer.bind.should.have.been.called
118
+ mockContainer.bind.args[0][0].should.equal 'myEventType'
119
+ mockContainer.bind.args[0][1].should.equal myCallback
120
+ window.alert.should.not.have.been.called
133
121
 
134
122
  it "throws an error if no parameters are given", ->
135
123
  module.bind_event()
136
- expect(window.alert).toHaveBeenCalled()
137
- expect(mockContainer.bind).not.toHaveBeenCalled()
124
+ window.alert.should.have.been.called
125
+ mockContainer.bind.should.not.have.been.called
138
126
 
139
127
  it "throws an error if the given event type doesn't exist", ->
140
128
  module.bind_event undefined, ->
141
- expect(window.alert).toHaveBeenCalled()
142
- expect(mockContainer.bind).not.toHaveBeenCalled()
129
+ window.alert.should.have.been.called
130
+ mockContainer.bind.should.not.have.been.called
143
131
 
144
132
  it 'throws an error if the given event type is not a string', ->
145
133
  module.bind_event {}, ->
146
- expect(window.alert).toHaveBeenCalled()
147
- expect(mockContainer.bind).not.toHaveBeenCalled()
134
+ window.alert.should.have.been.called
135
+ mockContainer.bind.should.not.have.been.called
148
136
 
149
137
  it "throws an error if the given callback doesn't exist", ->
150
138
  module.bind_event '123'
151
- expect(window.alert).toHaveBeenCalled()
152
- expect(mockContainer.bind).not.toHaveBeenCalled()
139
+ window.alert.should.have.been.called
140
+ mockContainer.bind.should.not.have.been.called
153
141
 
154
142
  it 'throws an error if the given callback is not a function', ->
155
143
  module.bind_event '123', {}
156
- expect(window.alert).toHaveBeenCalled()
157
- expect(mockContainer.bind).not.toHaveBeenCalled()
144
+ window.alert.should.have.been.called
145
+ mockContainer.bind.should.not.have.been.called
158
146
 
159
147
 
160
148
  describe 'fire_event', ->
161
149
 
162
150
  beforeEach ->
163
- spyOn mockContainer, 'trigger'
151
+ sinon.spy mockContainer, 'trigger'
164
152
 
165
153
  it 'triggers a custom jQuery event with the given event type on the container object', ->
166
154
  module.fire_event 'event type', 'event data'
167
- expect(mockContainer.trigger).toHaveBeenCalledWith('event type', 'event data')
155
+ mockContainer.trigger.should.have.been.called
156
+ mockContainer.trigger.args[0][0].should.equal 'event type'
157
+ mockContainer.trigger.args[0][1].should.equal 'event data'
168
158
 
169
159
  describe 'when no payload is given', ->
170
160
  it 'provides an empty object as payload', ->
171
161
  module.fire_event 'event type'
172
- expect(mockContainer.trigger).toHaveBeenCalled()
173
- expect(mockContainer.trigger.argsForCall[0][1]).toEqual({})
162
+ mockContainer.trigger.should.have.been.called
163
+ mockContainer.trigger.args[0][1].should.eql({})
174
164
 
175
165
  it "doesn't change the original payload variable", ->
176
166
  data = undefined
177
167
  module.fire_event 'event type', data
178
- expect(data).toBeUndefined
168
+ expect(data).to.be.undefined
179
169
 
180
170
  it 'provides 0 as payload if 0 is given', ->
181
171
  module.fire_event 'event type', 0
182
- expect(mockContainer.trigger).toHaveBeenCalled()
183
- expect(mockContainer.trigger.argsForCall[0][1]).toEqual(0)
172
+ mockContainer.trigger.should.have.been.called
173
+ mockContainer.trigger.args[0][1].should.equal(0)
184
174
 
185
175
  it 'throws an error if the given event type is not a string', ->
186
176
  module.fire_event {}
187
- expect(mockContainer.trigger).not.toHaveBeenCalled()
188
- expect(window.alert).toHaveBeenCalled()
177
+ mockContainer.trigger.should.not.have.been.called
178
+ window.alert.should.have.been.called
189
179
 
190
180
 
191
181
  describe 'global events', ->
192
182
 
193
- # Variables that should be accessible in both the beforeEach block and the tests.
194
183
  mockGlobalContainer = null
195
-
196
184
  beforeEach ->
197
185
  mockGlobalContainer = $('#test #module_container')
198
- spyOn(modularity, 'global_event_container').andReturn(mockGlobalContainer)
186
+ sinon.stub(modularity, 'global_event_container').returns(mockGlobalContainer)
187
+
188
+ afterEach ->
189
+ modularity.global_event_container.restore()
190
+
199
191
 
200
192
  describe 'bind_global_event', ->
201
193
 
202
194
  beforeEach ->
203
- spyOn mockGlobalContainer, 'bind'
195
+ sinon.spy mockGlobalContainer, 'bind'
196
+
197
+ afterEach ->
198
+ mockGlobalContainer.bind.restore()
204
199
 
205
200
  it 'binds the given event type and callback method to the global event container', ->
206
201
  callback = ->
207
202
  modularity.bind_global_event '123', callback
208
- expect(mockGlobalContainer.bind).toHaveBeenCalledWith('123', callback)
203
+ mockGlobalContainer.bind.should.have.been.called
204
+ mockGlobalContainer.bind.args[0][0].should.equal '123'
205
+ mockGlobalContainer.bind.args[0][1].should.equal callback
209
206
 
210
207
  it "throws an error if no parameters are given", ->
211
208
  modularity.bind_global_event()
212
- expect(window.alert).toHaveBeenCalled()
213
- expect(mockGlobalContainer.bind).not.toHaveBeenCalled()
209
+ window.alert.should.have.been.called
210
+ mockGlobalContainer.bind.should.not.have.been.called
214
211
 
215
212
  it "throws an error if the given event type doesn't exist", ->
216
213
  modularity.bind_global_event undefined, ->
217
- expect(window.alert).toHaveBeenCalled()
218
- expect(mockGlobalContainer.bind).not.toHaveBeenCalled()
214
+ window.alert.should.have.been.called
215
+ mockGlobalContainer.bind.should.not.have.been.called
219
216
 
220
217
  it 'throws an error if the given event type is not a string', ->
221
218
  modularity.bind_global_event {}, ->
222
- expect(window.alert).toHaveBeenCalled()
223
- expect(mockGlobalContainer.bind).not.toHaveBeenCalled()
219
+ window.alert.should.have.been.called
220
+ mockGlobalContainer.bind.should.not.have.been.called
224
221
 
225
222
  it "throws an error if the given callback doesn't exist", ->
226
223
  modularity.bind_global_event '123'
227
- expect(window.alert).toHaveBeenCalled()
228
- expect(mockGlobalContainer.bind).not.toHaveBeenCalled()
224
+ window.alert.should.have.been.called
225
+ mockGlobalContainer.bind.should.not.have.been.called
229
226
 
230
227
  it 'throws an error if the given callback is not a function', ->
231
228
  modularity.bind_global_event '123', {}
232
- expect(window.alert).toHaveBeenCalled()
233
- expect(mockGlobalContainer.bind).not.toHaveBeenCalled()
229
+ window.alert.should.have.been.called
230
+ mockGlobalContainer.bind.should.not.have.been.called
234
231
 
235
232
 
236
233
  describe 'fire_global_event', ->
237
234
 
238
235
  beforeEach ->
239
- spyOn mockGlobalContainer, 'trigger'
236
+ sinon.spy mockGlobalContainer, 'trigger'
237
+
238
+ afterEach ->
239
+ mockGlobalContainer.trigger.restore()
240
+
240
241
 
241
242
  it 'triggers a custom jQuery event with the given event type on the global event container object', ->
242
243
  modularity.fire_global_event 'event type', 'event data'
243
- expect(mockGlobalContainer.trigger).toHaveBeenCalledWith('event type', 'event data')
244
+ mockGlobalContainer.trigger.should.have.been.called
245
+ mockGlobalContainer.trigger.args[0][0].should.equal 'event type'
246
+ mockGlobalContainer.trigger.args[0][1].should.equal 'event data'
244
247
 
245
248
  describe 'when no payload is given', ->
246
249
  it 'provides an empty object as payload', ->
247
250
  modularity.fire_global_event 'event type'
248
- expect(mockGlobalContainer.trigger).toHaveBeenCalled()
249
- expect(mockGlobalContainer.trigger.argsForCall[0][1]).toEqual({})
251
+ mockGlobalContainer.trigger.should.have.been.called
252
+ mockGlobalContainer.trigger.args[0][1].should.eql({})
250
253
 
251
254
  it "doesn't change the original payload variable", ->
252
255
  data = undefined
253
256
  modularity.fire_global_event 'event type', data
254
- expect(data).toBeUndefined
257
+ expect(data).to.equal.undefined
255
258
 
256
259
  it 'provides 0 as payload if 0 is given', ->
257
260
  modularity.fire_global_event 'event type', 0
258
- expect(mockGlobalContainer.trigger).toHaveBeenCalled()
259
- expect(mockGlobalContainer.trigger.argsForCall[0][1]).toEqual(0)
261
+ mockGlobalContainer.trigger.should.have.been.called
262
+ mockGlobalContainer.trigger.args[0][1].should.equal(0)
260
263
 
261
264
  it 'throws an error if the given event type is not a string', ->
262
265
  modularity.fire_global_event {}
263
- expect(mockGlobalContainer.trigger).not.toHaveBeenCalled()
264
- expect(window.alert).toHaveBeenCalled()
266
+ mockGlobalContainer.trigger.should.not.have.been.called
267
+ window.alert.should.have.been.called
265
268
 
266
269
 
267
270
  describe 'mixins', ->
@@ -277,35 +280,41 @@ describe 'modularity', ->
277
280
  @mixin myMixin
278
281
 
279
282
 
280
-
281
283
  it 'adds all methods from the mixin object to the class prototype', ->
282
284
  instance = new Test('testing')
283
- expect(typeof instance.method1).toBe("function")
285
+ instance.method1.should.be.a("function")
284
286
 
285
287
 
286
288
  it 'calls the proper mixin method when calling from the implementing module', ->
287
- spyOn(myMixin, 'method1')
288
- spyOn(myMixin, 'method2')
289
+ sinon.spy myMixin, 'method1'
290
+ sinon.spy myMixin, 'method2'
289
291
  instance = new Test('testing')
290
292
  instance.method1()
291
- expect(myMixin.method1).toHaveBeenCalled()
292
- expect(myMixin.method2).not.toHaveBeenCalled()
293
+ myMixin.method1.should.have.been.called
294
+ myMixin.method2.should.not.have.been.called
295
+ myMixin.method1.restore()
296
+ myMixin.method2.restore()
293
297
 
294
298
  it 'calls the mixin with the proper paramaters', ->
295
- spyOn(myMixin, 'method1')
299
+ sinon.spy myMixin, 'method1'
296
300
  instance = new Test('testing')
297
301
  instance.method1("arg1", "arg2")
298
- expect(myMixin.method1).toHaveBeenCalledWith("arg1", "arg2")
302
+ myMixin.method1.should.have.been.calledWith("arg1", "arg2")
303
+ myMixin.method1.restore()
299
304
 
300
305
 
301
306
  it 'calls the constructor of the mixin', ->
302
- spyOn(myMixin, 'constructor')
307
+ sinon.spy myMixin, 'constructor'
303
308
  instance = new Test('testing')
304
- expect(myMixin.constructor).toHaveBeenCalled()
309
+ myMixin.constructor.should.have.been.called
305
310
 
306
311
 
307
- it 'calls the constructor with the this pointing to the instance', ->
312
+ it 'calls the constructor with the this object pointing to the instance', ->
308
313
  instance = new Test('testing')
309
- expect(recordedSelf).toBe(instance)
314
+ recordedSelf.should.equal instance
315
+
316
+ it "can handle mixins that don't define a constructor"
317
+
318
+ it "shows an error message if the given mixin is undefined"
310
319
 
311
- xit 'provides arguments to the @mixin method to the mixin constructor'
320
+ it 'provides arguments to the @mixin method to the mixin constructor'