Created
September 25, 2012 11:38
-
-
Save buger/3781260 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Added new param | |
def make_request(path, data, &blk) | |
opts = {log_stdout: true} | |
p data.to_json | |
with_api(Matching, opts) do |s| | |
Pusher.app_id = '18016' | |
Pusher.key = '2cca73d8fd2cf4273120' | |
Pusher.secret = '99e764cb6f925960c0a5' | |
s.config['mongo'] = EventMachine::Synchrony::ConnectionPool.new(size: 2) do | |
conn = EM::Mongo::Connection.new('localhost', 27017) | |
conn.db('granify_test') | |
end | |
fixed_random = opts.delete('_random') || true | |
Utils.stub(:rand?){ fixed_random } | |
data ||= "{}" | |
post_request({path: path, body: data.to_json, head: {"content-type" => "application/json"} } ) do |resp| | |
resp.response_header.status.should == 200 | |
yield(resp) if blk | |
end | |
end | |
end | |
# Now you can do | |
make_request("/path", { "_random": false }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment