Sha256: 19d8a86ddbb5d2e99e6d4d406e968dd2f21470c06bff23b7ec9ba74975419ec8

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::Key.new }

    describe 'when provided and invalid parameter' do
      [nil, '', 42].each do |param|
        it "shall raise and error for parameter '#{param}'" do
          assert_raises ArgumentError do
            subject.parse param
          end
        end
      end
    end

    describe 'when provided a key' do
      WWWJDic::KEYS.each do |key, value|
        it "shall return #{value} when parameter is #{key}" do
          _(WWWJDic::KEYS[subject.parse(key)]).must_equal value
        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_key.rb