Sha256: 6c329b0dcb44bed72f2f4cc59cb41f2edf18f42ffd5773ea7226e88341100706

Contents?: true

Size: 1.71 KB

Versions: 2

Compression:

Stored size: 1.71 KB

Contents

#--
# gravaty
# Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019  Marco Bresciani
#
# 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/>.
#++

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

    it 'shall return nothing when parameter is nil' do
      subject.parse(nil).must_be_empty
    end

    Gravaty::ALLOWED_SIZES.each do |value|
      it "shall return s='#{value.to_s}' when parameter is '#{value}'" do
        subject.parse(value).must_equal "s=#{value.to_s}"
      end
    end

    it 'shall raise an exception when provided with invalid rating' do
      begin
        subject.parse(0).must_raise ArgumentError
      rescue ArgumentError => aErr
        aErr.wont_be_nil
        aErr.message.wont_be_nil
        aErr.message.wont_be_empty
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gravaty-9.0.1 test/gravaty/parsers/test_pixelsize.rb
gravaty-9.0.0 test/gravaty/parsers/test_pixelsize.rb