Skip to content

Commit

Permalink
test push
Browse files Browse the repository at this point in the history
  • Loading branch information
ericcj authored and tikhon committed Oct 8, 2012
1 parent a4c457b commit 986590b
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions test/test_push.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,32 @@
require 'helper'

class TestPush < Test::Unit::TestCase

def setup
Parse.init
end

def test_send
# gotta mock
def test_save
data = {:foo => 'bar',
:alert => 'message'}
pf_push = Parse::Push.new(data, "some_chan")
pf_push.type = 'ios'

query = Parse::Query.new('_Installation').eq('deviceToken', 'baz')
pf_push.where = query.where

Parse::Client.any_instance.expects(:request).with do |uri, method, body, query|
hash = JSON.parse(body)
assert_equal :post, method
assert has_entries('type' => 'ios', 'channel' => "some_chan").matches?([hash])
assert has_entries('foo' => 'bar', 'alert' => 'message').matches?([hash['data']])
assert has_entries('deviceToken' => 'baz').matches?([hash['where']])
assert_nil query
true
end.returns({}.to_json)

pf_push.save
end


end

0 comments on commit 986590b

Please sign in to comment.