spec/twitter/client/user_spec.rb in twitter4r-0.3.2 vs spec/twitter/client/user_spec.rb in twitter4r-0.5.0
- old
+ new
@@ -9,26 +9,24 @@
:id => @id,
:screen_name => @screen_name,
:location => 'London'
)
@json = JSON.unparse(@user.to_hash)
- @request = mas_net_http_get(:basic_auth => nil)
@response = mas_net_http_response(:success, @json)
@connection = mas_net_http(@response)
@uris = Twitter::Client.class_eval("@@USER_URIS")
- @twitter.stub!(:create_http_get_request).and_return(@request)
Twitter::User.stub!(:unmarshal).and_return(@user)
Net::HTTP.stub!(:new).and_return(@connection)
end
it "should create expected HTTP GET request when giving numeric user id" do
- @twitter.should_receive(:create_http_get_request).with(@uris[:info], {:user_id => @id}).and_return(@request)
+ @twitter.should_receive(:rest_oauth_connect).with(:get, "#{@uris[:info]}?#{{:user_id => @id}.to_http_str}").and_return(@response)
@twitter.user(@id)
end
it "should create expected HTTP GET request when giving screen name" do
- @twitter.should_receive(:create_http_get_request).with(@uris[:info], {:screen_name => @screen_name}).and_return(@request)
+ @twitter.should_receive(:rest_oauth_connect).with(:get, "#{@uris[:info]}?#{{:screen_name => @screen_name}.to_http_str}").and_return(@response)
@twitter.user(@screen_name)
end
it "should bless model returned when giving numeric user id" do
@twitter.should_receive(:bless_model).with(@user).and_return(@user)
@@ -39,11 +37,11 @@
@twitter.should_receive(:bless_model).with(@user).and_return(@user)
@twitter.user(@screen_name)
end
after(:each) do
- nilize(@request, @response, @connection, @twitter, @id, @screen_name, @user)
+ nilize(@response, @connection, @twitter, @id, @screen_name, @user)
end
end
# TODO: Add specs for new Twitter::Client#user(id, :friends) and
# Twitter::Client#user(id, :followers) use cases.
@@ -56,36 +54,34 @@
:id => @id,
:screen_name => @screen_name,
:location => 'Urbana, IL'
)
@json = JSON.unparse(@user.to_hash)
- @request = mas_net_http_get(:basic_auth => nil)
@response = mas_net_http_response(:success, @json)
@connection = mas_net_http(@response)
@uris = Twitter::Client.class_eval("@@USER_URIS")
- @twitter.stub!(:create_http_get_request).and_return(@request)
Twitter::User.stub!(:unmarshal).and_return(@user)
Net::HTTP.stub!(:new).and_return(@connection)
end
it "should create expected HTTP GET request when giving numeric user id" do
- @twitter.should_receive(:create_http_get_request).with(@uris[:friends], {:user_id => @id}).and_return(@request)
+ @twitter.should_receive(:rest_oauth_connect).with(:get, "#{@uris[:friends]}?#{{:user_id => @id}.to_http_str}").and_return(@response)
@twitter.user(@id, :friends)
end
it "should invoke #to_i on Twitter::User objecct given" do
@user.should_receive(:to_i).and_return(@id)
@twitter.user(@user, :friends)
end
it "should create expected HTTP GET request when giving Twitter::User object" do
- @twitter.should_receive(:create_http_get_request).with(@uris[:friends], {:user_id => @user.to_i}).and_return(@request)
+ @twitter.should_receive(:rest_oauth_connect).with(:get, "#{@uris[:friends]}?#{{:user_id => @user.to_i}.to_http_str}").and_return(@response)
@twitter.user(@user, :friends)
end
it "should create expected HTTP GET request when giving screen name" do
- @twitter.should_receive(:create_http_get_request).with(@uris[:friends], {:screen_name => @screen_name}).and_return(@request)
+ @twitter.should_receive(:rest_oauth_connect).with(:get, "#{@uris[:friends]}?#{{:screen_name => @screen_name}.to_http_str}").and_return(@response)
@twitter.user(@screen_name, :friends)
end
it "should bless model returned when giving numeric id" do
@twitter.should_receive(:bless_model).with(@user).and_return(@user)
@@ -101,11 +97,11 @@
@twitter.should_receive(:bless_model).with(@user).and_return(@user)
@twitter.user(@screen_name, :friends)
end
after(:each) do
- nilize(@request, @response, @connection, @twitter, @id, @screen_name, @user)
+ nilize(@response, @connection, @twitter, @id, @screen_name, @user)
end
end
describe Twitter::Client, "#my(:info)" do
before(:each) do
@@ -115,21 +111,20 @@
:id => 2394393,
:screen_name => @screen_name,
:location => 'Glamorous Urbana'
)
@json = JSON.unparse(@user.to_hash)
- @request = mas_net_http_get(:basic_auth => nil)
@response = mas_net_http_response(:success, @json)
@connection = mas_net_http(@response)
@uris = Twitter::Client.class_eval("@@USER_URIS")
- @twitter.stub!(:create_http_get_request).and_return(@request)
+ @twitter.stub!(:rest_oauth_connect).and_return(@response)
Net::HTTP.stub!(:new).and_return(@connection)
Twitter::User.stub!(:unmarshal).and_return(@user)
end
it "should create expected HTTP GET request" do
- @twitter.should_receive(:create_http_get_request).with(@uris[:info], :id => @screen_name).and_return(@request)
+ @twitter.should_receive(:rest_oauth_connect).with(:get, "#{@uris[:info]}?#{{:id => @screen_name}.to_http_str}").and_return(@response)
@twitter.my(:info)
end
it "should bless the model object returned" do
@twitter.should_receive(:bless_models).with(@user).and_return(@user)
@@ -140,11 +135,11 @@
user = @twitter.my(:info)
user.should eql(@user)
end
after(:each) do
- nilize(@request, @response, @connection, @twitter, @user, @screen_name)
+ nilize(@response, @connection, @twitter, @user, @screen_name)
end
end
describe Twitter::Client, "#my(:friends)" do
before(:each) do
@@ -155,21 +150,19 @@
Twitter::User.new(:screen_name => 'jane_eyre'),
Twitter::User.new(:screen_name => 'tess_derbyfield'),
Twitter::User.new(:screen_name => 'elizabeth_jane_newson'),
]
@json = JSON.unparse(@friends.collect {|f| f.to_hash })
- @request = mas_net_http_get(:basic_auth => nil)
@response = mas_net_http_response(:success, @json)
@connection = mas_net_http(@response)
@uris = Twitter::Client.class_eval("@@USER_URIS")
- @twitter.stub!(:create_http_get_request).and_return(@request)
Twitter::User.stub!(:unmarshal).and_return(@friends)
Net::HTTP.stub!(:new).and_return(@connection)
end
it "should create expected HTTP GET request" do
- @twitter.should_receive(:create_http_get_request).with(@uris[:friends], :id => @screen_name).and_return(@request)
+ @twitter.should_receive(:rest_oauth_connect).with(:get, "#{@uris[:friends]}?#{{:id => @screen_name}.to_http_str}").and_return(@response)
@twitter.my(:friends)
end
it "should bless models returned" do
@twitter.should_receive(:bless_models).with(@friends).and_return(@friends)
@@ -180,10 +173,10 @@
friends = @twitter.my(:friends)
friends.should eql(@friends)
end
after(:each) do
- nilize(@request, @response, @connection, @twitter, @friends, @screen_name)
+ nilize(@response, @connection, @twitter, @friends, @screen_name)
end
end
describe Twitter::Client, "#my(:invalid_action)" do
before(:each) do