archseer / ruby-mpd

ruby-mpd is a powerful object-oriented Music Player Daemon library, forked from librmpd.
GNU General Public License v2.0
83 stars 32 forks source link

Specs for ruby-mpd.rb. Just #callback_thread left. 98.58% coverage. #31

Closed whomwah closed 6 years ago

whomwah commented 9 years ago

Testing callback_thread is proving complex. I think the method needs refactoring first to try and move some of the logic elsewhere to try and make it easier to test. I'll create another branch to try this out. I also found the way @socket is set confusing. May try and work on that too in another branch for review.

archseer commented 9 years ago

MPD supports a command called idle, which will stall the connection and report back when there is any change. One option would be opening a second connection to MPD and then waiting for an update on that socket.

I think it would be much more optimal as we get rid of polling every 100ms.

whomwah commented 9 years ago

idle certainly looks interesting and worth exploring. I see that it only lets you know there has been a change in a subsystem and does not let you know what that change is. It's up to you to find that out. All thought I guess a simple mpd.status would be enough.

archseer commented 9 years ago

Yeah, that's the idea. Any time idle returns, just fetch mpd.status.