mirror of
https://github.com/rest-client/rest-client.git
synced 2022-11-09 13:49:40 -05:00
Appease rubocop for a few rules.
This commit is contained in:
parent
18ee352a95
commit
440b8256e5
3 changed files with 34 additions and 11 deletions
|
@ -17,6 +17,10 @@ Lint/StringConversionInInterpolation:
|
|||
Lint/UnusedBlockArgument:
|
||||
Enabled: false
|
||||
|
||||
Lint/Eval:
|
||||
Exclude:
|
||||
- rest-client.windows.gemspec
|
||||
|
||||
# Offense count: 4
|
||||
# Cop supports --auto-correct.
|
||||
Style/Alias:
|
||||
|
@ -49,6 +53,20 @@ Style/ClassAndModuleCamelCase:
|
|||
Style/ClassAndModuleChildren:
|
||||
Enabled: false
|
||||
|
||||
# TODO?
|
||||
# Offense count: 14
|
||||
Metrics/AbcSize:
|
||||
Max: 75
|
||||
|
||||
# TODO?
|
||||
Metrics/MethodLength:
|
||||
Max: 66
|
||||
|
||||
# TODO?
|
||||
# Offense count: 4
|
||||
Metrics/PerceivedComplexity:
|
||||
Max: 24
|
||||
|
||||
# Offense count: 1
|
||||
# Configuration parameters: CountComments.
|
||||
Metrics/ClassLength:
|
||||
|
@ -105,6 +123,11 @@ Style/DoubleNegation:
|
|||
Style/EachWithObject:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 5
|
||||
# Cop supports --auto-correct.
|
||||
Style/EmptyLines:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 11
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
||||
|
|
|
@ -285,7 +285,7 @@ module RestClient
|
|||
# followed by two forward slashes. (The slashes are not part of the URI
|
||||
# RFC, but specified by the URL RFC 1738.)
|
||||
# https://tools.ietf.org/html/rfc3986#section-3.1
|
||||
url = 'http://' + url unless url.match(/\A[a-z][a-z0-9+.-]*:\/\//i)
|
||||
url = 'http://' + url unless url.match(%r{\A[a-z][a-z0-9+.-]*://}i)
|
||||
URI.parse(url)
|
||||
end
|
||||
|
||||
|
@ -554,7 +554,7 @@ module RestClient
|
|||
def stringify_headers headers
|
||||
headers.inject({}) do |result, (key, value)|
|
||||
if key.is_a? Symbol
|
||||
key = key.to_s.split(/_/).map { |w| w.capitalize }.join('-')
|
||||
key = key.to_s.split(/_/).map(&:capitalize).join('-')
|
||||
end
|
||||
if 'CONTENT-TYPE' == key.upcase
|
||||
target_value = value.to_s
|
||||
|
|
|
@ -6,26 +6,26 @@ describe RestClient::Payload do
|
|||
context "A regular Payload" do
|
||||
it "should use standard enctype as default content-type" do
|
||||
RestClient::Payload::UrlEncoded.new({}).headers['Content-Type'].
|
||||
should eq 'application/x-www-form-urlencoded'
|
||||
should eq 'application/x-www-form-urlencoded'
|
||||
end
|
||||
|
||||
it "should form properly encoded params" do
|
||||
RestClient::Payload::UrlEncoded.new({:foo => 'bar'}).to_s.
|
||||
should eq "foo=bar"
|
||||
should eq "foo=bar"
|
||||
["foo=bar&baz=qux", "baz=qux&foo=bar"].should include(
|
||||
RestClient::Payload::UrlEncoded.new({:foo => 'bar', :baz => 'qux'}).to_s)
|
||||
end
|
||||
|
||||
it "should escape parameters" do
|
||||
RestClient::Payload::UrlEncoded.new({'foo ' => 'bar'}).to_s.
|
||||
should eq "foo%20=bar"
|
||||
should eq "foo%20=bar"
|
||||
end
|
||||
|
||||
it "should properly handle hashes as parameter" do
|
||||
RestClient::Payload::UrlEncoded.new({:foo => {:bar => 'baz'}}).to_s.
|
||||
should eq "foo[bar]=baz"
|
||||
should eq "foo[bar]=baz"
|
||||
RestClient::Payload::UrlEncoded.new({:foo => {:bar => {:baz => 'qux'}}}).to_s.
|
||||
should eq "foo[bar][baz]=qux"
|
||||
should eq "foo[bar][baz]=qux"
|
||||
end
|
||||
|
||||
it "should handle many attributes inside a hash" do
|
||||
|
@ -45,16 +45,16 @@ describe RestClient::Payload do
|
|||
|
||||
it "should form properly use symbols as parameters" do
|
||||
RestClient::Payload::UrlEncoded.new({:foo => :bar}).to_s.
|
||||
should eq "foo=bar"
|
||||
should eq "foo=bar"
|
||||
RestClient::Payload::UrlEncoded.new({:foo => {:bar => :baz}}).to_s.
|
||||
should eq "foo[bar]=baz"
|
||||
should eq "foo[bar]=baz"
|
||||
end
|
||||
|
||||
it "should properly handle arrays as repeated parameters" do
|
||||
RestClient::Payload::UrlEncoded.new({:foo => ['bar']}).to_s.
|
||||
should eq "foo[]=bar"
|
||||
should eq "foo[]=bar"
|
||||
RestClient::Payload::UrlEncoded.new({:foo => ['bar', 'baz']}).to_s.
|
||||
should eq "foo[]=bar&foo[]=baz"
|
||||
should eq "foo[]=bar&foo[]=baz"
|
||||
end
|
||||
|
||||
it 'should not close if stream already closed' do
|
||||
|
|
Loading…
Reference in a new issue