Skip to content

Commit

Permalink
Merge pull request #579 from JonMidhir/fix_rspec_warnings
Browse files Browse the repository at this point in the history
Fix rspec warnings
  • Loading branch information
jnunemaker authored Mar 12, 2018
2 parents 37336f4 + 2291d55 commit 94d97bc
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 13 deletions.
9 changes: 6 additions & 3 deletions spec/httparty/connection_adapter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,20 @@
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
adapter = double('Adapter')
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

Expand Down
2 changes: 2 additions & 0 deletions spec/httparty/net_digest_auth_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ def cookie_header
include Net::HTTPHeader
def initialize
@header = {}
@path = '/'
@method = 'GET'
end
end).new
}
Expand Down
8 changes: 4 additions & 4 deletions spec/httparty/parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
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

Expand Down
2 changes: 1 addition & 1 deletion spec/httparty/request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@
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

Expand Down
2 changes: 1 addition & 1 deletion spec/httparty/response_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
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
Expand Down
9 changes: 5 additions & 4 deletions spec/httparty_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -358,11 +358,12 @@ def self.parse(body)

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

Expand Down

0 comments on commit 94d97bc

Please sign in to comment.