File: test_faker_app.rb

package info (click to toggle)
ruby-faker 3.6.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,596 kB
  • sloc: ruby: 20,656; sh: 6; makefile: 6
file content (57 lines) | stat: -rw-r--r-- 1,907 bytes parent folder | download
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
# frozen_string_literal: true

require_relative '../../test_helper'

class TestFakerApp < Test::Unit::TestCase
  def setup
    @tester = Faker::App
  end

  def test_name
    assert_match(/(\w+\.? ?){2,3}/, @tester.author)
  end

  def test_basic_semantic_version
    deterministically_verify -> { @tester.semantic_version.split('.') } do |test_sem_vers|
      assert_match(/[0-9]{1}/, test_sem_vers[0])
      assert_match(/[0-9]{1}/, test_sem_vers[1])
      assert_match(/[1-9]{1}/, test_sem_vers[2])
    end
  end

  def test_major_semantic_version
    deterministically_verify -> { @tester.semantic_version(major: (1000..9999)).split('.') } do |test_sem_vers|
      assert_match(/[0-9]{4}/, test_sem_vers[0])
      assert_match(/[0-9]{1}/, test_sem_vers[1])
      assert_match(/[1-9]{1}/, test_sem_vers[2])
    end
  end

  def test_minor_semantic_version
    deterministically_verify -> { @tester.semantic_version(minor: (1000..9999)).split('.') } do |test_sem_vers|
      assert_match(/[0-9]{1}/, test_sem_vers[0])
      assert_match(/[0-9]{4}/, test_sem_vers[1])
      assert_match(/[1-9]{1}/, test_sem_vers[2])
    end
  end

  def test_patch_semantic_version
    deterministically_verify -> { @tester.semantic_version(patch: (1000..9999)).split('.') } do |test_sem_vers|
      assert_match(/[0-9]{1}/, test_sem_vers[0])
      assert_match(/[0-9]{1}/, test_sem_vers[1])
      assert_match(/[0-9]{4}/, test_sem_vers[2])
    end
  end

  def test_all_semantic_version
    deterministically_verify -> { @tester.semantic_version(major: (1000..9999), minor: (1000..9999), patch: (1000..9999)).split('.') } do |test_sem_vers|
      assert_match(/[0-9]{4}/, test_sem_vers[0])
      assert_match(/[0-9]{4}/, test_sem_vers[1])
      assert_match(/[0-9]{4}/, test_sem_vers[2])
    end
  end

  def test_specific_major_version
    assert_match(/42\.[0-9]\.[0-9]/, @tester.semantic_version(major: 42))
  end
end