Skip to content
This repository
Fetching contributors…

Cannot retrieve contributors at this time

file 38 lines (30 sloc) 0.976 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
require 'helper'

Parse.init

class TestQuery < Test::Unit::TestCase

  def test_get
    post = Parse::Object.new "Post"
    post["title"] = "foo"
    post.save

    q = Parse.get("Post", post.id)

    assert_equal q.id, post.id
    assert_equal q["title"], post["title"]
  end

  def test_add_contraint
    # I know this method *should* be private.
    # But then it would be a PITA to test.
    # I'd rather test this one method than pointlessly test many others.
    # Thus is life.

    q = Parse::Query.new "TestQuery"
    q.add_constraint("points", 5)
    assert_equal q.where["points"], 5
    q.add_constraint("player", { "$regex" => "regex voodoo"})
    assert_equal q.where["player"], { "$regex" => "regex voodoo"}
  end
  
  def test_eq
    q = Parse::Query.new "TestQuery"
    q.eq("points", 5)
    assert_equal q.where, {"points" => 5}
    q.eq("player", "michael@jordan.com")
    assert_equal q.where, {"points" => 5, "player" => "michael@jordan.com"}
  end
end
Something went wrong with that request. Please try again.