Skip to content

Commit

Permalink
Handle a couple edge-cases
Browse files Browse the repository at this point in the history
If jQuery isn't loaded until after jasmine-fixture:
* allow subsequent calls to affix() to correct for this
by initializing jasmineFixture if jQuery is available
at call-time
* If jQuery is still unavailable, then throw an error
when the user attempts to affix()

Fixes #27
  • Loading branch information
searls committed Feb 15, 2014
1 parent 4e0f430 commit d29a642
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion app/js/jasmine-fixture.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,13 @@
if $
jasmineFixture = root.jasmineFixture($)
else
throw new Error("jasmine-fixture requires jQuery to be defined at window.jQuery or window.$")
root.affix = ->
nowJQueryExists = window.jQuery || window.$
if nowJQueryExists?
jasmineFixture = root.jasmineFixture(nowJQueryExists)
affix.call(this, arguments...)
else
throw new Error("jasmine-fixture requires jQuery to be defined at window.jQuery or window.$")

)(window.jQuery || window.$)

Expand Down

0 comments on commit d29a642

Please sign in to comment.