diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..74285f4 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,188 @@ +AllCops: + TargetRubyVersion: 2.3 + # RuboCop has a bunch of cops enabled by default. This setting tells RuboCop + # to ignore them, so only the ones explicitly set in this file are enabled. + DisabledByDefault: true + Exclude: + - '**/templates/**/*' + - '**/vendor/**/*' + - 'actionpack/lib/action_dispatch/journey/parser.rb' + - 'lib/templates/**/*' + - 'db/**/*' + - 'config/**/*' + - 'vendor/**/*' + +# Prefer &&/|| over and/or. +Style/AndOr: + Enabled: true + +# Do not use braces for hash literals when they are the last argument of a +# method call. +Style/BracesAroundHashParameters: + Enabled: true + EnforcedStyle: context_dependent + +# Align `when` with `case`. +Layout/CaseIndentation: + Enabled: true + +# Align comments with method definitions. +Layout/CommentIndentation: + Enabled: true + +Layout/EmptyLineAfterMagicComment: + Enabled: true + +Layout/EmptyLinesAroundBlockBody: + Enabled: true + +# In a regular class definition, no empty lines around the body. +Layout/EmptyLinesAroundClassBody: + Enabled: true + +# In a regular method definition, no empty lines around the body. +Layout/EmptyLinesAroundMethodBody: + Enabled: true + +# In a regular module definition, no empty lines around the body. +Layout/EmptyLinesAroundModuleBody: + Enabled: true + +Layout/FirstParameterIndentation: + Enabled: true + +# Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }. +Style/HashSyntax: + Enabled: true + +# Method definitions after `private` or `protected` isolated calls need one +# extra level of indentation. +Layout/IndentationConsistency: + Enabled: true + EnforcedStyle: rails + +# Two spaces, no tabs (for indentation). +Layout/IndentationWidth: + Enabled: true + +Layout/SpaceAfterColon: + Enabled: true + +Layout/SpaceAfterComma: + Enabled: true + +Layout/SpaceAroundEqualsInParameterDefault: + Enabled: true + +Layout/SpaceAroundKeyword: + Enabled: true + +Layout/SpaceAroundOperators: + Enabled: true + +Layout/SpaceBeforeFirstArg: + Enabled: true + +# Defining a method with parameters needs parentheses. +Style/MethodDefParentheses: + Enabled: true + +Style/FrozenStringLiteralComment: + Enabled: true + EnforcedStyle: always + +# Use `foo {}` not `foo{}`. +Layout/SpaceBeforeBlockBraces: + Enabled: true + +# Use `foo { bar }` not `foo {bar}`. +Layout/SpaceInsideBlockBraces: + Enabled: true + +# Use `{ a: 1 }` not `{a:1}`. +Layout/SpaceInsideHashLiteralBraces: + Enabled: true + +Layout/SpaceInsideParens: + Enabled: true + +# Check quotes usage according to lint rule below. +Style/StringLiterals: + Enabled: true + EnforcedStyle: double_quotes + +# Detect hard tabs, no hard tabs. +Layout/Tab: + Enabled: true + +# Blank lines should not have any spaces. +Layout/TrailingBlankLines: + Enabled: true + +# No trailing whitespace. +Layout/TrailingWhitespace: + Enabled: true + +# Use quotes for string literals when they are enough. +Style/UnneededPercentQ: + Enabled: true + +# Align `end` with the matching keyword or starting expression except for +# assignments, where it should be aligned with the LHS. +Layout: + Enabled: true + EnforcedStyleAlignWith: keyword + +# Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg. +Lint/RequireParentheses: + Enabled: true + +# Don't warn until lines go beyond GitHub view limit +Metrics/LineLength: + Enabled: false + +# Prefer the compact readable style +Style/ClassAndModuleChildren: + EnforcedStyle: compact + +Style/FormatStringToken: + EnforcedStyle: template + +# Disable top-level documentation +Documentation: + Enabled: false + +Metrics/MethodLength: + Enabled: false + +Metrics/CyclomaticComplexity: + Enabled: false + +Metrics/PerceivedComplexity: + Enabled: false + +Metrics/AbcSize: + Enabled: false + +Metrics/ParameterLists: + CountKeywordArgs: false + +Style/RescueStandardError: + Enabled: false + +Metrics/ModuleLength: + Enabled: false + +Metrics/BlockLength: + Enabled: false + +Naming/AccessorMethodName: + Enabled: false + +Metrics/ClassLength: + Enabled: false + +Style/GuardClause: + Enabled: false + +# Ignore templates diff --git a/Gemfile b/Gemfile index c55b781..35c4f0f 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,7 @@ # frozen_string_literal: true -source 'http://rubygems.org' -source 'http://rails-assets.org' + +source "http://rubygems.org" +source "http://rails-assets.org" # Declare your gem's dependencies in abraham.gemspec. # Bundler will treat runtime dependencies like base dependencies, and @@ -9,9 +10,9 @@ gemspec # These rails-assets dependencies need to be added to the developer's Gemfile # since there's no way to specify a source in the gemspec. -source 'http://rails-assets.org' do - gem 'rails-assets-shepherd.js', '~> 1.8' - gem 'rails-assets-js-cookie', '~> 2.1' +source "http://rails-assets.org" do + gem "rails-assets-js-cookie", "~> 2.1" + gem "rails-assets-shepherd.js", "~> 1.8" end # Declare any dependencies that are still in development here instead of in @@ -23,4 +24,4 @@ end # gem 'byebug', group: [:development, :test] # Avoid the 'multiple sources' confusion -gem 'rails-assets-tether', :source => 'http://rails-assets.org/' +gem "rails-assets-tether", source: "http://rails-assets.org/" diff --git a/Gemfile.lock b/Gemfile.lock index 44061ad..b336379 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -50,7 +50,7 @@ GEM minitest (~> 5.1) tzinfo (~> 1.1) arel (7.1.4) - ast (2.3.0) + ast (2.4.0) builder (3.2.3) concurrent-ruby (1.0.5) crass (1.0.4) @@ -60,6 +60,7 @@ GEM activesupport (>= 4.2.0) i18n (1.0.1) concurrent-ruby (~> 1.0) + jaro_winkler (1.5.1) jquery-rails (4.3.3) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) @@ -76,9 +77,10 @@ GEM nio4r (2.3.1) nokogiri (1.8.2) mini_portile2 (~> 2.3.0) - parser (2.3.2.0) - ast (~> 2.2) - powerpack (0.1.1) + parallel (1.12.1) + parser (2.5.1.2) + ast (~> 2.4.0) + powerpack (0.1.2) rack (2.0.5) rack-test (0.6.3) rack (>= 1.0) @@ -109,18 +111,20 @@ GEM method_source rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) - rainbow (2.1.0) + rainbow (3.0.0) rake (12.3.1) rb-fsevent (0.10.3) rb-inotify (0.9.10) ffi (>= 0.5.0, < 2) - rubocop (0.45.0) - parser (>= 2.3.1.1, < 3.0) + rubocop (0.59.2) + jaro_winkler (~> 1.5.1) + parallel (~> 1.10) + parser (>= 2.5, != 2.5.1.1) powerpack (~> 0.1) - rainbow (>= 1.99.1, < 3.0) + rainbow (>= 2.2.2, < 4.0) ruby-progressbar (~> 1.7) unicode-display_width (~> 1.0, >= 1.0.1) - ruby-progressbar (1.8.1) + ruby-progressbar (1.10.0) sass (3.5.6) sass-listen (~> 4.0.0) sass-listen (4.0.0) @@ -132,7 +136,7 @@ GEM sprockets (>= 2.8, < 4.0) sprockets-rails (>= 2.0, < 4.0) tilt (>= 1.1, < 3) - sprockets (3.7.1) + sprockets (3.7.2) concurrent-ruby (~> 1.0) rack (> 1, < 3) sprockets-rails (3.2.1) @@ -145,7 +149,7 @@ GEM tilt (2.0.8) tzinfo (1.2.5) thread_safe (~> 0.1) - unicode-display_width (1.1.1) + unicode-display_width (1.4.0) websocket-driver (0.6.5) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.3) @@ -162,4 +166,4 @@ DEPENDENCIES sqlite3 BUNDLED WITH - 1.16.1 + 1.16.5 diff --git a/Rakefile b/Rakefile index 0ca2ff1..1ad7a1e 100644 --- a/Rakefile +++ b/Rakefile @@ -1,33 +1,34 @@ # frozen_string_literal: true + begin - require 'bundler/setup' + require "bundler/setup" rescue LoadError - puts 'You must `gem install bundler` and `bundle install` to run rake tasks' + puts "You must `gem install bundler` and `bundle install` to run rake tasks" end -require 'rdoc/task' +require "rdoc/task" RDoc::Task.new(:rdoc) do |rdoc| - rdoc.rdoc_dir = 'rdoc' - rdoc.title = 'Abraham' - rdoc.options << '--line-numbers' - rdoc.rdoc_files.include('README.md') - rdoc.rdoc_files.include('lib/**/*.rb') + rdoc.rdoc_dir = "rdoc" + rdoc.title = "Abraham" + rdoc.options << "--line-numbers" + rdoc.rdoc_files.include("README.md") + rdoc.rdoc_files.include("lib/**/*.rb") end -APP_RAKEFILE = File.expand_path('../test/dummy/Rakefile', __FILE__) -load 'rails/tasks/engine.rake' +APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__) +load "rails/tasks/engine.rake" -load 'rails/tasks/statistics.rake' +load "rails/tasks/statistics.rake" -require 'bundler/gem_tasks' +require "bundler/gem_tasks" -require 'rake/testtask' +require "rake/testtask" Rake::TestTask.new(:test) do |t| - t.libs << 'lib' - t.libs << 'test' - t.pattern = 'test/**/*_test.rb' + t.libs << "lib" + t.libs << "test" + t.pattern = "test/**/*_test.rb" t.verbose = false end diff --git a/abraham.gemspec b/abraham.gemspec index 3efe8da..d1c275b 100644 --- a/abraham.gemspec +++ b/abraham.gemspec @@ -1,28 +1,29 @@ # frozen_string_literal: true -$LOAD_PATH.push File.expand_path('../lib', __FILE__) + +$LOAD_PATH.push File.expand_path("lib", __dir__) # Maintain your gem's version: -require 'abraham/version' +require "abraham/version" # Describe your gem and declare its dependencies: Gem::Specification.new do |s| - s.name = 'abraham' + s.name = "abraham" s.version = Abraham::VERSION - s.authors = ['Jonathan Abbett'] - s.email = ['jonathan@act.md'] - s.homepage = 'https://github.com/actmd/abraham' - s.summary = 'Trackable application tours for Rails with i18n support, based on Shepherd.js.' - s.description = 'Trackable application tours for Rails with i18n support, based on Shepherd.js.' - s.license = 'MIT' + s.authors = ["Jonathan Abbett"] + s.email = ["jonathan@act.md"] + s.homepage = "https://github.com/actmd/abraham" + s.summary = "Trackable application tours for Rails with i18n support, based on Shepherd.js." + s.description = "Trackable application tours for Rails with i18n support, based on Shepherd.js." + s.license = "MIT" - s.files = Dir['{app,config,db,lib}/**/*', 'MIT-LICENSE', 'Rakefile', 'README.md'] + s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.md"] - s.add_dependency 'rails', '~> 5.0', '>= 5.0.0.1' - s.add_dependency 'sass-rails', '~> 5.0' - s.add_dependency 'jquery-rails' - s.add_dependency 'rails-assets-shepherd.js', '~> 1.8' - s.add_dependency 'rails-assets-js-cookie', '~> 2.1' + s.add_dependency "jquery-rails" + s.add_dependency "rails", "~> 5.0", ">= 5.0.0.1" + s.add_dependency "rails-assets-js-cookie", "~> 2.1" + s.add_dependency "rails-assets-shepherd.js", "~> 1.8" + s.add_dependency "sass-rails", "~> 5.0" - s.add_development_dependency 'sqlite3' - s.add_development_dependency 'rubocop' + s.add_development_dependency "rubocop" + s.add_development_dependency "sqlite3" end diff --git a/app/controllers/abraham_histories_controller.rb b/app/controllers/abraham_histories_controller.rb index d22446a..49fffe1 100644 --- a/app/controllers/abraham_histories_controller.rb +++ b/app/controllers/abraham_histories_controller.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + class AbrahamHistoriesController < ApplicationController def create @abraham_history = AbrahamHistory.new(abraham_history_params) @@ -14,8 +15,8 @@ class AbrahamHistoriesController < ApplicationController private - # Never trust parameters from the scary internet, only allow the white list through. - def abraham_history_params - params.require(:abraham_history).permit(:controller_name, :action_name, :tour_name) - end + # Never trust parameters from the scary internet, only allow the white list through. + def abraham_history_params + params.require(:abraham_history).permit(:controller_name, :action_name, :tour_name) + end end diff --git a/app/helpers/abraham_helper.rb b/app/helpers/abraham_helper.rb index 4cd4b88..4456e5b 100644 --- a/app/helpers/abraham_helper.rb +++ b/app/helpers/abraham_helper.rb @@ -1,13 +1,11 @@ # frozen_string_literal: true + module AbrahamHelper def abraham_tour # Do we have tours for this controller/action in the user's locale? tours = Rails.configuration.abraham.tours["#{controller_name}.#{action_name}.#{I18n.locale}"] - unless tours - # How about the default locale? - tours = Rails.configuration.abraham.tours["#{controller_name}.#{action_name}.#{I18n.default_locale}"] - end + tours ||= Rails.configuration.abraham.tours["#{controller_name}.#{action_name}.#{I18n.default_locale}"] if tours completed = AbrahamHistory.where( @@ -19,9 +17,9 @@ module AbrahamHelper if remaining.any? # Generate the javascript snippet for the next remaining tour - render(partial: 'application/abraham', + render(partial: "application/abraham", locals: { tour_name: remaining.first, - steps: tours[remaining.first]['steps'] }) + steps: tours[remaining.first]["steps"] }) end end end diff --git a/app/models/abraham_history.rb b/app/models/abraham_history.rb index 7db45f9..b400a14 100644 --- a/app/models/abraham_history.rb +++ b/app/models/abraham_history.rb @@ -1,3 +1,4 @@ # frozen_string_literal: true + class AbrahamHistory < ActiveRecord::Base end diff --git a/app/models/application_record.rb b/app/models/application_record.rb index 767a072..71fbba5 100644 --- a/app/models/application_record.rb +++ b/app/models/application_record.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + class ApplicationRecord < ActiveRecord::Base self.abstract_class = true end diff --git a/bin/rails b/bin/rails index 4824017..70f3634 100755 --- a/bin/rails +++ b/bin/rails @@ -1,14 +1,15 @@ #!/usr/bin/env ruby # frozen_string_literal: true + # This command will automatically be run when you run "rails" with Rails gems # installed from the root of your application. -ENGINE_ROOT = File.expand_path('../..', __FILE__) -ENGINE_PATH = File.expand_path('../../lib/abraham/engine', __FILE__) +ENGINE_ROOT = File.expand_path("..", __dir__) +ENGINE_PATH = File.expand_path("../lib/abraham/engine", __dir__) # Set up gems listed in the Gemfile. -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) -require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) +require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"]) -require 'rails/all' -require 'rails/engine/commands' +require "rails/all" +require "rails/engine/commands" diff --git a/config/routes.rb b/config/routes.rb index 773d296..bda83df 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + Rails.application.routes.draw do resources :abraham_histories, only: :create end diff --git a/lib/abraham.rb b/lib/abraham.rb index d4213bf..d413b79 100644 --- a/lib/abraham.rb +++ b/lib/abraham.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true -require 'abraham/engine' + +require "abraham/engine" module Abraham end diff --git a/lib/abraham/engine.rb b/lib/abraham/engine.rb index 7273ae4..4daedda 100644 --- a/lib/abraham/engine.rb +++ b/lib/abraham/engine.rb @@ -1,10 +1,11 @@ # frozen_string_literal: true -require 'rubygems' + +require "rubygems" module Abraham class Engine < ::Rails::Engine - require 'rails-assets-shepherd.js' - require 'jquery-rails' - require 'rails-assets-js-cookie' + require "rails-assets-shepherd.js" + require "jquery-rails" + require "rails-assets-js-cookie" end end diff --git a/lib/abraham/version.rb b/lib/abraham/version.rb index 7d49053..e52c405 100644 --- a/lib/abraham/version.rb +++ b/lib/abraham/version.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module Abraham - VERSION = '1.3' + VERSION = "1.3" end diff --git a/lib/generators/abraham/install_generator.rb b/lib/generators/abraham/install_generator.rb index 570471d..323f759 100644 --- a/lib/generators/abraham/install_generator.rb +++ b/lib/generators/abraham/install_generator.rb @@ -1,27 +1,30 @@ # frozen_string_literal: true -require 'rails/generators' -require 'rails/generators/active_record' + +require "rails/generators" +require "rails/generators/active_record" module Abraham module Generators class InstallGenerator < ActiveRecord::Generators::Base - argument :name, type: :string, default: 'random_name' + argument :name, type: :string, default: "random_name" class_option :'skip-migration', type: :boolean, desc: "Don't generate a migration for the histories table" class_option :'skip-initializer', type: :boolean, desc: "Don't generate an initializer" - source_root File.expand_path(File.join(File.dirname(__FILE__), 'templates')) + source_root File.expand_path(File.join(File.dirname(__FILE__), "templates")) # Copies the migration template to db/migrate. def copy_files - return if options['skip-migration'] - migration_template 'migration.rb', 'db/migrate/create_abraham_histories.rb' + return if options["skip-migration"] + + migration_template "migration.rb", "db/migrate/create_abraham_histories.rb" end def create_initializer - return if options['skip-initializer'] - copy_file 'initializer.rb', 'config/initializers/abraham.rb' - copy_file 'abraham.yml', 'config/abraham.yml' + return if options["skip-initializer"] + + copy_file "initializer.rb", "config/initializers/abraham.rb" + copy_file "abraham.yml", "config/abraham.yml" end end end diff --git a/lib/generators/abraham/templates/initializer.rb b/lib/generators/abraham/templates/initializer.rb index c3fc522..d0dcf30 100644 --- a/lib/generators/abraham/templates/initializer.rb +++ b/lib/generators/abraham/templates/initializer.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + Rails.application.configure do tours = {} diff --git a/lib/generators/abraham/templates/migration.rb b/lib/generators/abraham/templates/migration.rb index 295ebdd..ad7d5b0 100644 --- a/lib/generators/abraham/templates/migration.rb +++ b/lib/generators/abraham/templates/migration.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + class CreateAbrahamHistories < ActiveRecord::Migration[5.0] def change create_table :abraham_histories do |t| diff --git a/test/abraham_test.rb b/test/abraham_test.rb index 845f33e..7cf3ba4 100644 --- a/test/abraham_test.rb +++ b/test/abraham_test.rb @@ -1,8 +1,9 @@ # frozen_string_literal: true -require 'test_helper' + +require "test_helper" class Abraham::Test < ActiveSupport::TestCase - test 'truth' do + test "truth" do assert_kind_of Module, Abraham end end diff --git a/test/dummy/Rakefile b/test/dummy/Rakefile index 84f2bc3..d2a78aa 100644 --- a/test/dummy/Rakefile +++ b/test/dummy/Rakefile @@ -1,7 +1,8 @@ # frozen_string_literal: true + # Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. -require_relative 'config/application' +require_relative "config/application" Rails.application.load_tasks diff --git a/test/dummy/app/channels/application_cable/channel.rb b/test/dummy/app/channels/application_cable/channel.rb index 51e3e93..9aec230 100644 --- a/test/dummy/app/channels/application_cable/channel.rb +++ b/test/dummy/app/channels/application_cable/channel.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module ApplicationCable class Channel < ActionCable::Channel::Base end diff --git a/test/dummy/app/channels/application_cable/connection.rb b/test/dummy/app/channels/application_cable/connection.rb index fa70319..8d6c2a1 100644 --- a/test/dummy/app/channels/application_cable/connection.rb +++ b/test/dummy/app/channels/application_cable/connection.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + module ApplicationCable class Connection < ActionCable::Connection::Base end diff --git a/test/dummy/app/controllers/application_controller.rb b/test/dummy/app/controllers/application_controller.rb index 5acba08..b3b8e0c 100644 --- a/test/dummy/app/controllers/application_controller.rb +++ b/test/dummy/app/controllers/application_controller.rb @@ -1,9 +1,10 @@ # frozen_string_literal: true + class ApplicationController < ActionController::Base protect_from_forgery with: :exception helper_method :current_user def current_user - OpenStruct.new(id: Random.rand(1..99999)) + OpenStruct.new(id: Random.rand(1..99_999)) end end diff --git a/test/dummy/app/controllers/dashboard_controller.rb b/test/dummy/app/controllers/dashboard_controller.rb index 9c70ebc..aa4389d 100644 --- a/test/dummy/app/controllers/dashboard_controller.rb +++ b/test/dummy/app/controllers/dashboard_controller.rb @@ -1,8 +1,7 @@ # frozen_string_literal: true -class DashboardController < ApplicationController - def home - end - def other - end +class DashboardController < ApplicationController + def home; end + + def other; end end diff --git a/test/dummy/app/helpers/application_helper.rb b/test/dummy/app/helpers/application_helper.rb index 71249b9..15b06f0 100644 --- a/test/dummy/app/helpers/application_helper.rb +++ b/test/dummy/app/helpers/application_helper.rb @@ -1,3 +1,4 @@ # frozen_string_literal: true + module ApplicationHelper end diff --git a/test/dummy/app/helpers/dashboard_helper.rb b/test/dummy/app/helpers/dashboard_helper.rb index 79ce46b..d18930d 100644 --- a/test/dummy/app/helpers/dashboard_helper.rb +++ b/test/dummy/app/helpers/dashboard_helper.rb @@ -1,3 +1,4 @@ # frozen_string_literal: true + module DashboardHelper end diff --git a/test/dummy/app/jobs/application_job.rb b/test/dummy/app/jobs/application_job.rb index 32fe70b..d92ffdd 100644 --- a/test/dummy/app/jobs/application_job.rb +++ b/test/dummy/app/jobs/application_job.rb @@ -1,3 +1,4 @@ # frozen_string_literal: true + class ApplicationJob < ActiveJob::Base end diff --git a/test/dummy/app/mailers/application_mailer.rb b/test/dummy/app/mailers/application_mailer.rb index 2428900..5cc63a0 100644 --- a/test/dummy/app/mailers/application_mailer.rb +++ b/test/dummy/app/mailers/application_mailer.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true + class ApplicationMailer < ActionMailer::Base - default from: 'from@example.com' - layout 'mailer' + default from: "from@example.com" + layout "mailer" end diff --git a/test/dummy/app/models/application_record.rb b/test/dummy/app/models/application_record.rb index 767a072..71fbba5 100644 --- a/test/dummy/app/models/application_record.rb +++ b/test/dummy/app/models/application_record.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + class ApplicationRecord < ActiveRecord::Base self.abstract_class = true end diff --git a/test/dummy/bin/bundle b/test/dummy/bin/bundle index 86f3466..5015ba6 100755 --- a/test/dummy/bin/bundle +++ b/test/dummy/bin/bundle @@ -1,4 +1,5 @@ #!/usr/bin/env ruby # frozen_string_literal: true -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) -load Gem.bin_path('bundler', 'bundle') + +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) +load Gem.bin_path("bundler", "bundle") diff --git a/test/dummy/bin/rails b/test/dummy/bin/rails index dd027b4..22f2d8d 100755 --- a/test/dummy/bin/rails +++ b/test/dummy/bin/rails @@ -1,5 +1,6 @@ #!/usr/bin/env ruby # frozen_string_literal: true -APP_PATH = File.expand_path('../config/application', __dir__) -require_relative '../config/boot' -require 'rails/commands' + +APP_PATH = File.expand_path("../config/application", __dir__) +require_relative "../config/boot" +require "rails/commands" diff --git a/test/dummy/bin/rake b/test/dummy/bin/rake index 609af74..e436ea5 100755 --- a/test/dummy/bin/rake +++ b/test/dummy/bin/rake @@ -1,5 +1,6 @@ #!/usr/bin/env ruby # frozen_string_literal: true -require_relative '../config/boot' -require 'rake' + +require_relative "../config/boot" +require "rake" Rake.application.run diff --git a/test/dummy/bin/setup b/test/dummy/bin/setup index ffca742..e413f40 100755 --- a/test/dummy/bin/setup +++ b/test/dummy/bin/setup @@ -1,11 +1,12 @@ #!/usr/bin/env ruby # frozen_string_literal: true -require 'pathname' -require 'fileutils' + +require "pathname" +require "fileutils" include FileUtils # path to your application root. -APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) +APP_ROOT = Pathname.new File.expand_path("..", __dir__) def system!(*args) system(*args) || abort("\n== Command #{args} failed ==") @@ -15,9 +16,9 @@ chdir APP_ROOT do # This script is a starting point to setup your application. # Add necessary setup steps to this file. - puts '== Installing dependencies ==' - system! 'gem install bundler --conservative' - system('bundle check') || system!('bundle install') + puts "== Installing dependencies ==" + system! "gem install bundler --conservative" + system("bundle check") || system!("bundle install") # puts "\n== Copying sample files ==" # unless File.exist?('config/database.yml') @@ -25,11 +26,11 @@ chdir APP_ROOT do # end puts "\n== Preparing database ==" - system! 'bin/rails db:setup' + system! "bin/rails db:setup" puts "\n== Removing old logs and tempfiles ==" - system! 'bin/rails log:clear tmp:clear' + system! "bin/rails log:clear tmp:clear" puts "\n== Restarting application server ==" - system! 'bin/rails restart' + system! "bin/rails restart" end diff --git a/test/dummy/bin/update b/test/dummy/bin/update index 3f81e54..998dede 100755 --- a/test/dummy/bin/update +++ b/test/dummy/bin/update @@ -1,11 +1,12 @@ #!/usr/bin/env ruby # frozen_string_literal: true -require 'pathname' -require 'fileutils' + +require "pathname" +require "fileutils" include FileUtils # path to your application root. -APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) +APP_ROOT = Pathname.new File.expand_path("..", __dir__) def system!(*args) system(*args) || abort("\n== Command #{args} failed ==") @@ -15,16 +16,16 @@ chdir APP_ROOT do # This script is a way to update your development environment automatically. # Add necessary update steps to this file. - puts '== Installing dependencies ==' - system! 'gem install bundler --conservative' - system('bundle check') || system!('bundle install') + puts "== Installing dependencies ==" + system! "gem install bundler --conservative" + system("bundle check") || system!("bundle install") puts "\n== Updating database ==" - system! 'bin/rails db:migrate' + system! "bin/rails db:migrate" puts "\n== Removing old logs and tempfiles ==" - system! 'bin/rails log:clear tmp:clear' + system! "bin/rails log:clear tmp:clear" puts "\n== Restarting application server ==" - system! 'bin/rails restart' + system! "bin/rails restart" end diff --git a/test/dummy/config.ru b/test/dummy/config.ru index 7eae264..bff88d6 100644 --- a/test/dummy/config.ru +++ b/test/dummy/config.ru @@ -1,6 +1,7 @@ # frozen_string_literal: true + # This file is used by Rack-based servers to start the application. -require_relative 'config/environment' +require_relative "config/environment" run Rails.application diff --git a/test/dummy/config/application.rb b/test/dummy/config/application.rb index 6b3a2da..88c8809 100644 --- a/test/dummy/config/application.rb +++ b/test/dummy/config/application.rb @@ -1,10 +1,11 @@ # frozen_string_literal: true -require_relative 'boot' -require 'rails/all' +require_relative "boot" + +require "rails/all" Bundler.require(*Rails.groups) -require 'abraham' +require "abraham" module Dummy class Application < Rails::Application diff --git a/test/dummy/config/boot.rb b/test/dummy/config/boot.rb index c90021f..59459d4 100644 --- a/test/dummy/config/boot.rb +++ b/test/dummy/config/boot.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true -# Set up gems listed in the Gemfile. -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../Gemfile', __dir__) -require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) -$LOAD_PATH.unshift File.expand_path('../../../lib', __dir__) +# Set up gems listed in the Gemfile. +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../Gemfile", __dir__) + +require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"]) +$LOAD_PATH.unshift File.expand_path("../../../lib", __dir__) diff --git a/test/dummy/config/environment.rb b/test/dummy/config/environment.rb index 12ea62f..7df99e8 100644 --- a/test/dummy/config/environment.rb +++ b/test/dummy/config/environment.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true + # Load the Rails application. -require_relative 'application' +require_relative "application" # Initialize the Rails application. Rails.application.initialize! diff --git a/test/dummy/config/environments/development.rb b/test/dummy/config/environments/development.rb index 8f4ad21..a296f8b 100644 --- a/test/dummy/config/environments/development.rb +++ b/test/dummy/config/environments/development.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. @@ -14,12 +15,12 @@ Rails.application.configure do config.consider_all_requests_local = true # Enable/disable caching. By default caching is disabled. - if Rails.root.join('tmp/caching-dev.txt').exist? + if Rails.root.join("tmp/caching-dev.txt").exist? config.action_controller.perform_caching = true config.cache_store = :memory_store config.public_file_server.headers = { - 'Cache-Control' => 'public, max-age=172800' + "Cache-Control" => "public, max-age=172800" } else config.action_controller.perform_caching = false diff --git a/test/dummy/config/environments/production.rb b/test/dummy/config/environments/production.rb index cbdb208..d1ac5cd 100644 --- a/test/dummy/config/environments/production.rb +++ b/test/dummy/config/environments/production.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. @@ -17,7 +18,7 @@ Rails.application.configure do # Disable serving static files from the `/public` folder by default since # Apache or NGINX already handles this. - config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? + config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present? # Compress JavaScripts and CSS. config.assets.js_compressor = :uglifier @@ -76,7 +77,7 @@ Rails.application.configure do # require 'syslog/logger' # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') - if ENV['RAILS_LOG_TO_STDOUT'].present? + if ENV["RAILS_LOG_TO_STDOUT"].present? logger = ActiveSupport::Logger.new(STDOUT) logger.formatter = config.log_formatter config.logger = ActiveSupport::TaggedLogging.new(logger) diff --git a/test/dummy/config/environments/test.rb b/test/dummy/config/environments/test.rb index 416a71c..f88be04 100644 --- a/test/dummy/config/environments/test.rb +++ b/test/dummy/config/environments/test.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. @@ -16,7 +17,7 @@ Rails.application.configure do # Configure public file server for tests with Cache-Control for performance. config.public_file_server.enabled = true config.public_file_server.headers = { - 'Cache-Control' => 'public, max-age=3600' + "Cache-Control" => "public, max-age=3600" } # Show full error reports and disable caching. diff --git a/test/dummy/config/initializers/abraham.rb b/test/dummy/config/initializers/abraham.rb index c3fc522..45344f5 100644 --- a/test/dummy/config/initializers/abraham.rb +++ b/test/dummy/config/initializers/abraham.rb @@ -1,13 +1,14 @@ # frozen_string_literal: true + Rails.application.configure do tours = {} - if Rails.root.join('config/tours').exist? - Dir[Rails.root.join('config/tours/*/')].each do |dir| - Dir[dir + '*.yml'].each do |yml| + if Rails.root.join("config/tours").exist? + Dir[Rails.root.join("config/tours/*/")].each do |dir| + Dir[dir + "*.yml"].each do |yml| path_parts = yml.split(File::SEPARATOR) controller = path_parts[path_parts.size - 2] - file_parts = path_parts[path_parts.size - 1].split('.') + file_parts = path_parts[path_parts.size - 1].split(".") action = file_parts[0] locale = file_parts[1] t = YAML.load_file(yml) diff --git a/test/dummy/config/initializers/assets.rb b/test/dummy/config/initializers/assets.rb index 9287bcd..1be14d3 100644 --- a/test/dummy/config/initializers/assets.rb +++ b/test/dummy/config/initializers/assets.rb @@ -1,8 +1,9 @@ # frozen_string_literal: true + # Be sure to restart your server when you modify this file. # Version of your assets, change this if you want to expire all your assets. -Rails.application.config.assets.version = '1.0' +Rails.application.config.assets.version = "1.0" # Add additional assets to the asset load path # Rails.application.config.assets.paths << Emoji.images_path diff --git a/test/dummy/config/initializers/cookies_serializer.rb b/test/dummy/config/initializers/cookies_serializer.rb index 2a72959..ee8dff9 100644 --- a/test/dummy/config/initializers/cookies_serializer.rb +++ b/test/dummy/config/initializers/cookies_serializer.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Be sure to restart your server when you modify this file. # Specify a serializer for the signed and encrypted cookie jars. diff --git a/test/dummy/config/initializers/filter_parameter_logging.rb b/test/dummy/config/initializers/filter_parameter_logging.rb index b7fe123..7a4f47b 100644 --- a/test/dummy/config/initializers/filter_parameter_logging.rb +++ b/test/dummy/config/initializers/filter_parameter_logging.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Be sure to restart your server when you modify this file. # Configure sensitive parameters which will be filtered from the log file. diff --git a/test/dummy/config/initializers/new_framework_defaults.rb b/test/dummy/config/initializers/new_framework_defaults.rb index d3c12d7..69b31ed 100644 --- a/test/dummy/config/initializers/new_framework_defaults.rb +++ b/test/dummy/config/initializers/new_framework_defaults.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Be sure to restart your server when you modify this file. # # This file contains migration options to ease your Rails 5.0 upgrade. diff --git a/test/dummy/config/initializers/session_store.rb b/test/dummy/config/initializers/session_store.rb index fcc1c91..606745f 100644 --- a/test/dummy/config/initializers/session_store.rb +++ b/test/dummy/config/initializers/session_store.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Be sure to restart your server when you modify this file. -Rails.application.config.session_store :cookie_store, key: '_dummy_session' +Rails.application.config.session_store :cookie_store, key: "_dummy_session" diff --git a/test/dummy/config/initializers/wrap_parameters.rb b/test/dummy/config/initializers/wrap_parameters.rb index 18c3825..2f3c0db 100644 --- a/test/dummy/config/initializers/wrap_parameters.rb +++ b/test/dummy/config/initializers/wrap_parameters.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Be sure to restart your server when you modify this file. # This file contains settings for ActionController::ParamsWrapper which diff --git a/test/dummy/config/puma.rb b/test/dummy/config/puma.rb index da41eff..991c3a6 100644 --- a/test/dummy/config/puma.rb +++ b/test/dummy/config/puma.rb @@ -1,20 +1,21 @@ # frozen_string_literal: true + # Puma can serve each request in a thread from an internal thread pool. # The `threads` method setting takes two numbers a minimum and maximum. # Any libraries that use thread pools should be configured to match # the maximum value specified for Puma. Default is set to 5 threads for minimum # and maximum, this matches the default thread size of Active Record. # -threads_count = ENV.fetch('RAILS_MAX_THREADS') { 5 }.to_i +threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i threads threads_count, threads_count # Specifies the `port` that Puma will listen on to receive requests, default is 3000. # -port ENV.fetch('PORT') { 3000 } +port ENV.fetch("PORT") { 3000 } # Specifies the `environment` that Puma will run in. # -environment ENV.fetch('RAILS_ENV') { 'development' } +environment ENV.fetch("RAILS_ENV") { "development" } # Specifies the number of `workers` to boot in clustered mode. # Workers are forked webserver processes. If using threads and workers together diff --git a/test/dummy/config/routes.rb b/test/dummy/config/routes.rb index 40e2c71..c88d17c 100644 --- a/test/dummy/config/routes.rb +++ b/test/dummy/config/routes.rb @@ -1,8 +1,9 @@ # frozen_string_literal: true -Rails.application.routes.draw do - get 'dashboard/home' - get 'dashboard/other' +Rails.application.routes.draw do + get "dashboard/home" + + get "dashboard/other" # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html end diff --git a/test/dummy/config/spring.rb b/test/dummy/config/spring.rb index 312295f..c5933e4 100644 --- a/test/dummy/config/spring.rb +++ b/test/dummy/config/spring.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true -%w( + +%w[ .ruby-version .rbenv-vars tmp/restart.txt tmp/caching-dev.txt -).each { |path| Spring.watch(path) } +].each { |path| Spring.watch(path) } diff --git a/test/dummy/db/migrate/20161118143752_create_abraham_histories.rb b/test/dummy/db/migrate/20161118143752_create_abraham_histories.rb index 295ebdd..ad7d5b0 100644 --- a/test/dummy/db/migrate/20161118143752_create_abraham_histories.rb +++ b/test/dummy/db/migrate/20161118143752_create_abraham_histories.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + class CreateAbrahamHistories < ActiveRecord::Migration[5.0] def change create_table :abraham_histories do |t| diff --git a/test/dummy/db/schema.rb b/test/dummy/db/schema.rb index 17fe716..c9d35d4 100644 --- a/test/dummy/db/schema.rb +++ b/test/dummy/db/schema.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # This file is auto-generated from the current state of the database. Instead # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. @@ -12,15 +13,15 @@ # It's strongly recommended that you check this file into your version control system. ActiveRecord::Schema.define(version: 20_161_118_143_752) do - create_table 'abraham_histories', force: :cascade do |t| - t.string 'controller_name' - t.string 'action_name' - t.string 'tour_name' - t.integer 'creator_id', null: false - t.datetime 'created_at', null: false - t.datetime 'updated_at', null: false - t.index ['created_at'], name: 'index_abraham_histories_on_created_at' - t.index ['creator_id'], name: 'index_abraham_histories_on_creator_id' - t.index ['updated_at'], name: 'index_abraham_histories_on_updated_at' + create_table "abraham_histories", force: :cascade do |t| + t.string "controller_name" + t.string "action_name" + t.string "tour_name" + t.integer "creator_id", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["created_at"], name: "index_abraham_histories_on_created_at" + t.index ["creator_id"], name: "index_abraham_histories_on_creator_id" + t.index ["updated_at"], name: "index_abraham_histories_on_updated_at" end end diff --git a/test/dummy/test/controllers/abraham_histories_controller_test.rb b/test/dummy/test/controllers/abraham_histories_controller_test.rb index 26ace95..1b1b374 100644 --- a/test/dummy/test/controllers/abraham_histories_controller_test.rb +++ b/test/dummy/test/controllers/abraham_histories_controller_test.rb @@ -1,10 +1,11 @@ # frozen_string_literal: true -require 'test_helper' + +require "test_helper" class AbrahamHistoriesControllerTest < ActionDispatch::IntegrationTest - test 'should create AbrahamHistory' do - assert_difference ['AbrahamHistory.count'] do - post abraham_histories_url, as: :json, params: { abraham_history: { action_name: 'foo', controller_name: 'bar', tour_name: 'baz' } } + test "should create AbrahamHistory" do + assert_difference ["AbrahamHistory.count"] do + post abraham_histories_url, as: :json, params: { abraham_history: { action_name: "foo", controller_name: "bar", tour_name: "baz" } } end end end diff --git a/test/dummy/test/controllers/dashboard_controller_test.rb b/test/dummy/test/controllers/dashboard_controller_test.rb index c684713..9b28f69 100644 --- a/test/dummy/test/controllers/dashboard_controller_test.rb +++ b/test/dummy/test/controllers/dashboard_controller_test.rb @@ -1,39 +1,40 @@ # frozen_string_literal: true -require 'test_helper' + +require "test_helper" class DashboardControllerTest < ActionDispatch::IntegrationTest - test 'uses configured shepherd theme' do + test "uses configured shepherd theme" do # default get dashboard_home_url assert_response :success - assert_select 'body script' do |element| + assert_select "body script" do |element| # it's the home tour assert element.text.include? "classes: 'shepherd-theme-default'" end # custom - Rails.configuration.abraham.default_theme = 'my-custom-theme' + Rails.configuration.abraham.default_theme = "my-custom-theme" get dashboard_home_url - assert_select 'body script' do |element| + assert_select "body script" do |element| # it's the home tour assert element.text.include? "classes: 'my-custom-theme'" end end - test 'home should have home tour code' do + test "home should have home tour code" do get dashboard_home_url assert_response :success - assert_select 'body script' do |element| + assert_select "body script" do |element| # it's the home tour - assert element.text.include? 'ENGLISH This first HOME step is centered text-only' + assert element.text.include? "ENGLISH This first HOME step is centered text-only" # it has three steps - assert element.text.include? 'step-1' - assert element.text.include? 'step-2' - assert element.text.include? 'step-3' - assert element.text.include? 'step-4' + assert element.text.include? "step-1" + assert element.text.include? "step-2" + assert element.text.include? "step-3" + assert element.text.include? "step-4" # Generates a showOn option - assert element.text.include? 'showOn:' + assert element.text.include? "showOn:" # it will post the right completion information assert element.text.include? "controller_name: 'dashboard'" assert element.text.include? "action_name: 'home'" @@ -41,15 +42,15 @@ class DashboardControllerTest < ActionDispatch::IntegrationTest end end - test 'other should have other tour code' do + test "other should have other tour code" do get dashboard_other_url assert_response :success - assert_select 'body script' do |element| + assert_select "body script" do |element| # it's the home tour - assert element.text.include? 'TOUR ONE step one ENGLISH' + assert element.text.include? "TOUR ONE step one ENGLISH" # it has only one steps - assert element.text.include? 'step-1' + assert element.text.include? "step-1" # it will post the right completion information assert element.text.include? "controller_name: 'dashboard'" assert element.text.include? "action_name: 'other'" diff --git a/test/install_generator_test.rb b/test/install_generator_test.rb index 3cc0d96..1a80ee6 100644 --- a/test/install_generator_test.rb +++ b/test/install_generator_test.rb @@ -1,46 +1,47 @@ # frozen_string_literal: true -require 'test_helper' -require 'rails/generators' -require 'generators/abraham/install_generator' + +require "test_helper" +require "rails/generators" +require "generators/abraham/install_generator" class InstallGeneratorTest < Rails::Generators::TestCase tests Abraham::Generators::InstallGenerator - destination File.expand_path('../../tmp', __FILE__) + destination File.expand_path("../tmp", __dir__) setup :prepare_destination - test 'should generate a migration' do + test "should generate a migration" do begin run_generator - assert_migration 'db/migrate/create_abraham_histories' + assert_migration "db/migrate/create_abraham_histories" ensure FileUtils.rm_rf destination_root end end - test 'should skip the migration when told to do so' do + test "should skip the migration when told to do so" do begin - run_generator ['--skip-migration'] - assert_no_migration 'db/migrate/create_abraham_histories' + run_generator ["--skip-migration"] + assert_no_migration "db/migrate/create_abraham_histories" ensure FileUtils.rm_rf destination_root end end - test 'should generate an initializer' do + test "should generate an initializer" do begin run_generator - assert_file 'config/initializers/abraham.rb' - assert_file 'config/abraham.yml' + assert_file "config/initializers/abraham.rb" + assert_file "config/abraham.yml" ensure FileUtils.rm_rf destination_root end end - test 'should skip the initializer when told to do so' do + test "should skip the initializer when told to do so" do begin - run_generator ['--skip-initializer'] - assert_no_file 'config/initializers/abraham.rb' + run_generator ["--skip-initializer"] + assert_no_file "config/initializers/abraham.rb" ensure FileUtils.rm_rf destination_root end diff --git a/test/integration/navigation_test.rb b/test/integration/navigation_test.rb index 3c97384..43df32a 100644 --- a/test/integration/navigation_test.rb +++ b/test/integration/navigation_test.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true -require 'test_helper' + +require "test_helper" class NavigationTest < ActionDispatch::IntegrationTest # test "the truth" do diff --git a/test/models/abraham_history_test.rb b/test/models/abraham_history_test.rb index de50c1b..363bf8b 100644 --- a/test/models/abraham_history_test.rb +++ b/test/models/abraham_history_test.rb @@ -1,5 +1,6 @@ # frozen_string_literal: true -require 'test_helper' + +require "test_helper" class AbrahamHistoryTest < ActiveSupport::TestCase # test "the truth" do diff --git a/test/test_helper.rb b/test/test_helper.rb index af68d44..cf48e30 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,10 +1,11 @@ # frozen_string_literal: true -# Configure Rails Environment -ENV['RAILS_ENV'] = 'test' -require File.expand_path('../../test/dummy/config/environment.rb', __FILE__) -ActiveRecord::Migrator.migrations_paths = [File.expand_path('../../test/dummy/db/migrate', __FILE__)] -require 'rails/test_help' +# Configure Rails Environment +ENV["RAILS_ENV"] = "test" + +require File.expand_path("../test/dummy/config/environment.rb", __dir__) +ActiveRecord::Migrator.migrations_paths = [File.expand_path("../test/dummy/db/migrate", __dir__)] +require "rails/test_help" # Filter out Minitest backtrace while allowing backtrace from other libraries # to be shown.