Fix parser swapping mentions and sentences

This commit is contained in:
Paul Friedman 2014-10-19 22:33:17 -07:00
parent 6f27d32bf1
commit 927efe7f07
2 changed files with 29 additions and 2 deletions

View file

@ -1,5 +1,6 @@
require 'spec_helper'
require 'memory_profiler'
require 'tempfile'
def Process.rss; `ps -o rss= -p #{Process.pid}`.chomp.to_i; end
@ -11,4 +12,30 @@ describe Ebooks::Model do
expect(report.total_memsize).to be < 1000000000
end
describe '.consume' do
it 'interprets lines with @ as mentions' do
file = Tempfile.new('mentions')
file.write('@m1spy hello!')
file.close
model = Ebooks::Model.consume(file.path)
expect(model.sentences.count).to eq 0
expect(model.mentions.count).to eq 1
file.unlink
end
it 'interprets lines without @ as statements' do
file = Tempfile.new('statements')
file.write('hello!')
file.close
model = Ebooks::Model.consume(file.path)
expect(model.mentions.count).to eq 0
expect(model.sentences.count).to eq 1
file.unlink
end
end
end