describe("basename", function() local nextfile = require "nextfile" it("should return the basename of an absolute filepath", function() local name = nextfile.basename("/testdir/701.txt") assert.are.equal("701", name) end) it("should return the basename of a relative filepath", function() local name = nextfile.basename("../../foo/testdir/file.mp3") assert.are.equal("file", name) end) end) describe("nextfile", function() local prevfile = require "prevfile" local nextfile = require "nextfile" insulate("prevfile.prevfile returns nil", function() prevfile.prevfile = function() return nil end it("should call prevfile.prevfile", function() spy.on(prevfile, "prevfile") test_directory = "/testdir" nextfile.nextfile(test_directory) assert.spy(prevfile.prevfile).was_called_with(test_directory) end) it("should return nil", function() local file = nextfile.nextfile("/testdir") assert.are.equal(nil, file) end) end) -- insulate("prevfile.prevfile returns a numeric filename", function() -- prevfile.prevfile = function() return "/testdir/701.txt" end -- -- it("should return the result of incrementing the filename", function() -- local file = nextfile.nextfile("/testdir") -- -- assert.are.equal("/testdir/702.txt", file) -- end) -- end) end)