spec/twitter/client/user_spec.rb in twitter4r-0.2.2 vs spec/twitter/client/user_spec.rb in twitter4r-0.2.3

- old
+ new

@@ -46,16 +46,16 @@ @twitter.should_receive(:create_http_get_request).with(@uris[:info], {:id => @screen_name}).and_return(@request) @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(@model) + @twitter.should_receive(:bless_model).with(@user).and_return(@user) @twitter.user(@id) end it "should bless model returned when giving screen name" do - @twitter.should_receive(:bless_model).with(@user).and_return(@model) + @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) @@ -65,17 +65,63 @@ # TODO: Add specs for new Twitter::Client#user(id, :friends) and # Twitter::Client#user(id, :followers) use cases. describe Twitter::Client, "#user(id, :friends)" do before(:each) do @twitter = client_context + @id = 395784 + @screen_name = 'cafe_paradiso' + @user = Twitter::User.new( + :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 " do - + it "should create expected HTTP GET request when giving numeric user id" do + @twitter.should_receive(:create_http_get_request).with(@uris[:friends], {:id => @id}).and_return(@request) + @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], {:id => @user.to_i}).and_return(@request) + @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], {:id => @screen_name}).and_return(@request) + @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) + @twitter.user(@id, :friends) + end + + it "should bless model returned when giving Twitter::User object" do + @twitter.should_receive(:bless_model).with(@user).and_return(@user) + @twitter.user(@user, :friends) + end + + it "should bless model returned when giving screen name" do + @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) end end describe Twitter::Client, "#my(:info)" do before(:each) do