@@ -47,4 +47,32 @@ def test_foreach
4747 assert_send_type "(String path, headers: bool, **untyped) -> Enumerator[CSV::Row, void]" ,
4848 CSV , :foreach , path , headers : true , encoding : 'UTF-8'
4949 end
50+
51+ def test_read
52+ tmpdir = Dir . mktmpdir
53+ path = File . join ( tmpdir , "example.csv" )
54+ File . write ( path , "a,b,c\n 1,2,3\n " )
55+
56+ assert_send_type "(String path, headers: true) -> CSV::Table[CSV::Row]" ,
57+ CSV , :read , path , headers : true
58+ assert_send_type "(IO path, headers: true) -> CSV::Table[CSV::Row]" ,
59+ CSV , :read , File . open ( path ) , headers : true
60+ assert_send_type "(String path, headers: :first_row) -> CSV::Table[CSV::Row]" ,
61+ CSV , :read , path , headers : :first_row
62+ assert_send_type "(IO path, headers: :first_row) -> CSV::Table[CSV::Row]" ,
63+ CSV , :read , File . open ( path ) , headers : :first_row
64+ assert_send_type "(String path, headers: Array[String]) -> CSV::Table[CSV::Row]" ,
65+ CSV , :read , path , headers : %w[ foo bar baz ]
66+ assert_send_type "(IO path, headers: Array[String]) -> CSV::Table[CSV::Row]" ,
67+ CSV , :read , File . open ( path ) , headers : %w[ foo bar baz ]
68+ assert_send_type "(String path, headers: String) -> CSV::Table[CSV::Row]" ,
69+ CSV , :read , path , headers : "foo,bar,baz"
70+ assert_send_type "(IO path, headers: String) -> CSV::Table[CSV::Row]" ,
71+ CSV , :read , File . open ( path ) , headers : "foo,bar,baz"
72+
73+ assert_send_type "(String path) -> Array[Array[String?]]" ,
74+ CSV , :read , path
75+ assert_send_type "(IO path) -> Array[Array[String?]]" ,
76+ CSV , :read , File . open ( path )
77+ end
5078end
0 commit comments