Sha256: 9cd6030c56c2d884691b74e8ddc2aaf602cc2ad3c982a8a6f1e4f1415de7bcc1

Contents?: true

Size: 1.58 KB

Versions: 2

Compression:

Stored size: 1.58 KB

Contents

#--
# wwwjdic
# Copyright © 2014, 2015, 2016, 2017, 2018, 2019  Marco Bresciani
#
# This file is part of wwwjdic.
#
# wwwjdic is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# wwwjdic is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with wwwjdic. If not, see <http://www.gnu.org/licenses/>.
#++

require_relative '../../test_helper'

describe WWWJDic::WWWJDic do
  describe 'when using a parser' do
    include WWWJDic::ParsableDuckType

    before do
      @parser = subject
      I18n.load_path = Dir[File.join(File.dirname(__FILE__), '/../../../lib/wwwjdic/locales/', '*.yml')]
    end

    subject {WWWJDic::Parsers::Server.new}

    describe 'when a valid server is selected' do
      WWWJDic::URIS.each do |key, value|
        it "shall return '#{value}' when parameter is '#{key}'" do
          subject.parse(key).must_equal key
          WWWJDic::URIS[subject.parse(key)].must_equal value
        end
      end
    end

    describe 'when an invalid server is selected' do
      it 'shall raise an error' do
        assert_raises ArgumentError do
          subject.parse :xx
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
wwwjdic-13.0.1 test/wwwjdic/parsers/test_server.rb
wwwjdic-13.0.0 test/wwwjdic/parsers/test_server.rb