Class: UserTune::HelperTest
- Includes:
- ClientTester
- Defined in:
- lib/gems/xmpp4r-0.4/test/tune/tc_helper_send.rb,
lib/gems/xmpp4r-0.4/test/tune/tc_helper_recv.rb
Overview
Jabber::debug=true
Instance Method Summary collapse
-
#deliver_usertune ⇒ Object
see example 2 from www.xmpp.org/extensions/xep-0118.html#protocol-transport.
-
#psi_usertune ⇒ Object
an example from the Wild.
-
#test_recv_now_playing ⇒ Object
Test receiving ‘now playing’ notifications.
-
#test_send_now_playing ⇒ Object
Test sending ‘now playing’ notifications.
- #test_send_stop_playing ⇒ Object
Instance Method Details
#deliver_usertune ⇒ Object
see example 2 from www.xmpp.org/extensions/xep-0118.html#protocol-transport
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/gems/xmpp4r-0.4/test/tune/tc_helper_recv.rb', line 51 def deliver_usertune "<message from='[email protected]' to='[email protected]'> <event xmlns='http://jabber.org/protocol/pubsub#event'> <items node='http://jabber.org/protocol/tune'> <item id='bffe6584-0f9c-11dc-84ba-001143d5d5db'> <tune xmlns='http://jabber.org/protocol/tune'> <artist>Yes</artist> <length>686</length> <source>Yessongs</source> <title>Heart of the Sunrise</title> <track>3</track> <uri>http://www.yesworld.com/lyrics/Fragile.html#9</uri> </tune> </item> </items> </event> </message>" end |
#psi_usertune ⇒ Object
an example from the Wild
73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/gems/xmpp4r-0.4/test/tune/tc_helper_recv.rb', line 73 def psi_usertune "<message from='[email protected]' to='[email protected]/trackbot' xmlns='jabber:client'><event xmlns='http://jabber.org/protocol/pubsub#event'><items node='http://jabber.org/protocol/tune'><item id='current'> <tune xmlns='http://jabber.org/protocol/tune'> <artist>Wes Montgomery</artist><title>Jingles</title><source>Bags Meets Wes</source><track>8</track><length>410</length></tune></item></items></event></message>" end |
#test_recv_now_playing ⇒ Object
Test receiving ‘now playing’ notifications
See www.xmpp.org/extensions/xep-0118.html#protocol-transport, example 1
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/gems/xmpp4r-0.4/test/tune/tc_helper_recv.rb', line 23 def state { |presence| send(deliver_usertune) } query_waiter = Semaphore.new h = UserTune::Helper.new(@client, '[email protected]') h.add_usertune_callback do |tune| assert_kind_of Jabber::UserTune::Tune, tune assert_equal true, tune. assert_equal 'Yes', tune.artist assert_equal 686, tune.length assert_equal 'Yessongs', tune.source assert_equal 'Heart of the Sunrise', tune.title assert_equal '3', tune.track assert_equal 'http://www.yesworld.com/lyrics/Fragile.html#9',tune.uri end @client. do |m| query_waiter.run end @client.send Jabber::Presence.new wait_state query_waiter.wait end |
#test_send_now_playing ⇒ Object
Test sending ‘now playing’ notifications
See www.xmpp.org/extensions/xep-0118.html#protocol-transport, example 1
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/gems/xmpp4r-0.4/test/tune/tc_helper_send.rb', line 23 def artist = 'Mike Flowers Pops' title = 'Light My Fire' tune_to_send = UserTune::Tune.new(artist, title) h = UserTune::Helper.new(@client, nil) assert_kind_of(UserTune::Helper, h) state { || assert_kind_of(Jabber::Iq, ) assert_equal :set, .type assert_kind_of(Jabber::PubSub::IqPubSub,.first_element('pubsub')) assert_equal(Jabber::UserTune::NS_USERTUNE,.first_element('pubsub').first_element('publish').node) tune=.first_element('pubsub').first_element('publish').first_element('item').first_element('tune') assert_kind_of Jabber::UserTune::Tune,tune assert_equal true, tune. assert_equal artist,tune.artist assert_equal title,tune.title assert_equal nil,tune.length assert_equal nil,tune.track assert_equal nil,tune.source assert_equal nil,tune.uri send("<iq type='result' id='#{.id}'/>") } h.(tune_to_send) wait_state end |
#test_send_stop_playing ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/gems/xmpp4r-0.4/test/tune/tc_helper_send.rb', line 54 def h = UserTune::Helper.new(@client, nil) state { || tune = .first_element('pubsub').first_element('publish').first_element('item').first_element('tune') assert_kind_of Jabber::UserTune::Tune, tune assert_equal false, tune. assert_equal nil, tune.artist assert_equal nil, tune.title assert_equal nil,tune.length assert_equal nil,tune.track assert_equal nil,tune.source assert_equal nil,tune.uri send("<iq type='result' id='#{.id}'/>") } h. wait_state end |