Skip to content

Commit

Permalink
RuboCop: only Style/StringLiterals
Browse files Browse the repository at this point in the history
  • Loading branch information
olleolleolle committed Feb 4, 2020
1 parent 15b86d7 commit ec8d7e9
Show file tree
Hide file tree
Showing 21 changed files with 262 additions and 262 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ default_gemfile = ENV['BUNDLE_GEMFILE'] =~ /Gemfile$/
begin
require 'cane/rake_task'
rescue LoadError
warn "warning: cane not available; skipping quality checks."
warn 'warning: cane not available; skipping quality checks.'
else
desc %(Check code quality metrics with Cane)
Cane::RakeTask.new(:quality) do |cane|
Expand Down
2 changes: 1 addition & 1 deletion faraday_middleware.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
spec.version = FaradayMiddleware::VERSION

spec.summary = %q{Various middleware for Faraday}
spec.authors = ["Erik Michaels-Ober", "Wynn Netherland"]
spec.authors = ['Erik Michaels-Ober', 'Wynn Netherland']
spec.email = ['[email protected]', '[email protected]']
spec.homepage = 'https://github.com/lostisland/faraday_middleware'
spec.licenses = ['MIT']
Expand Down
2 changes: 1 addition & 1 deletion lib/faraday_middleware/request/method_override.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module FaradayMiddleware
# http:https://rack.rubyforge.org/doc/classes/Rack/MethodOverride.html
class MethodOverride < Faraday::Middleware

HEADER = "X-Http-Method-Override".freeze
HEADER = 'X-Http-Method-Override'.freeze

# Public: Initialize the middleware.
#
Expand Down
8 changes: 4 additions & 4 deletions lib/faraday_middleware/request/oauth2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ def initialize(app, token = nil, options = {})

if options[:token_type].nil?
warn "\nWarning: FaradayMiddleware::OAuth2 initialized with default "\
"token_type - token will be added as both a query string parameter "\
"and an Authorization header. In the next major release, tokens will "\
"be added exclusively as an Authorization header by default. Please "\
"visit https://github.com/lostisland/faraday_middleware/wiki for more information."
'token_type - token will be added as both a query string parameter '\
'and an Authorization header. In the next major release, tokens will '\
'be added exclusively as an Authorization header by default. Please '\
'visit https://github.com/lostisland/faraday_middleware/wiki for more information.'
end
end

Expand Down
4 changes: 2 additions & 2 deletions lib/faraday_middleware/response/parse_dates.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require "time"
require "faraday"
require 'time'
require 'faraday'

module FaradayMiddleware
# Parse dates from response body
Expand Down
2 changes: 1 addition & 1 deletion lib/faraday_middleware/response/parse_json.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def process_response(env)
end

