File: test_faker_compass.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 (42 lines) | stat: -rw-r--r-- 941 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
# frozen_string_literal: true

require_relative '../../test_helper'

class TestFakerCompass < Test::Unit::TestCase
  def setup
    @tester = Faker::Compass
    @word_pattern = /\w+/
    @multiword_pattern = /^\w+ by \w+$/
    @combined_pattern = /^(?:\w+|\w+ by \w+|[\w-]+)$/
    @number_pattern = /^\d+(?:.\d\d?)?$/
    @letter_pattern = /^[NEWS]?[NEWS](?:b?[NEWS])?$/
  end

  def test_cardinal
    assert_match @word_pattern, @tester.cardinal
  end

  def test_ordinal
    assert_match @word_pattern, @tester.ordinal
  end

  def test_half_wind
    assert_match @word_pattern, @tester.half_wind
  end

  def test_quarter_wind
    assert_match @multiword_pattern, @tester.quarter_wind
  end

  def test_direction
    assert_match @combined_pattern, @tester.direction
  end

  def test_abbreviation
    assert_match @letter_pattern, @tester.abbreviation
  end

  def test_azimuth
    assert_match @number_pattern, @tester.azimuth
  end
end