require 'rspec' require './lib/lingo24' # Replace this with your Application's +user_key+ from the Lingo24 Developer Portal (https://developer.lingo24.com) USER_KEY = '' # Specification file for the +Lingo24::PremiumMTAPI+ class describe Lingo24::PremiumMTAPI do it 'should translate a string with source and target supplied' do translator = Lingo24::PremiumMTAPI.new(USER_KEY) r = translator.translate('Love your language', 'en', 'es') expect(r.size).to be > 0 end it 'should translate a string with a specifc engine' do translator = Lingo24::PremiumMTAPI.new(USER_KEY) r = translator.translate_specific('Love your language', 'ugc-ro-en') expect(r.size).to be > 0 end it 'if you translate using a specific engine but supply the wrong id, it should raise an Lingo24::Exception' do begin translator = Lingo24::PremiumMTAPI.new(USER_KEY) r = translator.translate_specific('Love your language', 'ugc-roen') fail('No Lingo24::Exception raised') rescue Lingo24::Exception => detail expect(detail.code).to eql('500') end end it 'should provide a list of available source languages' do translator = Lingo24::PremiumMTAPI.new(USER_KEY) r = translator.get_source_langs() expect(r.size).to be > 0 end it 'should provide a list of available source languages, filtered by the target language' do translator = Lingo24::PremiumMTAPI.new(USER_KEY) a = translator.get_source_langs('de') b = translator.get_source_langs() expect(b.size).to be > a.size end it 'should provide a list of available target languages' do translator = Lingo24::PremiumMTAPI.new(USER_KEY) r = translator.get_target_langs() expect(r.size).to be > 0 end it 'should provide a list of available target languages, filtered by the source language' do translator = Lingo24::PremiumMTAPI.new(USER_KEY) a = translator.get_target_langs('de') b = translator.get_target_langs() expect(b.size).to be > a.size end it 'should translate a string using Lingo24::Language objects for source and target' do translator = Lingo24::PremiumMTAPI.new(USER_KEY) r = translator.translate_language('Love your language', Lingo24::Language.new('en', 'English'), Lingo24::Language.new('es', 'Spanish')) expect(r.size).to be > 0 end end