BRACKETS = %w- [ { -
WHITESPACE = [ " ", "\n", "\r", "\t" ]
WHITESPACE = [ ' ', "\n", "\r", "\t" ]

def parse_response?(env)
super and BRACKETS.include? first_char(env[:body])
Expand Down
22 changes: 11 additions & 11 deletions spec/unit/caching_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@
expect(get('/broken').body).to eq('request:2')
end

context ":ignore_params" do
context ':ignore_params' do
let(:options) { {:ignore_params => %w[ utm_source utm_term ]} }

it "strips ignored parameters from cache_key" do
it 'strips ignored parameters from cache_key' do
expect(get('/').body).to eq('request:1')
expect(get('/?utm_source=a').body).to eq('request:1')
expect(get('/?utm_source=a&utm_term=b').body).to eq('request:1')
Expand All @@ -80,30 +80,30 @@
end
end

context ":full_key" do
context ':full_key' do
let(:options) { {:full_key => true} }

it "use full URL as cache key" do
it 'use full URL as cache key' do
expect(get('http:https://www.site-a.com/test').body).to eq('request:1')
expect(get('http:https://www.site-b.com/test').body).to eq('request:2')
end
end

context ":write_options" do
context ':write_options' do
let(:options) { {:write_options => {:expires_in => 9000 } } }

it "passes on the options when writing to the cache" do
expect(@cache).to receive(:write).with(Digest::SHA1.hexdigest("/"),
it 'passes on the options when writing to the cache' do
expect(@cache).to receive(:write).with(Digest::SHA1.hexdigest('/'),
instance_of(Faraday::Response),
options[:write_options])
get('/')
end

context "with no :write_options" do
context 'with no :write_options' do
let(:options) { {} }

it "doesn't pass a third options parameter to the cache's #write" do
expect(@cache).to receive(:write).with(Digest::SHA1.hexdigest("/"), instance_of(Faraday::Response))
expect(@cache).to receive(:write).with(Digest::SHA1.hexdigest('/'), instance_of(Faraday::Response))
get('/')
end
end
Expand All @@ -128,8 +128,8 @@ def fetch(key)
class CachingLint < Struct.new(:app)
def call(env)
app.call(env).on_complete do
raise "no headers" unless env[:response_headers].is_a? Hash
raise "no response" unless env[:response].is_a? Faraday::Response
raise 'no headers' unless env[:response_headers].is_a? Hash
raise 'no response' unless env[:response].is_a? Faraday::Response
# raise "env not identical" unless env[:response].env.object_id == env.object_id
end
end
Expand Down
28 changes: 14 additions & 14 deletions spec/unit/chunked_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require 'faraday_middleware/response/chunked'

RSpec.describe FaradayMiddleware::Chunked, :type => :response do
context "no transfer-encoding" do
context 'no transfer-encoding' do
it "doesn't change nil body" do
expect(process(nil).body).to be_nil
end
Expand All @@ -16,8 +16,8 @@
end
end

context "transfer-encoding gzip" do
let(:headers) { {"transfer-encoding" => "gzip"}}
context 'transfer-encoding gzip' do
let(:headers) { {'transfer-encoding' => 'gzip'}}

it "doesn't change nil body" do
expect(process(nil).body).to be_nil
Expand All @@ -32,8 +32,8 @@
end
end

context "transfer-encoding chunked" do
let(:headers) { {"transfer-encoding" => "chunked"}}
context 'transfer-encoding chunked' do
let(:headers) { {'transfer-encoding' => 'chunked'}}

it "doesn't change nil body" do
expect(process(nil).body).to be_nil
Expand All @@ -43,35 +43,35 @@
expect(process('').body).to eq('')
end

it "parses a basic chunked body" do
it 'parses a basic chunked body' do
expect(process("10\r\nasdfghjklasdfghj\r\n0\r\n").body).to eq('asdfghjklasdfghj')
end

it "parses a chunked body with no ending chunk" do
it 'parses a chunked body with no ending chunk' do
expect(process("10\r\nasdfghjklasdfghj\r\n").body).to eq('asdfghjklasdfghj')
end

it "parses a chunked body with no trailing CRLF on the data chunk" do
it 'parses a chunked body with no trailing CRLF on the data chunk' do
expect(process("10\r\nasdfghjklasdfghj0\r\n").body).to eq('asdfghjklasdfghj')
end

it "parses a chunked body with an extension" do
it 'parses a chunked body with an extension' do
expect(process("10;foo=bar\r\nasdfghjklasdfghj\r\n0\r\n").body).to eq('asdfghjklasdfghj')
end

it "parses a chunked body with two extensions" do
it 'parses a chunked body with two extensions' do
expect(process("10;foo=bar;bar=baz\r\nasdfghjklasdfghj\r\n0\r\n").body).to eq('asdfghjklasdfghj')
end

it "parses a chunked body with two chunks" do
it 'parses a chunked body with two chunks' do
expect(process("8\r\nasdfghjk\r\n8\r\nlasdfghj\r\n0\r\n").body).to eq('asdfghjklasdfghj')
end
end

context "transfer-encoding chunked,chunked" do
let(:headers) { {"transfer-encoding" => "chunked,chunked"}}
context 'transfer-encoding chunked,chunked' do
let(:headers) { {'transfer-encoding' => 'chunked,chunked'}}

it "parses a basic chunked body" do
it 'parses a basic chunked body' do
expect(process("10\r\nasdfghjklasdfghj\r\n0\r\n").body).to eq('asdfghjklasdfghj')
end
end
Expand Down
28 changes: 14 additions & 14 deletions spec/unit/encode_json_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def process(body, content_type = nil)
def result_body() result[:body] end
def result_type() result[:request_headers]['content-type'] end

context "no body" do
context 'no body' do
let(:result) { process(nil) }

it "doesn't change body" do
Expand All @@ -25,7 +25,7 @@ def result_type() result[:request_headers]['content-type'] end
end
end

context "empty body" do
context 'empty body' do
let(:result) { process('') }

it "doesn't change body" do
Expand All @@ -37,42 +37,42 @@ def result_type() result[:request_headers]['content-type'] end
end
end

context "string body" do
context 'string body' do
let(:result) { process('{"a":1}') }

it "doesn't change body" do
expect(result_body).to eq('{"a":1}')
end

it "adds content type" do
it 'adds content type' do
expect(result_type).to eq('application/json')
end
end

context "object body" do
context 'object body' do
let(:result) { process({:a => 1}) }

it "encodes body" do
it 'encodes body' do
expect(result_body).to eq('{"a":1}')
end

it "adds content type" do
it 'adds content type' do
expect(result_type).to eq('application/json')
end
end

context "empty object body" do
context 'empty object body' do
let(:result) { process({}) }

it "encodes body" do
it 'encodes body' do
expect(result_body).to eq('{}')
end
end

context "object body with json type" do
context 'object body with json type' do
let(:result) { process({:a => 1}, 'application/json; charset=utf-8') }

it "encodes body" do
it 'encodes body' do
expect(result_body).to eq('{"a":1}')
end

Expand All @@ -81,10 +81,10 @@ def result_type() result[:request_headers]['content-type'] end
end
end

context "object body with vendor json type" do
context 'object body with vendor json type' do
let(:result) { process({:a => 1}, 'application/vnd.myapp.v1+json; charset=utf-8') }

it "encodes body" do
it 'encodes body' do
expect(result_body).to eq('{"a":1}')
end

Expand All @@ -93,7 +93,7 @@ def result_type() result[:request_headers]['content-type'] end
end
end

context "object body with incompatible type" do
context 'object body with incompatible type' do
let(:result) { process({:a => 1}, 'application/xml; charset=utf-8') }

it "doesn't change body" do
Expand Down
Loading

0 comments on commit ec8d7e9

Please sign in to comment.