Method: UserTune::HelperTest#test_send_now_playing

Defined in:
lib/vendor/xmpp4r/test/tune/tc_helper_send.rb

#test_send_now_playingObject

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/vendor/xmpp4r/test/tune/tc_helper_send.rb', line 23

def test_send_now_playing
  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 { |now_playing|
    assert_kind_of(Jabber::Iq, now_playing)
    assert_equal :set, now_playing.type

    assert_kind_of(Jabber::PubSub::IqPubSub,now_playing.first_element('pubsub'))
    assert_equal(Jabber::UserTune::NS_USERTUNE,now_playing.first_element('pubsub').first_element('publish').node)

    tune=now_playing.first_element('pubsub').first_element('publish').first_element('item').first_element('tune')
    assert_kind_of Jabber::UserTune::Tune,tune
    assert_equal true, tune.playing?
    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='#{now_playing.id}'/>")
  }
  h.now_playing(tune_to_send)
  wait_state
end