🧪 Add experimental new FakeServer for tests#157
Conversation
This was written for several reasons: * To improve `yields_in_test_server_thread` and clean up tests using it * To support new tests for the new cached capabilities methods * Because I kept messing up `OpenSSL::SSL::SSLSocket#accept`, even though I copied and pasted from `imaps_test` and `starttls_test`. 😳 * To support testing of other libraries and applications that use Net::IMAP. I will (probably) eventually update most of the tests in `test_imap.rb` to use FakeServer. The version here is able to support the capabilities tests and several more existing tests. See the rdoc on FakeServer for more info.
* test_clear_responses * test_close * test_enable * test_responses * test_uid_expunge * test_uidplus_responses * test_unselect All of the tests that used `yields_in_test_server_thread` were updated, so that method was deleted too.
|
@hsbt, @shugo I wanted to check in and make sure you're okay with this. Although I tried to keep it simple, readable, and relatively easy for someone new to use, it's significantly more complex than the simple This PR added over 500 lines of code in order to save only ~50 lines of test code. I could've saved a few more lines of code, but I did add new assertions and split some test methods into multiple tests. Nevertheless, it's still an order of magnitude difference! As I continue to convert most of the existing tests and add new ones, that savings should grow. I'm not fully satisfied with the internal structure or the API... but since I'm already using for a couple of future PRs, I wanted to add it in its current form, rather than delay until I was satisified with it... that day may never come! My hope is that this allows the tests to focus on what matters, and thus be more approachable for us and for newcomers to read, debug, and write. But I can only answer that question for myself. After I've used it in more places and the API stabilizes I would like to either move it into |
This was written for several reasons:
yields_in_test_server_threadand clean up tests using it#capable?(name)#156OpenSSL::SSL::SSLSocket#accept, eventhough I copied and pasted from
imaps_testandstarttls_test. 😳I will (probably) eventually update most of the tests in
test_imap.rbto useFakeServer. The version here is able to support the capabilities tests and several more existing tests. To quote the rdoc:The following tests in
test_imap.rbhave been updated to useFakeServer:test_clear_responsestest_closetest_enabletest_responsestest_uid_expungetest_uidplus_responsestest_unselectAll of the tests that used
yields_in_test_server_threadwere updated, so that method was deleted too. It has effectively been replaced bywith_fake_server.