1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
|
# frozen_string_literal: true
require_relative 'helper'
class TestBook < Test::Unit::TestCase
include DeterministicHelper
assert_methods_are_deterministic(
FFaker::Book,
:title, :genre, :author, :isbn, :description, :cover
)
def setup
@tester = FFaker::Book
end
def test_title
assert_match(/[\sa-z]+/, @tester.title)
end
def test_genre
assert_match(%r{[\w\s'/]+}, @tester.genre)
end
def test_author
assert_match(/[\sa-z]+/, @tester.author)
end
def test_isbn
assert_match(/\d+/, @tester.isbn)
end
def test_description
assert_match(/[\sa-z]+/, @tester.description)
end
def test_cover
assert_match(%r{\Ahttps://robohash\.org/.+\.png\?size=300x300\z},
@tester.cover)
end
def test_cover_with_format
assert_match(%r{\Ahttps://robohash\.org/.+\.jpg\?size=300x300\z},
@tester.cover(format: 'jpg'))
end
def test_cover_output_with_keyword_arguments
output = capture_output do
@tester.cover(format: 'jpg')
end
assert_equal ['', ''], output
end
def test_cover_with_slug_as_positional_argument
assert_match(%r{\Ahttps://robohash\.org/foobar\.png\?size=300x300\z},
@tester.cover('foobar'))
end
def test_cover_output_with_positional_arguments
output = capture_output do
@tester.cover('foobar')
end
assert_equal(
['', "Positional arguments for Book#cover are deprecated. Please use keyword arguments.\n"],
output
)
end
def test_orly_cover
assert_match(%r{\Ahttps://orly-appstore\.herokuapp\.com/generate},
@tester.orly_cover)
end
end
|