# 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 . # # SPDX-FileCopyrightText: 2013 Marco Bresciani # # SPDX-License-Identifier: GPL-3.0-or-later #++ require_relative '../test_helper' def test_qrcode_sizes Gravaty::ALLOWED_SIZES.each do |size| it "shall provide a '#{size}' pixels URI, when size '#{size}'" do _(subject.qrcode).must_match Gravaty::TEST_QR_REGEXP _(subject.qrcode(pixelsize: size)).must_match(/#{Gravaty::TEST_SIZE_REGEXP}$/) end end end def test_qrcode describe 'when asked for QR code format ' do it 'shall provide an URI in QR code format' do _(subject.qrcode).must_match Gravaty::TEST_QR_REGEXP end test_qrcode_sizes end end def test_json describe 'when asked for JSON format ' do it 'shall provide an URI in JSON format' do _(subject.json).must_match Gravaty::TEST_JSON_REGEXP end it 'shall provide a JSON URI when callback is provided' do _(subject.json).must_match Gravaty::TEST_JSON_REGEXP _(subject.json(callback: Gravaty::TEST_CALLBACK)).must_match(/#{Gravaty::TEST_CALLBACK}$/) end end end describe Gravaty::Gravaty do describe 'when created with a valid email address ' do subject do Gravaty::Gravaty.new(Gravaty::TEST_MY_ADDRESS, Gravaty.parser) end Gravaty::PROFILE_FORMATS.each do |format| describe "when asked for '#{format}' profile" do it "shall provide an URI with required '#{format}' format" do _(subject.profile(format: format)).must_include(".#{format}") end end end describe 'when asked for unknown profile format ' do it 'must raise an ArgumentError' do _(-> { subject.profile format: 'unknown' }).must_raise ArgumentError end end test_json test_qrcode end end