Sha256: 910a12bfc359e0d4506c18513c459e94e22660406177aeab3c1bab4d2a6852ba

Contents?: true

Size: 1.4 KB

Versions: 9

Compression:

Stored size: 1.4 KB

Contents

# frozen_string_literal: true

require_relative 'helper'

class TestAvatar < Test::Unit::TestCase
  include DeterministicHelper

  ROBOHASH = 'https://robohash.org'

  assert_methods_are_deterministic(FFakerTW::Avatar, :image)

  def setup
    @tester = FFakerTW::Avatar
  end

  def test_avatar
    assert_match(%r{\Ahttps://robohash\.org/.+\.png\?size=300x300\z},
                 @tester.image)
  end

  def test_avatar_with_param
    assert_equal("#{ROBOHASH}/faker.png?size=300x300", @tester.image('faker'))
  end

  def test_avatar_with_correct_size
    assert_equal("#{ROBOHASH}/faker.png?size=150x320",
                 @tester.image('faker', '150x320'))
  end

  def test_avatar_with_incorrect_size
    assert_raise ArgumentError do
      @tester.image(nil, '150x320z')
    end
  end

  def test_avatar_with_supported_format
    assert_equal("#{ROBOHASH}/faker.jpg?size=300x300",
                 @tester.image('faker', '300x300', 'jpg'))
  end

  def test_avatar_with_incorrect_format
    assert_raise ArgumentError do
      @tester.image(nil, '300x300', 'wrong_format')
    end
  end

  def test_avatar_with_correct_background
    assert_equal("#{ROBOHASH}/faker.png?size=300x300&bgset=bg1",
                 @tester.image('faker', '300x300', 'png', '1'))
  end

  def test_avatar_with_incorrect_background
    assert_raise ArgumentError do
      @tester.image('faker', '300x300', 'png', 'not_a_number')
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ffakerTW-1.8.0 test/test_avatar.rb
ffakerTW-1.7.0 test/test_avatar.rb
ffakerTW-1.6.0 test/test_avatar.rb
ffakerTW-1.5.0 test/test_avatar.rb
ffakerTW-1.4.0 test/test_avatar.rb
ffakerTW-1.3.0 test/test_avatar.rb
ffakerTW-1.2.0 test/test_avatar.rb
ffakerTW-1.1.0 test/test_avatar.rb
ffakerTW-0.1.0 test/test_avatar.rb