Sha256: a6686c7d7bba9822ceb4527182e20187618156413e7be4482671b4bbe279521f

Contents?: true

Size: 1.63 KB

Versions: 1

Compression:

Stored size: 1.63 KB

Contents

# -*- coding: utf-8 -*-

require 'dict/dict'

describe Dict do

  it "should return array of available services which is not empty" do
    arr = Dict.available_dictionaries
    arr.should be_a(Array)
    arr.size.should_not == 0
  end

  it "should return array of available services, which contains wiktionary and glosbe" do
    Dict.available_dictionaries.should == ['wiktionary', 'glosbe']
  end

  it "should return hash with translations from all dictionaries" do
    wiktionary = stub(:translate => stub(:translations => {'WORD' => 'WIKTIONARY_RESULTS'}))
    Dict::Wiktionary.should_receive(:new).with('WORD').and_return(wiktionary)

    glosbe = stub(:translate => stub(:translations => {'WORD' => 'GLOSBE_RESULTS'}))
    Dict::Glosbe.should_receive(:new).with('WORD').and_return(glosbe)

    results = Dict::get_all_dictionaries_translations('WORD')
    results.should == {'wiktionary' => {'WORD' => 'WIKTIONARY_RESULTS'}, 'glosbe' => {'WORD' => 'GLOSBE_RESULTS'}}
  end

  it "should return whatever Wiktionary returns embedded in a hash" do
    wiktionary = stub(:translate => stub( :translations => 'WIKTIONARY_RESULTS'))
    Dict::Wiktionary.should_receive(:new).with('WORD').and_return(wiktionary)
    Dict.get_single_dictionary_translations('WORD', 'wiktionary').should == 'WIKTIONARY_RESULTS'
  end
  
  it "should return whatever Glosbe returns embedded in a hash" do
    glosbe = stub(:translate => stub( :translations => 'GLOSBE_RESULTS'))
    Dict::Glosbe.should_receive(:new).with('WORD').and_return(glosbe)
    Dict.get_single_dictionary_translations('WORD', 'glosbe').should == 'GLOSBE_RESULTS'
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dict-0.3.4 spec/dict/lib_dict_spec.rb