Class: TestSubscriptions

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
lib/v2/test/test_subscriptions.rb

Instance Method Summary collapse

Instance Method Details

#setupObject



21
22
23
# File 'lib/v2/test/test_subscriptions.rb', line 21

def setup
  # do nothing
end

#teardownObject



52
53
54
# File 'lib/v2/test/test_subscriptions.rb', line 52

def teardown
  # do nothing
end

#test_subscriptionsObject



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
# File 'lib/v2/test/test_subscriptions.rb', line 25

def test_subscriptions
  print '> input your Pushbullet access token: '
  input = STDIN.noecho(&:gets)

  assert_not_nil(input)
  access_token = input.chomp
  
  Pushbullet.set_access_token(access_token)

  # subscribe
  channel_tag = 'pushbullet'
  subscribed = Pushbullet::V2::Subscriptions.subscribe(channel_tag)
  assert_not_nil(subscribed)  # XXX - should check its result (it can be 'Already subscribed to this channel.' error)

  # get
  subscriptions = Pushbullet::V2::Subscriptions.get
  assert_not_nil(subscriptions)

  subscribed = subscriptions['subscriptions'].first

  # channel info
  assert_not_nil(Pushbullet::V2::Subscriptions.channel_info(subscribed['channel']['tag']))

  # unsubscribe
  assert_not_nil(Pushbullet::V2::Subscriptions.unsubscribe(subscribed['iden']))
end