-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1858 from tk0miya/uri_mailto
stdlib: Add types for URI::MailTo
- Loading branch information
Showing
2 changed files
with
143 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
require_relative "../test_helper" | ||
require "uri" | ||
|
||
class URI::MailToSingletonTest < Test::Unit::TestCase | ||
include TestHelper | ||
|
||
library "uri" | ||
testing "singleton(::URI::MailTo)" | ||
|
||
def test_EMAIL_REGEXP | ||
assert_const_type "::Regexp", "URI::MailTo::EMAIL_REGEXP" | ||
end | ||
|
||
def test_build | ||
assert_send_type "(::Array[ ::String ]) -> ::URI::MailTo", | ||
URI::MailTo, :build, ["example@example.com", "subject=subject"] | ||
assert_send_type "([ ::String, ::Array[ ::Array[ ::String ] ] ]) -> ::URI::MailTo", | ||
URI::MailTo, :build, ["example@example.com", [["subject", "subject"]]] | ||
assert_send_type "(::Hash[ ::Symbol, ::String | ::Array[ ::Array[ ::String ] ] ]) -> ::URI::MailTo", | ||
URI::MailTo, :build, { to: "example@example.com", headers: "subject=subject" } | ||
end | ||
end | ||
|
||
class URI::MailToTest < Test::Unit::TestCase | ||
include TestHelper | ||
|
||
library "uri" | ||
testing "::URI::MailTo" | ||
|
||
def test_headers | ||
assert_send_type "() -> ::Array[[ ::String, ::String ]]", | ||
URI::MailTo.build(["example@example.com", "subject=subject"]), :headers | ||
end | ||
|
||
def test_headers= | ||
assert_send_type "(::String) -> ::String", | ||
URI::MailTo.build(["example@example.com", "subject=subject"]), :headers=, "subject=subject2" | ||
end | ||
|
||
def test_to | ||
assert_send_type "() -> ::String", | ||
URI::MailTo.build(["example@example.com", "subject=subject"]), :to | ||
end | ||
|
||
def test_to= | ||
assert_send_type "(::String) -> ::String", | ||
URI::MailTo.build(["example@example.com", "subject=subject"]), :to=, "example2@example.com" | ||
end | ||
|
||
def test_to_mailtext | ||
assert_send_type "() -> ::String", | ||
URI::MailTo.build(["example@example.com", "subject=subject"]), :to_mailtext | ||
end | ||
|
||
def test_to_rfc822text | ||
assert_send_type "() -> ::String", | ||
URI::MailTo.build(["example@example.com", "subject=subject"]), :to_rfc822text | ||
end | ||
end |