Sha256: 4b9467f415baca8b40552dfcdd513136dc703c4823e183f35342732466b3eb91

Contents?: true

Size: 1.61 KB

Versions: 1

Compression:

Stored size: 1.61 KB

Contents

#--
# wwwjdic
# Copyright © 2014, 2015, 2016, 2017, 2018, 2019, 2020  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::Display.new }

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

    describe 'when an invalid display mode 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-14.0.0 test/wwwjdic/parsers/test_display.rb