Sha256: 2a2aeba61d6bd76bdd1b6ac6464795cde7d8d9359bdb40c824a89dad4a640289

Contents?: true

Size: 953 Bytes

Versions: 1

Compression:

Stored size: 953 Bytes

Contents

require 'minitest/spec'
require 'minitest/autorun'
require 'loremarkov'

NUM_PREFIX = 3
LOREM_IPSUM = Loremarkov.sample_text 'lorem_ipsum'
LOREM_LEX = Loremarkov.lex LOREM_IPSUM
LOREM_SENTENCE = LOREM_IPSUM[/[^.]*\./]
LOREM_SENTENCE_WORDS = %w{
  Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
  tempor incididunt ut labore et dolore magna aliqua.
}

describe Loremarkov do
  describe "Lorem ipsum" do
    describe "sample text" do
      it "must match test data" do
        # this works because the first Lorem tokens are all spaces
        LOREM_SENTENCE.must_equal LOREM_SENTENCE_WORDS.join(' ')
      end
    end

    describe "lex" do
      it "must provide expected prefixes" do
        LOREM_LEX.each.with_index { |token, i|
          break if i >= 36
          # this too works because all tokens are spaces
          token.must_equal (i % 2 == 0 ? LOREM_SENTENCE_WORDS[i/2] : ' ')
        }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
loremarkov-0.2.0.1 test/test_loremarkov.rb