spec/twitter/client/favorites_spec.rb in twitter4r-0.5.0 vs spec/twitter/client/favorites_spec.rb in twitter4r-0.5.1

- old
+ new

@@ -13,16 +13,16 @@ @favorites = [] Twitter::Status.stub!(:unmarshal).and_return(@favorites) end it "should create expected HTTP GET request when not giving options" do - @twitter.should_receive(:rest_oauth_connect).with(:get, @uri).and_return(@response) + @twitter.should_receive(:rest_oauth_connect).with(:get, @uri, nil).and_return(@response) @twitter.favorites end it "should create expected HTTP GET request when giving :page options" do - @twitter.should_receive(:rest_oauth_connect).with(:get, "#{@uri}?#{@options.to_http_str}").and_return(@response) + @twitter.should_receive(:rest_oauth_connect).with(:get, @uri, @options).and_return(@response) @twitter.favorites(@options) end it "should raise Twitter::RESTError when 401 HTTP response received without giving options" do @connection = mas_net_http(mas_net_http_response(:not_authorized)) @@ -96,38 +96,38 @@ def finalize nilize(@uri, @request, @twitter, @default_header, @response, @error_response, @connection) end end -describe "Twitter::Client#favorite error handling", :shared => true do +shared_examples_for "Twitter::Client#favorite error handling" do it "should raise a Twitter::RESTError exception when a 401 HTTP response is received" do connection = mas_net_http(mas_net_http_response(:not_authorized)) lambda { execute_method }.should raise_error(Twitter::RESTError) - end + end it "should raise a Twitter::RESTError exception when a 403 HTTP response is received" do connection = mas_net_http(mas_net_http_response(:forbidden)) lambda { execute_method }.should raise_error(Twitter::RESTError) - end + end it "should raise a Twitter::RESTError exception when a 404 HTTP response is received" do connection = mas_net_http(mas_net_http_response(:file_not_found)) lambda { execute_method }.should raise_error(Twitter::RESTError) - end + end it "should raise a Twitter::RESTError exception when a 500 HTTP response is received" do connection = mas_net_http(mas_net_http_response(:server_error)) lambda { execute_method }.should raise_error(Twitter::RESTError) - end + end end describe Twitter::Client, "#favorite(:add, status)" do include FavoriteSpecMixin it_should_behave_like "Twitter::Client#favorite error handling" @@ -167,10 +167,10 @@ @twitter.favorite(:remove, @id) end it "should create expected DELETE request for :remove action supplying integer id of status" do @twitter.should_receive(:rest_oauth_connect).with(:delete, create_uri(:destroy, @id)).and_return(@request) - @twitter.favorite(:remove, @id) + execute_method end it "should create expected DELETE request for :remove action supplying status object" do @twitter.should_receive(:rest_oauth_connect).with(:delete, create_uri(:destroy, @id)).and_return(@request) @twitter.favorite(:remove, @status)