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 end
describe ".call" do 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 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)) expect(HTTParty::ConnectionAdapter).to receive(:new).with(uri, options).and_return(double(connection: nil))
HTTParty::ConnectionAdapter.call(@uri, @options) HTTParty::ConnectionAdapter.call(uri, options)
end end
it "calls #connection on the connection adapter" do it "calls #connection on the connection adapter" do
@ -42,7 +45,7 @@ RSpec.describe HTTParty::ConnectionAdapter do
connection = double('Connection') connection = double('Connection')
expect(adapter).to receive(:connection).and_return(connection) expect(adapter).to receive(:connection).and_return(connection)
allow(HTTParty::ConnectionAdapter).to receive_messages(new: adapter) 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
end end

View file

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

View file

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

View file

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

View file

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

View file

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