Sha256: d34a2bfb1f48a1da0a04dd99cf08c0f1f2840da5b518eea555c77c529c393ca7

Contents?: true

Size: 1.6 KB

Versions: 2

Compression:

Stored size: 1.6 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::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

2 entries across 2 versions & 1 rubygems

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