1
0
Fork 0
mirror of https://github.com/jnunemaker/httparty synced 2023-03-27 23:23:07 -04:00

Merge pull request #579 from JonMidhir/fix_rspec_warnings

Fix rspec warnings
This commit is contained in:
John Nunemaker 2018-03-12 10:42:02 -04:00 committed by GitHub
commit 94d97bc2d1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 19 additions and 13 deletions

View file

@ -32,9 +32,12 @@ RSpec.describe HTTParty::ConnectionAdapter do
end
describe ".call" do
let(:uri) { URI 'http://www.google.com' }
let(:options) { { foo: :bar } }
it "generates an HTTParty::ConnectionAdapter instance with the given uri and options" do
expect(HTTParty::ConnectionAdapter).to receive(:new).with(@uri, @options).and_return(double(connection: nil))
HTTParty::ConnectionAdapter.call(@uri, @options)
expect(HTTParty::ConnectionAdapter).to receive(:new).with(uri, options).and_return(double(connection: nil))
HTTParty::ConnectionAdapter.call(uri, options)
end
it "calls #connection on the connection adapter" do
@ -42,7 +45,7 @@ RSpec.describe HTTParty::ConnectionAdapter do
connection = double('Connection')
expect(adapter).to receive(:connection).and_return(connection)
allow(HTTParty::ConnectionAdapter).to receive_messages(new: adapter)
expect(HTTParty::ConnectionAdapter.call(@uri, @options)).to be connection
expect(HTTParty::ConnectionAdapter.call(uri, options)).to be connection
end
end

View file

@ -23,6 +23,8 @@ RSpec.describe Net::HTTPHeader::DigestAuthenticator do
include Net::HTTPHeader
def initialize
@header = {}
@path = '/'
@method = 'GET'
end
end).new
}

View file

@ -27,10 +27,10 @@ RSpec.describe HTTParty::Parser do
end
it "returns the SupportedFormats constant for subclasses" do
class MyParser < HTTParty::Parser
SupportedFormats = {"application/atom+xml" => :atom}
end
expect(MyParser.formats).to eq({"application/atom+xml" => :atom})
klass = Class.new(HTTParty::Parser)
klass::SupportedFormats = { "application/atom+xml" => :atom }
expect(klass.formats).to eq({"application/atom+xml" => :atom})
end
end

View file

@ -612,7 +612,7 @@ RSpec.describe HTTParty::Request do
stub_request(:get, 'http://api.foo.com/v2')
.to_return(body: '<hash><foo>bar</foo></hash>')
body = ""
response = @request.perform { |chunk| body += chunk }
@request.perform { |chunk| body += chunk }
expect(body.length).to eq(27)
end

View file

@ -66,7 +66,7 @@ RSpec.describe HTTParty::Response do
subject { described_class.new(request, @response_object, @parsed_response) }
it 'does not throw exception' do
expect{ subject }.not_to raise_error(HTTParty::ResponseError)
expect{ subject }.not_to raise_error
end
end
end

View file

@ -358,11 +358,12 @@ RSpec.describe HTTParty do
it "raises UnsupportedFormat when the parser cannot handle the format" do
@klass.format :json
class MyParser < HTTParty::Parser
SupportedFormats = {}
end unless defined?(MyParser)
parser_class = Class.new(HTTParty::Parser)
parser_class::SupportedFormats = {}
expect do
@klass.parser MyParser
@klass.parser parser_class
end.to raise_error(HTTParty::UnsupportedFormat)
end