cpf_cnpj 0.5.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,134 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "test_helper"
4
-
5
- module CNPJCli
6
- class CheckTest < Minitest::Test
7
- include CaptureSyscall
8
-
9
- %w[-c --check].each do |switch|
10
- test "checks if provided number is valid [using #{switch}]" do
11
- exit_status, stdout = capture_syscall do
12
- system "./bin/cnpj #{switch} 54550752000155"
13
- end
14
-
15
- assert_equal 0, exit_status
16
- assert_equal stdout, ""
17
- end
18
-
19
- test "outputs error message if provided number is invalid [using #{switch}]" do
20
- exit_status, _, stderr = capture_syscall do
21
- system "./bin/cnpj #{switch} invalid"
22
- end
23
-
24
- assert_equal 1, exit_status
25
- assert stderr.include?("Error: Invalid number")
26
- end
27
- end
28
- end
29
-
30
- class HelpTest < Minitest::Test
31
- include CaptureSyscall
32
-
33
- %w[-h --help].each do |switch|
34
- test "outputs help [using #{switch}]" do
35
- exit_status, _, stderr = capture_syscall do
36
- system "./bin/cnpj #{switch}"
37
- end
38
-
39
- assert_equal 1, exit_status
40
- assert stderr.include?("Usage: cnpj")
41
- end
42
- end
43
-
44
- test "outputs help on tail" do
45
- exit_status, _, stderr = capture_syscall do
46
- system "./bin/cnpj"
47
- end
48
-
49
- assert_equal 1, exit_status
50
- assert stderr.include?("Usage: cnpj")
51
- end
52
- end
53
-
54
- class VersionTest < Minitest::Test
55
- include CaptureSyscall
56
-
57
- %w[-v --version].each do |switch|
58
- test "outputs version [using #{switch}]" do
59
- exit_status, stdout = capture_syscall do
60
- system "./bin/cnpj #{switch}"
61
- end
62
-
63
- assert_equal 0, exit_status
64
- assert stdout.include?(CNPJ::VERSION.to_s)
65
- end
66
- end
67
- end
68
-
69
- class GenerateTest < Minitest::Test
70
- include CaptureSyscall
71
-
72
- %w[-g --generate].each do |switch|
73
- test "generates number [using #{switch}]" do
74
- exit_status, stdout = capture_syscall do
75
- system "./bin/cnpj #{switch}"
76
- end
77
-
78
- assert_equal 0, exit_status
79
- assert_match CNPJ::REGEX, stdout
80
- end
81
- end
82
-
83
- test "generates stripped number" do
84
- exit_status, stdout = capture_syscall do
85
- system "./bin/cnpj -gs"
86
- end
87
-
88
- assert_equal 0, exit_status
89
- assert_match(/\A\d{14}\Z/, stdout)
90
- end
91
- end
92
-
93
- class FormatTest < Minitest::Test
94
- include CaptureSyscall
95
-
96
- %w[-f --format].each do |switch|
97
- test "formats argument [using #{switch}]" do
98
- exit_status, stdout = capture_syscall do
99
- system "./bin/cnpj #{switch} 54550752000155"
100
- end
101
-
102
- assert_equal 0, exit_status
103
- assert stdout.include?("54.550.752/0001-55")
104
- end
105
- end
106
-
107
- test "formats argument using stdin" do
108
- exit_status, stdout = capture_syscall do
109
- system "echo 54550752000155 | ./bin/cnpj --format"
110
- end
111
-
112
- assert_equal 0, exit_status
113
- assert stdout.include?("54.550.752/0001-55")
114
- end
115
-
116
- test "fails when providing invalid number" do
117
- exit_status, _, stderr = capture_syscall do
118
- system "./bin/cnpj --format invalid"
119
- end
120
-
121
- assert_equal 1, exit_status
122
- assert stderr.include?("Error: Invalid number")
123
- end
124
-
125
- test "fails when not providing a number" do
126
- exit_status, _, stderr = capture_syscall do
127
- system "./bin/cnpj --format"
128
- end
129
-
130
- assert_equal 1, exit_status
131
- assert stderr.include?("Error: Invalid number")
132
- end
133
- end
134
- end
@@ -1,134 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "test_helper"
4
-
5
- module CPFCli
6
- class CheckTest < Minitest::Test
7
- include CaptureSyscall
8
-
9
- %w[-c --check].each do |switch|
10
- test "checks if provided number is valid [using #{switch}]" do
11
- exit_status, stdout = capture_syscall do
12
- system "./bin/cpf #{switch} 76616598837"
13
- end
14
-
15
- assert_equal 0, exit_status
16
- assert_equal stdout, ""
17
- end
18
-
19
- test "outputs error message if provided number is invalid [using #{switch}]" do
20
- exit_status, _, stderr = capture_syscall do
21
- system "./bin/cpf #{switch} invalid"
22
- end
23
-
24
- assert_equal 1, exit_status
25
- assert stderr.include?("Error: Invalid number")
26
- end
27
- end
28
- end
29
-
30
- class HelpTest < Minitest::Test
31
- include CaptureSyscall
32
-
33
- %w[-h --help].each do |switch|
34
- test "outputs help [using #{switch}]" do
35
- exit_status, _, stderr = capture_syscall do
36
- system "./bin/cpf #{switch}"
37
- end
38
-
39
- assert_equal 1, exit_status
40
- assert stderr.include?("Usage: cpf")
41
- end
42
- end
43
-
44
- test "outputs help on tail" do
45
- exit_status, _, stderr = capture_syscall do
46
- system "./bin/cpf"
47
- end
48
-
49
- assert_equal 1, exit_status
50
- assert stderr.include?("Usage: cpf")
51
- end
52
- end
53
-
54
- class VersionTest < Minitest::Test
55
- include CaptureSyscall
56
-
57
- %w[-v --version].each do |switch|
58
- test "outputs version [using #{switch}]" do
59
- exit_status, stdout, _stderr = capture_syscall do
60
- system "./bin/cpf #{switch}"
61
- end
62
-
63
- assert_equal 0, exit_status
64
- assert stdout.include?(CPF::VERSION.to_s)
65
- end
66
- end
67
- end
68
-
69
- class GenerateTest < Minitest::Test
70
- include CaptureSyscall
71
-
72
- %w[-g --generate].each do |switch|
73
- test "generates number [using #{switch}]" do
74
- exit_status, stdout = capture_syscall do
75
- system "./bin/cpf #{switch}"
76
- end
77
-
78
- assert_equal 0, exit_status
79
- assert_match CPF::REGEX, stdout
80
- end
81
- end
82
-
83
- test "generates stripped number" do
84
- exit_status, stdout = capture_syscall do
85
- system "./bin/cpf -gs"
86
- end
87
-
88
- assert_equal 0, exit_status
89
- assert_match(/\A\d{11}\Z/, stdout)
90
- end
91
- end
92
-
93
- class FormatTest < Minitest::Test
94
- include CaptureSyscall
95
-
96
- %w[-f --format].each do |switch|
97
- test "formats argument [using #{switch}]" do
98
- exit_status, stdout = capture_syscall do
99
- system "./bin/cpf #{switch} 76616598837"
100
- end
101
-
102
- assert_equal 0, exit_status
103
- assert stdout.include?("766.165.988-37")
104
- end
105
- end
106
-
107
- test "formats argument using stdin" do
108
- exit_status, stdout = capture_syscall do
109
- system "echo 76616598837 | ./bin/cpf --format"
110
- end
111
-
112
- assert_equal 0, exit_status
113
- assert stdout.include?("766.165.988-37")
114
- end
115
-
116
- test "fails when providing invalid number" do
117
- exit_status, _, stderr = capture_syscall do
118
- system "./bin/cpf --format invalid"
119
- end
120
-
121
- assert_equal 1, exit_status
122
- assert stderr.include?("Error: Invalid number")
123
- end
124
-
125
- test "fails when not providing a number" do
126
- exit_status, _, stderr = capture_syscall do
127
- system "./bin/cpf --format"
128
- end
129
-
130
- assert_equal 1, exit_status
131
- assert stderr.include?("Error: Invalid number")
132
- end
133
- end
134
- end
File without changes
File without changes