Sha256: c5435335cd293c0b86438c805e83c5d7fc955beb9a12da304aa4a1b8beb94254
Contents?: true
Size: 1.87 KB
Versions: 3
Compression:
Stored size: 1.87 KB
Contents
require 'spec_helper' require 'memory_profiler' require 'tempfile' def Process.rss; `ps -o rss= -p #{Process.pid}`.chomp.to_i; end describe Ebooks::Model do describe 'making tweets' do before(:all) { @model = Ebooks::Model.consume(path("data/0xabad1dea.json")) } it "generates a tweet" do s = @model.make_statement expect(s.length).to be <= 140 puts s end it "generates an appropriate response" do s = @model.make_response("hi") expect(s.length).to be <= 140 expect(s.downcase).to include("hi") puts s end end it "consumes, saves and loads models correctly" do model = nil report = MemoryUsage.report do model = Ebooks::Model.consume(path("data/0xabad1dea.json")) end expect(report.total_memsize).to be < 200000000 file = Tempfile.new("0xabad1dea") model.save(file.path) report2 = MemoryUsage.report do model = Ebooks::Model.load(file.path) end expect(report2.total_memsize).to be < 4000000 expect(model.tokens[0]).to be_a String expect(model.sentences[0][0]).to be_a Fixnum expect(model.mentions[0][0]).to be_a Fixnum expect(model.keywords[0]).to be_a String puts "0xabad1dea.model uses #{report2.total_memsize} bytes in memory" 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
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
twitter_ebooks-3.1.5 | spec/model_spec.rb |
twitter_ebooks-3.1.4 | spec/model_spec.rb |
twitter_ebooks-3.1.3 | spec/model_spec.rb |