test/unit/garb/data_request_test.rb in garb-0.7.5 vs test/unit/garb/data_request_test.rb in garb-0.7.6
- old
+ new
@@ -1,6 +1,6 @@
-require File.join(File.dirname(__FILE__), '..', '..', '/test_helper')
+require 'test_helper'
module Garb
class DataRequestTest < MiniTest::Unit::TestCase
context "An instance of the DataRequest class" do
@@ -24,18 +24,16 @@
should "return an empty query string if parameters are empty" do
data_request = DataRequest.new(@session, "")
assert_equal "", data_request.query_string
end
-
+
should "be able to build a uri" do
- url = 'http://example.com'
- expected = URI.parse('http://example.com')
-
- assert_equal expected, DataRequest.new(@session, url).uri
+ url = 'http://example.com'
+ assert_equal URI.parse(url), DataRequest.new(@session, url).uri
end
-
+
should "be able to send a request for a single user" do
@session.stubs(:single_user?).returns(true)
response = mock('Net::HTTPOK') do |m|
m.expects(:kind_of?).with(Net::HTTPSuccess).returns(true)
end
@@ -80,20 +78,23 @@
data_request = DataRequest.new(@session, 'https://example.com/data', 'key' => 'value')
assert_equal 'responseobject', data_request.oauth_user_request
assert_received(@session, :access_token)
- assert_received(access_token, :get) {|e| e.with('https://example.com/data?key=value')}
+ assert_received(access_token, :get) {|e| e.with('https://example.com/data?key=value', {'GData-Version' => '2'})}
end
should "be able to request via http with an auth token" do
@session.expects(:auth_token).with().returns('toke')
response = mock
http = mock do |m|
m.expects(:use_ssl=).with(true)
m.expects(:verify_mode=).with(OpenSSL::SSL::VERIFY_NONE)
- m.expects(:get).with('/data?key=value', 'Authorization' => 'GoogleLogin auth=toke').returns(response)
+ m.expects(:get).with('/data?key=value', {
+ 'Authorization' => 'GoogleLogin auth=toke',
+ 'GData-Version' => '2'
+ }).returns(response)
end
Net::HTTP.expects(:new).with('example.com', 443).returns(http)
data_request = DataRequest.new(@session, 'https://example.com/data', 'key' => 'value')