Rubocop fixes

This commit is contained in:
Hakan Ensari 2017-06-14 21:16:21 +01:00
parent cc539ebdd0
commit 40b4e39465
20 changed files with 29 additions and 9 deletions

2
.pryrc
View File

@ -1,3 +1,5 @@
# frozen_string_literal: true
Pry.config.editor = 'vim'
require './config/environment'
puts "Loading #{App.env}"

View File

@ -1,2 +1,3 @@
# frozen_string_literal: true
Dir.glob('lib/tasks/*.rake').each { |r| import r }

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
require 'pathname'
# Encapsulates app configuration

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
require_relative 'app'
$LOAD_PATH << App.root.join('lib')
Dir[App.root.join('config/initializers/*.rb')].each { |f| require f }

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
require 'pg'
require 'sequel'

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
job_type :rake, 'cd :path && foreman run bundle exec rake :task --silent :output'
every '*/15 13,14,15,16,17 * * 1-5' do

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
worker_process_count = (ENV['WORKER_PROCESSES'] || 4).to_i
preload_app true

View File

@ -7,7 +7,7 @@ Sequel.migration do
String :iso_code
Float :rate
index [:date, :iso_code], unique: true
index %i[date iso_code], unique: true
end
end
end

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
require 'oj'
require 'sinatra'
require 'rack/cors'

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
class Currency < Sequel::Model
dataset_module do
def recent

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
require 'currency'
class Quote

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
namespace :db do
desc 'Create db'
task :create do

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
task :environment do
require './config/environment'
end

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
namespace :rates do
task setup: :environment do
require 'currency'

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
return unless ENV['RACK_ENV'] == 'test'
require 'rake/testtask'
@ -12,4 +13,4 @@ end
RuboCop::RakeTask.new
task default: %w(db:migrate rates:load test rubocop)
task default: %w[db:migrate rates:load test rubocop]

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
require_relative 'helper'
require 'rack/test'
require 'api'
@ -32,7 +33,7 @@ describe 'the API' do
it 'filters symbols' do
get '/latest?symbols=USD'
json['rates'].keys.must_equal %w(USD)
json['rates'].keys.must_equal %w[USD]
end
it 'aliases base as from' do
@ -42,7 +43,7 @@ describe 'the API' do
it 'aliases symbols as to' do
get '/latest?to=USD'
json['rates'].keys.must_equal %w(USD)
json['rates'].keys.must_equal %w[USD]
end
it 'returns historical quotes' do
@ -57,14 +58,14 @@ describe 'the API' do
end
it 'returns a cache control header' do
%w(/ /latest /2012-11-20).each do |path|
%w[/ /latest /2012-11-20].each do |path|
get path
headers['Cache-Control'].wont_be_nil
end
end
it 'returns a last modified header' do
%w(/latest /2012-11-20).each do |path|
%w[/latest /2012-11-20].each do |path|
get path
headers['Last-Modified'].wont_be_nil
end
@ -76,7 +77,7 @@ describe 'the API' do
end
it 'allows cross-origin requests' do
%w(/ /latest /2012-11-20).each do |path|
%w[/ /latest /2012-11-20].each do |path|
header 'Origin', '*'
get path
assert headers.key?('Access-Control-Allow-Methods')
@ -84,7 +85,7 @@ describe 'the API' do
end
it 'responds to preflight requests' do
%w(/ /latest /2012-11-20).each do |path|
%w[/ /latest /2012-11-20].each do |path|
header 'Origin', '*'
header 'Access-Control-Request-Method', 'GET'
header 'Access-Control-Request-Headers', 'Content-Type'

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
require_relative 'helper'
require 'currency'

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
require_relative 'helper'
require 'rack/test'
require 'api'

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
require './config/environment'
require 'minitest/autorun'
require 'minitest/pride'

View File

@ -1,4 +1,5 @@
# frozen_string_literal: true
require_relative 'helper'
require 'quote'
@ -27,7 +28,7 @@ describe Quote do
it 'casts to hash' do
stub_rates do |quote|
%i(base date rates).each do |key|
%i[base date rates].each do |key|
quote.to_h.keys.must_include key
end
end