Sha256: 2ad3d050623e4bc34ded53aab4267c6b9ce6f4954a7b1b0a785f45ee749582f9

Contents?: true

Size: 1.28 KB

Versions: 1

Compression:

Stored size: 1.28 KB

Contents

require 'helper'

class TestAvatar < Test::Unit::TestCase
  def setup
    @tester = FFaker::Avatar
  end

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

  def test_avatar_with_param
    assert_equal('http://robohash.org/faker.png?size=300x300',
                 @tester.image('faker'))
  end

  def test_avatar_with_correct_size
    assert_equal('http://robohash.org/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('http://robohash.org/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('http://robohash.org/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

1 entries across 1 versions & 1 rubygems

Version Path
ffaker-2.1.0 test/test_avatar.rb