File: test_faker_finance.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 (49 lines) | stat: -rw-r--r-- 1,174 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
# frozen_string_literal: true

require_relative '../../test_helper'

class TestFakerFinance < Test::Unit::TestCase
  def setup
    Faker::Config.locale = nil
  end

  def test_vat_number
    assert_match(/\w+/, Faker::Finance.vat_number)
  end

  def test_vat_number_with_invalid_params
    assert_raise ArgumentError do
      Faker::Finance.vat_number(country: Faker::Lorem.word)
    end
  end

  def test_vat_number_with_valid_params
    Faker::Finance.vat_number_keys.each do |country|
      assert_match(/\w+/, Faker::Finance.vat_number(country: country))
    end
  end

  def test_south_african_vat_number
    assert_match(/\AZA\d{10,11}\z/, Faker::Finance.vat_number(country: 'ZA'))
  end

  def test_ticker
    assert_match(/\w+/, Faker::Finance.ticker)
  end

  def test_ticker_with_invalid_params
    assert_raise ArgumentError do
      Faker::Finance.ticker(Faker::Lorem.word)
    end
  end

  def test_ticker_with_valid_params
    ticker_return = Faker::Finance.ticker('nyse')

    assert_includes Faker::Base.fetch_all('finance.ticker.nyse').join(', '), ticker_return
  end

  def test_stock_market
    assert_match(/\w+/, Faker::Finance.stock_market)
  end
end