Skip to content

Commit 6e887af

Browse files
committed
♻️ Move continuation request parser tests to yaml
1 parent eff3d84 commit 6e887af

File tree

2 files changed

+37
-8
lines changed

2 files changed

+37
-8
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
:tests:
3+
4+
test_continuation_request_rfc3501_6.2.2_example:
5+
:response: "+ YDMGCSqGSIb3EgECAgIBAAD/////6jcyG4GE3KkTzBeBiVHeceP2CWY0SR0fAQAgAAQEBAQ=\r\n"
6+
:expected: !ruby/struct:Net::IMAP::ContinuationRequest
7+
data: !ruby/struct:Net::IMAP::ResponseText
8+
code:
9+
text: "YDMGCSqGSIb3EgECAgIBAAD/////6jcyG4GE3KkTzBeBiVHeceP2CWY0SR0fAQAgAAQEBAQ="
10+
raw_data: "+ YDMGCSqGSIb3EgECAgIBAAD/////6jcyG4GE3KkTzBeBiVHeceP2CWY0SR0fAQAgAAQEBAQ=\r\n"
11+
12+
test_continuation_request_rfc3501_6.3.11_example:
13+
:response: "+ Ready for literal data\r\n"
14+
:expected: !ruby/struct:Net::IMAP::ContinuationRequest
15+
data: !ruby/struct:Net::IMAP::ResponseText
16+
code:
17+
text: "Ready for literal data"
18+
raw_data: "+ Ready for literal data\r\n"
19+
20+
test_continuation_request_rfc3501_7.5_example:
21+
:response: "+ Ready for additional command text\r\n"
22+
:expected: !ruby/struct:Net::IMAP::ContinuationRequest
23+
data: !ruby/struct:Net::IMAP::ResponseText
24+
code:
25+
text: "Ready for additional command text"
26+
raw_data: "+ Ready for additional command text\r\n"
27+
28+
test_continuation_request_without_response_text:
29+
:response: "+\r\n"
30+
:expected: !ruby/struct:Net::IMAP::ContinuationRequest
31+
data: !ruby/struct:Net::IMAP::ResponseText
32+
code:
33+
text: ''
34+
raw_data: "+\r\n"

test/net/imap/test_imap_response_parser.rb

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ def teardown
5151
# §7.5.2: FETCH response, BODYSTRUCTURE msg-att
5252
generate_tests_from fixture_file: "body_structure_responses.yml"
5353

54+
# §7.6: Command Continuation Request
55+
generate_tests_from fixture_file: "continuation_requests.yml"
56+
5457
############################################################################
5558
# IMAP extensions, by RFC:
5659

@@ -79,14 +82,6 @@ def test_enable
7982
assert_equal("SMTPUTF8", response.data.first)
8083
end
8184

82-
def test_continuation_request_without_response_text
83-
parser = Net::IMAP::ResponseParser.new
84-
response = parser.parse("+\r\n")
85-
assert_instance_of(Net::IMAP::ContinuationRequest, response)
86-
assert_equal(nil, response.data.code)
87-
assert_equal("", response.data.text)
88-
end
89-
9085
def test_ignored_response
9186
parser = Net::IMAP::ResponseParser.new
9287
response = nil

0 commit comments

Comments
 (0)