twitter-ebooks/spec/model_spec.rb

42 lines
1,015 B
Ruby
Raw Normal View History

2014-10-14 01:02:08 -07:00
require 'spec_helper'
2014-10-16 03:02:39 -07:00
require 'memory_profiler'
require 'tempfile'
2014-10-14 01:02:08 -07:00
2014-10-18 22:21:50 -07:00
def Process.rss; `ps -o rss= -p #{Process.pid}`.chomp.to_i; end
2014-10-14 01:02:08 -07:00
describe Ebooks::Model do
2014-10-16 03:02:39 -07:00
it "does not use a ridiculous amount of memory" do
2014-10-18 22:21:50 -07:00
report = MemoryUsage.report do
model = Ebooks::Model.consume(path("data/0xabad1dea.json"))
end
2014-10-16 03:02:39 -07:00
2014-10-18 22:21:50 -07:00
expect(report.total_memsize).to be < 1000000000
2014-10-14 01:02:08 -07:00
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
2014-10-14 01:02:08 -07:00
end