Sha256: f899faddc5edb786223843078e2d9e8fa6036baa5417d3e9f4c5f179a6f19a27

Contents?: true

Size: 1.17 KB

Versions: 3

Compression:

Stored size: 1.17 KB

Contents

require 'tempfile'
require 'securerandom'
require 'pathname'

require 'spec_helper'

describe Analects::Library do
  subject(:library) {
    described_class.new(options)
  }
  let(:data_dir) { Pathname(Dir.tmpdir).join('analects-' + SecureRandom.hex(16)) }
  let(:options) {
    { data_dir: data_dir }
  }

  context 'with a data_dir specified' do
    it 'should set that data dir on the sources' do
      subject.cedict.data_dir.should == data_dir
    end
  end

  describe "#cedict" do
    subject(:cedict) { library.cedict }

    its(:name)     { should == :cedict }

    it "should download and unpack the CEDICT archive" do
      cedict.should_receive(:retrieve_http).once.with(Analects::CEDICT_URL).and_return(:a_stream)
      cedict.should_receive(:retrieve_gunzip).once.with(:a_stream).and_return(:an_unzipped_stream)

      cedict.retrieve!
    end
  end

  it "should have a CHISE IDS source" do
    library.chise_ids.name.should == :chise_ids
  end

  describe "#chise_ids" do
    subject (:chise_ids) { library.chise_ids }

    its( :name )      { should == :chise_ids }
    its( :retrieval ) { should == [ :git ] }
    its( :url       ) { should == Analects::CHISE_IDS_URL}
  end


end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
analects-0.4.2 spec/analects/library_spec.rb
analects-0.4.1 spec/analects/library_spec.rb
analects-0.4.0 spec/analects/library_spec.rb