Skip to content

Commit

Permalink
Make sure methods can be used. -ref #3
Browse files Browse the repository at this point in the history
  • Loading branch information
Xiphe committed May 13, 2014
1 parent a72d3f3 commit 875ff64
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/phpdiffmerge.js
Expand Up @@ -495,7 +495,7 @@
var args = Array.prototype.slice.call(arguments, 1);

self.each(function() {
var instance = $.data(self, 'plugin_' + pluginName);
var instance = $.data(this, 'plugin_' + pluginName);
if (!instance) {
logError('cannot call methods on ' + pluginName + ' prior to initialization; ' +
'attempted to call method "' + options + '"');
Expand Down
12 changes: 11 additions & 1 deletion tests/phpdiffmergeSpec.coffee
Expand Up @@ -21,4 +21,14 @@ describe 'phpdiffmerge', ->
it 'should re-init when called with new options', ->
spyOn instance, '_init'
$fixture.phpdiffmerge debug: true
expect(instance._init).toHaveBeenCalled()
expect(instance._init).toHaveBeenCalled()

describe 'methods', ->
beforeEach ->
$fixture.phpdiffmerge

it 'should have callable methods', ->
method = 'useLeft'
spyOn instance, method
$fixture.phpdiffmerge method
expect(instance.useLeft).toHaveBeenCalled()

0 comments on commit 875ff64

Please sign in to comment.