spec/twitter/client/messaging_spec.rb in twitter4r-0.2.4 vs spec/twitter/client/messaging_spec.rb in twitter4r-0.2.5
- old
+ new
@@ -8,10 +8,11 @@
@response = mas_net_http_response(:success, "[]")
@connection = mas_net_http(@response)
Net::HTTP.stub!(:new).and_return(@connection)
@messages = []
Twitter::Message.stub!(:unmarshal).and_return(@messages)
+ @page = 2
end
it "should create expected HTTP GET request for :received case" do
@twitter.should_receive(:create_http_get_request).with(@uris[:received]).and_return(@request)
@twitter.messages(:received)
@@ -34,9 +35,25 @@
it "should raise an ArgumentError when giving an invalid messaging action" do
lambda {
@twitter.messages(:crap)
}.should raise_error(ArgumentError)
+ end
+
+ it "should accept an options Hash for paging" do
+ lambda {
+ @twitter.messages(:sent, :page => @page)
+ }.should_not raise_error(Exception)
+ end
+
+ it "should generate expected GET HTTP request for paging case" do
+ @twitter.should_receive(:create_http_get_request).with(@uris[:received] + "?page=#{@page}").and_return(@request)
+ @twitter.messages(:received, :page => @page)
+ end
+
+ it "should bless models for paging case" do
+ @twitter.should_receive(:bless_models).with(@messages).and_return(@messages)
+ @twitter.messages(:sent, :page => @page)
end
after(:each) do
nilize(@twitter, @uris, @request, @response, @connection, @messages)
end