Sha256: 9479fc3ad1b7638abdb9e1a54de623f2acd33e1ceaf1e5b9eb56245bcbddea9a
Contents?: true
Size: 1.44 KB
Versions: 1
Compression:
Stored size: 1.44 KB
Contents
require 'spec_helper' require 'wukong' describe_example_script(:telegram, 'dataflow/telegram.rb') do it 'runs' do Wukong::LocalRunner.run(subject, :default) end context 'Recompose processor' do subject{ Wukong::Widget::Recompose } its(:field_names){ should include(:break_length) } let(:words ){ # 0 5 1 5 2 5 3 5 4 5 5 5 6 5 7 5 8 %w[ If names be not correct, language is not in accordance with the truth of things. If language be not in accordance with the truth of things, affairs cannot be carried on to success. ] } context '#process' do it 'breaks lines correctly' do (2..80).each do |len| # run the data flow into an array sink test_sink = Wukong::Sink::ArraySink.new rc = subject.new(:break_length => len, :output => test_sink ) words.each{|word| rc.process(word) } rc.stop # start and end are correct test_sink.records.first.should =~ /^If/ test_sink.records.last.should =~ /success\.$/ # lines should be as long as possible, but not longer test_sink.records[0..-2].zip(test_sink.records[1..-1]) do |line, nextl| nextw = nextl.split[0] ((line.length <= len) || line !~ /\s/).should be_true (line.length + nextw.length + 1 > len).should be_true end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
wukong-3.0.0.pre | spec/examples/dataflow/telegram_spec.rb |