Sha256: 3a77f70fde5eef82830b449d46662afda05055e35230eecb397f502d5f76c747

Contents?: true

Size: 1.73 KB

Versions: 1

Compression:

Stored size: 1.73 KB

Contents

# frozen_string_literal: true

#--
# wwwjdic
# rubocop:disable Style/AsciiComments
# © 2014 Marco Bresciani
# rubocop:enable Style/AsciiComments
#
# 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/>.
#
# SPDX-FileCopyrightText: 2014 Marco Bresciani
#
# SPDX-License-Identifier: GPL-3.0-or-later
#++

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__), '../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

1 entries across 1 versions & 1 rubygems

Version Path
wwwjdic-16.0.0 test/wwwjdic/parsers/test_server.rb