Sha256: cb9e7ff061fa1e6413f58e2a77719f84da6b19304002f04397e76d59c65558db

Contents?: true

Size: 818 Bytes

Versions: 1

Compression:

Stored size: 818 Bytes

Contents

# encoding: UTF-8

require 'spec_helper'

include Rosette::Core

describe Extractor do
  let(:extractor) do
    Rosette::Extractors::Test::TestExtractor.new
  end

  describe '#extract_each_from' do
    it 'extracts each line and line number from the text file and yields the results' do
      extractor.extract_each_from("foo\nbar").tap do |extract_enum|
        expect(extract_enum).to be_a(Enumerator)
        extract_enum.to_a.tap do |phrases|
          expect(phrases.size).to eq(2)
          expect(phrases.all? { |phrase| phrase.first.is_a?(Phrase) }).to be(true)
          expect(phrases.all? { |phrase| phrase.last.is_a?(Fixnum) }).to be(true)  # line numbers
          expect(phrases.first.first.key).to eq('foo')
          expect(phrases.last.first.key).to eq('bar')
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rosette-core-1.0.1 spec/core/extractor/extractor_spec.rb