Skip to content
This repository
Fetching contributors…

Cannot retrieve contributors at this time

file 41 lines (31 sloc) 0.88 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
require 'helper'

class TestUser < Test::Unit::TestCase
  
  def setup
    Parse.init
  end

  def test_save
    username = rand.to_s
    data = {
      :username => username,
      :password => "topsecret"
    }
    user = Parse::User.new data
    user.save
    assert_equal user[Parse::Protocol::KEY_OBJECT_ID].class, String
    assert_equal user[Parse::Protocol::KEY_CREATED_AT].class, String
  end
  
  def test_login
    u = "alan" + rand(10000000000000).to_s
    data = {
      :username => u,
      :password => "secret"
    }

    user = Parse::User.new(data)

    user.save
    
    assert_equal user["username"], u
    assert_equal user[Parse::Protocol::KEY_USER_SESSION_TOKEN].class, String
    
    login = Parse::User.authenticate(u, "secret")
    
    assert_equal login["username"], user["username"]
    assert_equal login["sessionToken"].class, String
  end

end
Something went wrong with that request. Please try again.