Sha256: 5eaf54b12385f109ae5e2aa01a7e6a0ab9e6fcef4f8338e42d5da9ae217d3325

Contents?: true

Size: 1.81 KB

Versions: 1

Compression:

Stored size: 1.81 KB

Contents

# frozen_string_literal: true

#--
# gravaty
# rubocop:disable Style/AsciiComments
# © 2013 Marco Bresciani
# rubocop:enable Style/AsciiComments
#
# This file is part of gravaty.
#
# gravaty 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.
#
# gravaty 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 gravaty. If not, see <http://www.gnu.org/licenses/>.
#
# SPDX-FileCopyrightText: 2013 Marco Bresciani
#
# SPDX-License-Identifier: GPL-3.0-or-later
#++

require_relative '../../test_helper'

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

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

    subject { Gravaty::Parsers::Format.new }

    Gravaty::PROFILE_FORMATS.each do |value|
      [[nil, ''], %W[#{value} .#{value.downcase}]].each do |pair|
        it "shall return '#{pair[1]}' when parameter is '#{pair[0]}'" do
          _(subject.parse(pair[0])).must_equal pair[1]
        end
      end
    end

    it 'shall raise exception with invalid default image extension' do
      subject.parse('svg').must_raise ArgumentError
    rescue ArgumentError => e
      _(e).wont_be_nil
      _(e.message).wont_be_nil
      _(e.message).wont_be_empty
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gravaty-11.0.1 test/gravaty/parsers/test_format.rb