Skip to content
This repository has been archived by the owner on Dec 1, 2017. It is now read-only.

Commit

Permalink
test the invoke function gets self passed into it
Browse files Browse the repository at this point in the history
  • Loading branch information
jtarchie committed Jun 4, 2013
1 parent 8349d99 commit 43632ee
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions spec/collections_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,19 @@ describe("#invoke", function()
local index = function(array, index) return array[index] end
assert.same(_.invoke(values, index, 3), {3,4})
end)

describe("when passing self into the invoke function", function()
local object = {count=0}
function object:incr()
self.count = self.count + 1
return self.count
end

it("passes the object the method is being invoked on", function()
local array = {object, object, object}
assert.same(_.invoke(array, 'incr'), {1,2,3})
end)
end)
end)

describe("#sortBy", function()
Expand Down

0 comments on commit 43632ee

Please sign in to comment.