Skip to content

Commit

Permalink
Merge pull request #155 from solidusio/check_rubocop
Browse files Browse the repository at this point in the history
Add Rubocop to the CI checks
  • Loading branch information
coorasse committed Aug 5, 2019
2 parents 38ada19 + 7b23835 commit 0ae0b4c
Show file tree
Hide file tree
Showing 14 changed files with 56 additions and 32 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@ spec/dummy
.rvmrc
.sass-cache
public/spree
.ruby-version
.ruby-gemset
10 changes: 8 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
---
inherit_from: .hound.yml

Metrics/BlockLength:
Exclude:
- spec/**/*
- lib/tasks/**/*

AllCops:
Exclude:
- spec/dummy/**/*
- bin/*
- 'spec/dummy/**/*'
- 'bin/**/*'
- 'vendor/**/*'
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.5.1
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ language: ruby
before_install:
- gem update --system # https://github.com/travis-ci/travis-ci/issues/8978
- gem install bundler
rvm:
- 2.5
script:
- bundle exec rubocop
- bundle exec rake
8 changes: 5 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
source "https://rubygems.org"
# frozen_string_literal: true

source 'https://rubygems.org'

branch = ENV.fetch('SOLIDUS_BRANCH', 'master')
gem "solidus", github: "solidusio/solidus", branch: branch
gem 'solidus', github: 'solidusio/solidus', branch: branch

if ENV['DB'] == 'mysql'
gem 'mysql2', '~> 0.4.10'
Expand All @@ -10,8 +12,8 @@ else
end

group :development, :test do
gem "pry-rails"
gem 'i18n-tasks', '~> 0.9' if branch == 'master'
gem 'pry-rails'
end

gemspec
12 changes: 6 additions & 6 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# frozen_string_literal: true

require 'bundler'
Bundler::GemHelper.install_tasks

require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new

task :default do
if Dir["spec/dummy"].empty?
if Dir['spec/dummy'].empty?
Rake::Task[:test_app].invoke
Dir.chdir("../../")
Dir.chdir('../../')
end
Rake::Task[:spec].invoke
end
Expand All @@ -24,12 +26,10 @@ namespace :solidus_i18n do
desc 'Update by retrieving the latest Solidus locale files'
task :update_default do
require 'open-uri'
puts "Fetching latest Solidus locale file"
puts 'Fetching latest Solidus locale file'
location = 'https://raw.github.com/solidusio/solidus/master/core/config/locales/en.yml'

open("#{locales_dir}/en.yml", 'wb') do |file|
file << open(location).read
end
File.write("#{locales_dir}/en.yml", URI.parse(location).read)
end

def locales_dir
Expand Down
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# frozen_string_literal: true

Spree::Core::Engine.routes.draw do
end
2 changes: 2 additions & 0 deletions lib/solidus_i18n.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'solidus_core'
require 'solidus_i18n/engine'
require 'solidus_i18n/version'
2 changes: 2 additions & 0 deletions lib/solidus_i18n/engine.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module SolidusI18n
class Engine < Rails::Engine
engine_name 'solidus_i18n'
Expand Down
2 changes: 2 additions & 0 deletions lib/solidus_i18n/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module SolidusI18n
module_function

Expand Down
24 changes: 13 additions & 11 deletions lib/tasks/solidus_i18n/upgrade.rake
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# frozen_string_literal: true

require 'fileutils'

namespace :solidus_i18n do
desc 'Upgrades to version without globalize.'
task upgrade: :environment do
files = %w(
files = %w[
add_translations_to_main_models
add_translations_to_product_permalink
add_translations_to_option_value
Expand All @@ -13,7 +15,7 @@ namespace :solidus_i18n do
remove_null_constraints_from_spree_tables
add_deleted_at_to_translation_tables
add_translations_to_store
).collect do |file_name|
].collect do |file_name|
Dir.glob Rails.root.join('db', 'migrate', "*_#{file_name}*.rb")
end.flatten

Expand All @@ -23,21 +25,21 @@ namespace :solidus_i18n do
# Install new migrations
Rake::Task['solidus_i18n:install:migrations'].invoke

puts <<-DESC
Upgraded migrations successfully.
puts <<~DESC
Upgraded migrations successfully.
Now please remove these lines from your vendor/assets folder:
Now please remove these lines from your vendor/assets folder:
From `vendor/assets/javascripts/spree/backend/all.js`
From `vendor/assets/javascripts/spree/backend/all.js`
//= require spree/backend/spree_i18n
//= require spree/backend/spree_i18n
and from `vendor/assets/stylesheets/spree/backend/all.css`
and from `vendor/assets/stylesheets/spree/backend/all.css`
*= require spree/backend/spree_i18n
*= require spree/backend/spree_i18n
Don't forget to run `rake db:migrate` now.
Don't forget to run `rake db:migrate` now.
DESC
DESC
end
end
7 changes: 4 additions & 3 deletions solidus_i18n.gemspec
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# coding: utf-8
lib = File.expand_path('../lib/', __FILE__)
# frozen_string_literal: true

lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift lib unless $LOAD_PATH.include?(lib)

require 'solidus_i18n/version'
Expand All @@ -24,8 +25,8 @@ Gem::Specification.new do |s|
s.add_runtime_dependency 'solidus_core', ['>= 1.1', '< 3']

s.add_development_dependency 'pry-rails', '>= 0.3.0'
s.add_development_dependency 'rubocop', '>= 0.24.1'
s.add_development_dependency 'rspec-rails', '~> 3.1'
s.add_development_dependency 'rubocop', '0.67.2'
s.add_development_dependency 'simplecov', '~> 0.9'
s.add_development_dependency 'sqlite3', '~> 1.3.6'
end
8 changes: 5 additions & 3 deletions spec/solidus_i18n_spec.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe "solidus_i18n" do
RSpec.describe 'solidus_i18n' do
describe 'defined locales' do
subject do
I18n.available_locales.select do |locale|
I18n.t('spree.i18n.this_file_language', locale: locale, fallback: false, default: nil)
end
end

it "contains the added locales" do
it 'contains the added locales' do
# Add to this list when adding/removing locales
expect(subject).to match_array %i[
en
Expand Down Expand Up @@ -54,7 +56,7 @@
]
end

it "has a unique description for each locale" do
it 'has a unique description for each locale' do
descriptions = subject.map do |locale|
I18n.t('spree.i18n.this_file_language', locale: locale)
end
Expand Down
4 changes: 3 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# frozen_string_literal: true

require 'simplecov'
SimpleCov.start 'rails'

ENV['RAILS_ENV'] ||= 'test'

begin
require File.expand_path('../dummy/config/environment', __FILE__)
require File.expand_path('dummy/config/environment', __dir__)
rescue LoadError
puts 'Could not load dummy application. Please ensure you have run `bundle exec rake test_app`'
exit
Expand Down

0 comments on commit 0ae0b4c

Please sign in to comment.