Class: TestContacts

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

Instance Method Summary collapse

Instance Method Details

#setupObject



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

def setup
  # do nothing
end

#teardownObject



51
52
53
# File 'lib/v2/test/test_contacts.rb', line 51

def teardown
  # do nothing
end

#test_contactsObject



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

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

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

  # get
  assert_not_nil(Pushbullet::V2::Contacts.get)

  # create
  created = Pushbullet::V2::Contacts.create('test contact', '[email protected]')
  assert_not_nil(created)

  # update
  new_name = 'test contact 2'
  updated = Pushbullet::V2::Contacts.update(created['iden'], new_name)
  assert_not_nil(updated)
  assert_equal(updated['name'], new_name)

  # delete
  assert_not_nil(Pushbullet::V2::Contacts.delete(created['iden']))
end