Skip to content

Commit

Permalink
Improve Observable.fromFileByLine test coverage;
Browse files Browse the repository at this point in the history
  • Loading branch information
bjornbytes committed Sep 12, 2018
1 parent 457fe4c commit 6110f95
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions tests/observable.lua
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,17 @@ describe('Observable', function()
local oldIO = _G['io']
_G['io'] = {}

local filename = 'file.txt'

it('returns an observable', function()
expect(Rx.Observable.fromFileByLine('file.txt')).to.be.an(Rx.Observable)
expect(Rx.Observable.fromFileByLine(filename)).to.be.an(Rx.Observable)
end)

it('errors if the file does not exist', function()
io.open = function() return nil end
expect(Rx.Observable.fromFileByLine('file.txt').subscribe).to.fail()
local onError = spy()
Rx.Observable.fromFileByLine(filename):subscribe(nil, onError, nil)
expect(onError).to.equal({{ filename }})
end)

it('returns an Observable that produces the lines of the file', function()
Expand All @@ -237,7 +241,7 @@ describe('Observable', function()
end
end

expect(Rx.Observable.fromFileByLine('file.txt')).to.produce('line1', 'line2', 'line3')
expect(Rx.Observable.fromFileByLine(filename)).to.produce('line1', 'line2', 'line3')
end)

io = oldIO
Expand Down

0 comments on commit 6110f95

Please sign in to comment.