diff --git a/.rubocop.yml b/.rubocop.yml index 524cd8c..8b13789 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,44 +1 @@ -AllCops: - Exclude: - - 'apps/web/application.rb' - - 'db/**/*' - - 'spec/**/*' - - 'Rakefile' -ConditionalAssignment: - Enabled: false -StringLiterals: - Enabled: false -RedundantReturn: - Enabled: false -Documentation: - Enabled: false -WordArray: - Enabled: false -AbcSize: - Enabled: false -MutableConstant: - Enabled: false -SignalException: - Enabled: false -CyclomaticComplexity: - Enabled: false -MissingRespondToMissing: - Enabled: false -MethodMissingSuper: - Enabled: false -Style/FrozenStringLiteralComment: - Enabled: false -LineLength: - Max: 120 -Style/EmptyMethod: - Enabled: false -Bundler/OrderedGems: - Enabled: false -Metrics/BlockLength: - Exclude: - - 'Rakefile' - - '**/*.rake' - - 'spec/**/*.rb' -Style/ClassAndModuleChildren: - Enabled: false diff --git a/Gemfile b/Gemfile index fb2297c..3757fae 100644 --- a/Gemfile +++ b/Gemfile @@ -1,34 +1,36 @@ +# frozen_string_literal: true + source 'https://rubygems.org' -gem 'rake' -gem 'hanami', '~> 1.3' +gem 'hanami', '~> 1.3' gem 'hanami-model', '~> 1.3' +gem 'rake' -gem 'pg' -gem 'sass', '~> 3.4', '>= 3.4.22' gem 'bootstrap', '~> 4.3.1' gem 'haml' gem 'json-schema' -gem 'sidekiq' gem 'omni_scrapper', path: '../omni_scrapper' +gem 'pg' +gem 'sass', '~> 3.4', '>= 3.4.22' +gem 'sidekiq' group :development do # Code reloading # See: http://hanamirb.org/guides/projects/code-reloading - gem 'shotgun', platforms: :ruby gem 'hanami-webconsole' + gem 'shotgun', platforms: :ruby end group :test, :development do gem 'dotenv', '~> 2.4' - gem 'rubocop' gem 'hanami-fabrication' gem 'pry', '~> 0.12.2' + gem 'rubocop' end group :test do - gem 'rspec' gem 'capybara' + gem 'rspec' end group :production do diff --git a/Rakefile b/Rakefile index 5000dfa..4e3aa76 100644 --- a/Rakefile +++ b/Rakefile @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rake' require 'hanami/rake_tasks' @@ -5,5 +7,5 @@ begin require 'rspec/core/rake_task' RSpec::Core::RakeTask.new(:spec) task default: :spec -rescue LoadError + # rescue LoadError end diff --git a/apps/web/application.rb b/apps/web/application.rb index 80999f0..b809016 100644 --- a/apps/web/application.rb +++ b/apps/web/application.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'sass' require 'hanami/helpers' require 'hanami/assets' @@ -19,10 +21,10 @@ class Application < Hanami::Application # # When you add new directories, remember to add them here. # - load_paths << [ - 'validations', - 'controllers', - 'views' + load_paths << %w[ + validations + controllers + views ] # Handle exceptions with HTTP statuses (true) or don't catch them (false). @@ -225,7 +227,7 @@ class Application < Hanami::Application # # * https://developer.mozilla.org/en-US/docs/Web/Security/CSP/CSP_policy_directives # - security.content_security_policy %{ + security.content_security_policy %( form-action 'self'; frame-ancestors 'self'; base-uri 'self'; @@ -240,7 +242,7 @@ class Application < Hanami::Application child-src 'self'; frame-src 'self'; media-src 'self' - } + ) ## # FRAMEWORKS diff --git a/apps/web/config/routes.rb b/apps/web/config/routes.rb index 473e8d5..72756b8 100644 --- a/apps/web/config/routes.rb +++ b/apps/web/config/routes.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + root to: 'home#index' resources :sites resources :schemas diff --git a/apps/web/controllers/home/index.rb b/apps/web/controllers/home/index.rb index 05ab532..e1ab3dd 100644 --- a/apps/web/controllers/home/index.rb +++ b/apps/web/controllers/home/index.rb @@ -1,11 +1,12 @@ +# frozen_string_literal: true + module Web module Controllers module Home class Index include Web::Action - def call(params) - end + def call(params); end end end end diff --git a/apps/web/controllers/schemas/create.rb b/apps/web/controllers/schemas/create.rb index 956bb8b..74fb5bd 100644 --- a/apps/web/controllers/schemas/create.rb +++ b/apps/web/controllers/schemas/create.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Web module Controllers module Schemas diff --git a/apps/web/controllers/schemas/index.rb b/apps/web/controllers/schemas/index.rb index 4a3a813..db358d2 100644 --- a/apps/web/controllers/schemas/index.rb +++ b/apps/web/controllers/schemas/index.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Web module Controllers module Schemas @@ -6,7 +8,7 @@ class Index expose :schemas - def call(params) + def call(_params) @schemas = SchemaRepository.new.all end end diff --git a/apps/web/controllers/schemas/new.rb b/apps/web/controllers/schemas/new.rb index 0c617a7..9b3b61e 100644 --- a/apps/web/controllers/schemas/new.rb +++ b/apps/web/controllers/schemas/new.rb @@ -1,11 +1,12 @@ +# frozen_string_literal: true + module Web module Controllers module Schemas class New include Web::Action - def call(params) - end + def call(params); end end end end diff --git a/apps/web/controllers/sites/create.rb b/apps/web/controllers/sites/create.rb index a95136f..ba7dad0 100644 --- a/apps/web/controllers/sites/create.rb +++ b/apps/web/controllers/sites/create.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Web module Controllers module Sites diff --git a/apps/web/controllers/sites/destroy.rb b/apps/web/controllers/sites/destroy.rb index 89ab05c..8361a41 100644 --- a/apps/web/controllers/sites/destroy.rb +++ b/apps/web/controllers/sites/destroy.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Web module Controllers module Sites diff --git a/apps/web/controllers/sites/edit.rb b/apps/web/controllers/sites/edit.rb index 81c8a69..741d28b 100644 --- a/apps/web/controllers/sites/edit.rb +++ b/apps/web/controllers/sites/edit.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Web module Controllers module Sites diff --git a/apps/web/controllers/sites/index.rb b/apps/web/controllers/sites/index.rb index ea7ae47..f0fed05 100644 --- a/apps/web/controllers/sites/index.rb +++ b/apps/web/controllers/sites/index.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Web module Controllers module Sites diff --git a/apps/web/controllers/sites/new.rb b/apps/web/controllers/sites/new.rb index be52ab6..04c94b5 100644 --- a/apps/web/controllers/sites/new.rb +++ b/apps/web/controllers/sites/new.rb @@ -1,11 +1,12 @@ +# frozen_string_literal: true + module Web module Controllers module Sites class New include Web::Action - def call(params) - end + def call(params); end end end end diff --git a/apps/web/controllers/sites/show.rb b/apps/web/controllers/sites/show.rb index a8f1c33..8c0a9fb 100644 --- a/apps/web/controllers/sites/show.rb +++ b/apps/web/controllers/sites/show.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Web module Controllers module Sites diff --git a/apps/web/controllers/sites/update.rb b/apps/web/controllers/sites/update.rb index 2b5432b..96baa78 100644 --- a/apps/web/controllers/sites/update.rb +++ b/apps/web/controllers/sites/update.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Web module Controllers module Sites diff --git a/apps/web/controllers/tasks/create.rb b/apps/web/controllers/tasks/create.rb index 7e4b0dd..4e14182 100644 --- a/apps/web/controllers/tasks/create.rb +++ b/apps/web/controllers/tasks/create.rb @@ -1,11 +1,12 @@ +# frozen_string_literal: true + module Web module Controllers module Tasks class Create include Web::Action - def call(params) - end + def call(params); end end end end diff --git a/apps/web/controllers/tasks/index.rb b/apps/web/controllers/tasks/index.rb index 3b5f7f9..85c71d1 100644 --- a/apps/web/controllers/tasks/index.rb +++ b/apps/web/controllers/tasks/index.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Web module Controllers module Tasks @@ -6,7 +8,7 @@ class Index expose :tasks - def call(params) + def call(_params) @tasks = TaskRepository.new.all end end diff --git a/apps/web/controllers/tasks/new.rb b/apps/web/controllers/tasks/new.rb index 0efa8ea..a12b2de 100644 --- a/apps/web/controllers/tasks/new.rb +++ b/apps/web/controllers/tasks/new.rb @@ -1,11 +1,12 @@ +# frozen_string_literal: true + module Web module Controllers module Tasks class New include Web::Action - def call(params) - end + def call(params); end end end end diff --git a/apps/web/views/application_layout.rb b/apps/web/views/application_layout.rb index 51e14ba..ee7028e 100644 --- a/apps/web/views/application_layout.rb +++ b/apps/web/views/application_layout.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Web module Views class ApplicationLayout diff --git a/apps/web/views/base_view.rb b/apps/web/views/base_view.rb index fc3550b..d4b83ed 100644 --- a/apps/web/views/base_view.rb +++ b/apps/web/views/base_view.rb @@ -1,6 +1,8 @@ +# frozen_string_literal: true + module Web module Views - class BaseView + class BaseView include Web::View def edit_button(path) diff --git a/apps/web/views/home/index.rb b/apps/web/views/home/index.rb index 34344c8..8db8636 100644 --- a/apps/web/views/home/index.rb +++ b/apps/web/views/home/index.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Web module Views module Home diff --git a/apps/web/views/schemas/create.rb b/apps/web/views/schemas/create.rb index fcab55b..16ca968 100644 --- a/apps/web/views/schemas/create.rb +++ b/apps/web/views/schemas/create.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Web module Views module Schemas diff --git a/apps/web/views/schemas/index.rb b/apps/web/views/schemas/index.rb index 42e55f7..bafbdea 100644 --- a/apps/web/views/schemas/index.rb +++ b/apps/web/views/schemas/index.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Web module Views module Schemas diff --git a/apps/web/views/schemas/new.rb b/apps/web/views/schemas/new.rb index 9fbab4f..fd01478 100644 --- a/apps/web/views/schemas/new.rb +++ b/apps/web/views/schemas/new.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Web module Views module Schemas diff --git a/apps/web/views/sites/edit.rb b/apps/web/views/sites/edit.rb index e3803fa..745e5b1 100644 --- a/apps/web/views/sites/edit.rb +++ b/apps/web/views/sites/edit.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Web module Views module Sites diff --git a/apps/web/views/sites/index.rb b/apps/web/views/sites/index.rb index d725a44..2263f9c 100644 --- a/apps/web/views/sites/index.rb +++ b/apps/web/views/sites/index.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Web module Views module Sites diff --git a/apps/web/views/sites/new.rb b/apps/web/views/sites/new.rb index f5efd52..a691158 100644 --- a/apps/web/views/sites/new.rb +++ b/apps/web/views/sites/new.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Web module Views module Sites diff --git a/apps/web/views/sites/show.rb b/apps/web/views/sites/show.rb index 5e1253f..225d8ce 100644 --- a/apps/web/views/sites/show.rb +++ b/apps/web/views/sites/show.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Web module Views module Sites diff --git a/apps/web/views/tasks/create.rb b/apps/web/views/tasks/create.rb index 00b3a02..28089a6 100644 --- a/apps/web/views/tasks/create.rb +++ b/apps/web/views/tasks/create.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Web module Views module Tasks diff --git a/apps/web/views/tasks/index.rb b/apps/web/views/tasks/index.rb index 63b7412..9396492 100644 --- a/apps/web/views/tasks/index.rb +++ b/apps/web/views/tasks/index.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Web module Views module Tasks diff --git a/apps/web/views/tasks/new.rb b/apps/web/views/tasks/new.rb index 6ef7d95..fabebc1 100644 --- a/apps/web/views/tasks/new.rb +++ b/apps/web/views/tasks/new.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Web module Views module Tasks diff --git a/config.ru b/config.ru index f985808..78e7a0a 100644 --- a/config.ru +++ b/config.ru @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require './config/environment' run Hanami.app diff --git a/config/boot.rb b/config/boot.rb index 01636fd..4aadcd5 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,2 +1,4 @@ +# frozen_string_literal: true + require_relative './environment' Hanami.boot diff --git a/config/environment.rb b/config/environment.rb index c976404..f4c77ea 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'bundler/setup' require 'hanami/setup' require 'hanami/model' @@ -44,7 +46,8 @@ logger level: :info, formatter: :json, filter: [] mailer do - delivery :smtp, address: ENV.fetch('SMTP_HOST'), port: ENV.fetch('SMTP_PORT') + delivery \ + :smtp, address: ENV.fetch('SMTP_HOST'), port: ENV.fetch('SMTP_PORT') end end end diff --git a/config/initializers/inflectors.rb b/config/initializers/inflectors.rb index 0b464d1..ebbab7a 100644 --- a/config/initializers/inflectors.rb +++ b/config/initializers/inflectors.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'hanami/utils/inflector' Hanami::Utils::Inflector.inflections do diff --git a/db/migrations/20190625090047_create_sites.rb b/db/migrations/20190625090047_create_sites.rb index 28b95b4..ef6f8e1 100644 --- a/db/migrations/20190625090047_create_sites.rb +++ b/db/migrations/20190625090047_create_sites.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Hanami::Model.migration do change do create_table :sites do diff --git a/db/migrations/20190707143735_create_schemas.rb b/db/migrations/20190707143735_create_schemas.rb index 87986a0..f04b018 100644 --- a/db/migrations/20190707143735_create_schemas.rb +++ b/db/migrations/20190707143735_create_schemas.rb @@ -1,9 +1,11 @@ +# frozen_string_literal: true + Hanami::Model.migration do change do create_table :schemas do primary_key :id - column :definition, "jsonb", null: false + column :definition, 'jsonb', null: false column :created_at, DateTime, null: false column :updated_at, DateTime, null: false end diff --git a/db/migrations/20190707143813_create_scraping_tasks.rb b/db/migrations/20190707143813_create_scraping_tasks.rb index 3f5f339..12dc113 100644 --- a/db/migrations/20190707143813_create_scraping_tasks.rb +++ b/db/migrations/20190707143813_create_scraping_tasks.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Hanami::Model.migration do change do create_table :scraping_tasks do diff --git a/db/migrations/20191027111142_add_name_to_schema.rb b/db/migrations/20191027111142_add_name_to_schema.rb index 8f6d8b9..f86ab4b 100644 --- a/db/migrations/20191027111142_add_name_to_schema.rb +++ b/db/migrations/20191027111142_add_name_to_schema.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Hanami::Model.migration do change do alter_table :schemas do diff --git a/db/migrations/20191027122225_create_tasks.rb b/db/migrations/20191027122225_create_tasks.rb index 93d0d97..edc2ed1 100644 --- a/db/migrations/20191027122225_create_tasks.rb +++ b/db/migrations/20191027122225_create_tasks.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Hanami::Model.migration do change do create_table :tasks do @@ -7,8 +9,8 @@ foreign_key :site_id, :sites, on_delete: :restrict, null: false column :crawler, String, null: false - column :fields, "jsonb", null: false - column :crawler_options, "jsonb", null: false + column :fields, 'jsonb', null: false + column :crawler_options, 'jsonb', null: false column :created_at, DateTime, null: false column :updated_at, DateTime, null: false diff --git a/lib/omniscrapper_hq.rb b/lib/omniscrapper_hq.rb index eb4b8e9..9f04744 100644 --- a/lib/omniscrapper_hq.rb +++ b/lib/omniscrapper_hq.rb @@ -1,2 +1,4 @@ +# frozen_string_literal: true + module OmniscrapperHq end diff --git a/lib/omniscrapper_hq/domain/configuration/crawler.rb b/lib/omniscrapper_hq/domain/configuration/crawler.rb index 83628bc..aa7e0fc 100644 --- a/lib/omniscrapper_hq/domain/configuration/crawler.rb +++ b/lib/omniscrapper_hq/domain/configuration/crawler.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Domain module Configuration # Builds a list of required fields from scrapper metadata diff --git a/lib/omniscrapper_hq/domain/configuration/fields.rb b/lib/omniscrapper_hq/domain/configuration/fields.rb index 15ada27..8070fdf 100644 --- a/lib/omniscrapper_hq/domain/configuration/fields.rb +++ b/lib/omniscrapper_hq/domain/configuration/fields.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Domain module Configuration # Infers from schema a list of fields that should be returned by scrapper. @@ -9,7 +11,7 @@ def initialize(schema) end def list - @fields.map do |name, options| + @fields.map do |name, _options| { name: name, required: @required_fields.include?(name.to_s) diff --git a/lib/omniscrapper_hq/entities/schema.rb b/lib/omniscrapper_hq/entities/schema.rb index a407a5a..02659b5 100644 --- a/lib/omniscrapper_hq/entities/schema.rb +++ b/lib/omniscrapper_hq/entities/schema.rb @@ -1,2 +1,4 @@ +# frozen_string_literal: true + class Schema < Hanami::Entity end diff --git a/lib/omniscrapper_hq/entities/scraping_task.rb b/lib/omniscrapper_hq/entities/scraping_task.rb index 2d171d6..95727dd 100644 --- a/lib/omniscrapper_hq/entities/scraping_task.rb +++ b/lib/omniscrapper_hq/entities/scraping_task.rb @@ -1,2 +1,4 @@ +# frozen_string_literal: true + class ScrapingTask < Hanami::Entity end diff --git a/lib/omniscrapper_hq/entities/site.rb b/lib/omniscrapper_hq/entities/site.rb index fab3a45..5a0e61b 100644 --- a/lib/omniscrapper_hq/entities/site.rb +++ b/lib/omniscrapper_hq/entities/site.rb @@ -1,2 +1,4 @@ +# frozen_string_literal: true + class Site < Hanami::Entity end diff --git a/lib/omniscrapper_hq/entities/task.rb b/lib/omniscrapper_hq/entities/task.rb index 010f55a..c2d8cb0 100644 --- a/lib/omniscrapper_hq/entities/task.rb +++ b/lib/omniscrapper_hq/entities/task.rb @@ -1,2 +1,4 @@ +# frozen_string_literal: true + class Task < Hanami::Entity end diff --git a/lib/omniscrapper_hq/repositories/crawler_repository.rb b/lib/omniscrapper_hq/repositories/crawler_repository.rb index 84b645a..9e0b51b 100644 --- a/lib/omniscrapper_hq/repositories/crawler_repository.rb +++ b/lib/omniscrapper_hq/repositories/crawler_repository.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class CrawlerRepository def all data_source.all_names diff --git a/lib/omniscrapper_hq/repositories/schema_repository.rb b/lib/omniscrapper_hq/repositories/schema_repository.rb index 6b90d12..7997786 100644 --- a/lib/omniscrapper_hq/repositories/schema_repository.rb +++ b/lib/omniscrapper_hq/repositories/schema_repository.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class SchemaRepository < Hanami::Repository associations do has_many :scraping_tasks diff --git a/lib/omniscrapper_hq/repositories/scraping_task_repository.rb b/lib/omniscrapper_hq/repositories/scraping_task_repository.rb index 0736252..f7a5f6f 100644 --- a/lib/omniscrapper_hq/repositories/scraping_task_repository.rb +++ b/lib/omniscrapper_hq/repositories/scraping_task_repository.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class ScrapingTaskRepository < Hanami::Repository associations do belongs_to :schema diff --git a/lib/omniscrapper_hq/repositories/site_repository.rb b/lib/omniscrapper_hq/repositories/site_repository.rb index 89902d1..75a7f26 100644 --- a/lib/omniscrapper_hq/repositories/site_repository.rb +++ b/lib/omniscrapper_hq/repositories/site_repository.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class SiteRepository < Hanami::Repository associations do has_many :scraping_tasks diff --git a/lib/omniscrapper_hq/repositories/task_repository.rb b/lib/omniscrapper_hq/repositories/task_repository.rb index 1c3ed44..0c4346c 100644 --- a/lib/omniscrapper_hq/repositories/task_repository.rb +++ b/lib/omniscrapper_hq/repositories/task_repository.rb @@ -1,2 +1,4 @@ +# frozen_string_literal: true + class TaskRepository < Hanami::Repository end diff --git a/lib/omniscrapper_hq/workers/sample.rb b/lib/omniscrapper_hq/workers/sample.rb index c7eb12f..36c0bc0 100644 --- a/lib/omniscrapper_hq/workers/sample.rb +++ b/lib/omniscrapper_hq/workers/sample.rb @@ -1,17 +1,15 @@ +# frozen_string_literal: true + require 'sidekiq' module Runners class Sample include Sidekiq::Worker - def perform - - end + def perform; end private - def scrapper_schema - - end + def scrapper_schema; end end end diff --git a/spec/features_helper.rb b/spec/features_helper.rb index d35c1b2..367bef1 100644 --- a/spec/features_helper.rb +++ b/spec/features_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Require this file for feature tests require_relative './spec_helper' diff --git a/spec/omniscrapper_hq/entities/schema_spec.rb b/spec/omniscrapper_hq/entities/schema_spec.rb index 261e678..a01ba15 100644 --- a/spec/omniscrapper_hq/entities/schema_spec.rb +++ b/spec/omniscrapper_hq/entities/schema_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.describe Schema, type: :entity do # place your tests here end diff --git a/spec/omniscrapper_hq/entities/scraping_task_spec.rb b/spec/omniscrapper_hq/entities/scraping_task_spec.rb index be0814b..13e23cb 100644 --- a/spec/omniscrapper_hq/entities/scraping_task_spec.rb +++ b/spec/omniscrapper_hq/entities/scraping_task_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.describe ScrapingTask, type: :entity do # place your tests here end diff --git a/spec/omniscrapper_hq/entities/site_spec.rb b/spec/omniscrapper_hq/entities/site_spec.rb index c2461bc..b610535 100644 --- a/spec/omniscrapper_hq/entities/site_spec.rb +++ b/spec/omniscrapper_hq/entities/site_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.describe Site, type: :entity do it 'can be initialized' do site = Fabricate.build(:site, name: 'Hello') diff --git a/spec/omniscrapper_hq/entities/task_spec.rb b/spec/omniscrapper_hq/entities/task_spec.rb index a554423..961a14e 100644 --- a/spec/omniscrapper_hq/entities/task_spec.rb +++ b/spec/omniscrapper_hq/entities/task_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.describe Task, type: :entity do # place your tests here end diff --git a/spec/omniscrapper_hq/repositories/schema_repository_spec.rb b/spec/omniscrapper_hq/repositories/schema_repository_spec.rb index f7899d0..206b89b 100644 --- a/spec/omniscrapper_hq/repositories/schema_repository_spec.rb +++ b/spec/omniscrapper_hq/repositories/schema_repository_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.describe SchemaRepository, type: :repository do let(:repository) { described_class.new } let(:schema) { Fabricate(:schema) } diff --git a/spec/omniscrapper_hq/repositories/scraping_task_repository_spec.rb b/spec/omniscrapper_hq/repositories/scraping_task_repository_spec.rb index 8c70d22..551fa20 100644 --- a/spec/omniscrapper_hq/repositories/scraping_task_repository_spec.rb +++ b/spec/omniscrapper_hq/repositories/scraping_task_repository_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.describe ScrapingTaskRepository, type: :repository do let(:repository) { described_class.new } end diff --git a/spec/omniscrapper_hq/repositories/site_repository_spec.rb b/spec/omniscrapper_hq/repositories/site_repository_spec.rb index f01a7e6..c67fa0f 100644 --- a/spec/omniscrapper_hq/repositories/site_repository_spec.rb +++ b/spec/omniscrapper_hq/repositories/site_repository_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.describe SiteRepository, type: :repository do let(:repository) { described_class.new } let(:site) { Fabricate(:site) } diff --git a/spec/omniscrapper_hq/repositories/task_repository_spec.rb b/spec/omniscrapper_hq/repositories/task_repository_spec.rb index 75965a5..d694265 100644 --- a/spec/omniscrapper_hq/repositories/task_repository_spec.rb +++ b/spec/omniscrapper_hq/repositories/task_repository_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.describe TaskRepository, type: :repository do # place your tests here end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 8891051..34c373d 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # Require this file for unit tests ENV['HANAMI_ENV'] ||= 'test' @@ -6,7 +8,6 @@ Hanami::Utils.require!("#{__dir__}/support") RSpec.configure do |config| - config.expect_with :rspec do |expectations| expectations.include_chain_clauses_in_custom_matcher_descriptions = true end diff --git a/spec/support/capybara.rb b/spec/support/capybara.rb index f94a31f..2e8e61b 100644 --- a/spec/support/capybara.rb +++ b/spec/support/capybara.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module RSpec module FeatureExampleGroup def self.included(group) diff --git a/spec/support/fabricators/schema_fabricator.rb b/spec/support/fabricators/schema_fabricator.rb index 64a9ca8..7dea692 100644 --- a/spec/support/fabricators/schema_fabricator.rb +++ b/spec/support/fabricators/schema_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:schema) do - definition { { type: "object", properties: { a: { type: "integer"} } } } + definition { { type: 'object', properties: { a: { type: 'integer' } } } } end diff --git a/spec/support/fabricators/scraping_task_fabricator.rb b/spec/support/fabricators/scraping_task_fabricator.rb index 0856a5f..6b53ebf 100644 --- a/spec/support/fabricators/scraping_task_fabricator.rb +++ b/spec/support/fabricators/scraping_task_fabricator.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + Fabricator(:scraping_task) do name { 'task' } schema_id { Fabricate(:schema).id } diff --git a/spec/support/fabricators/site_fabricator.rb b/spec/support/fabricators/site_fabricator.rb index 908a9cb..bec52d1 100644 --- a/spec/support/fabricators/site_fabricator.rb +++ b/spec/support/fabricators/site_fabricator.rb @@ -1,4 +1,6 @@ +# frozen_string_literal: true + Fabricator(:site) do - name { "camelot" } - url { "test" } -end \ No newline at end of file + name { 'camelot' } + url { 'test' } +end diff --git a/spec/web/controllers/home/index_spec.rb b/spec/web/controllers/home/index_spec.rb index 20bbfbc..ab80ce8 100644 --- a/spec/web/controllers/home/index_spec.rb +++ b/spec/web/controllers/home/index_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.describe Web::Controllers::Home::Index, type: :action do let(:action) { described_class.new } let(:params) { Hash[] } diff --git a/spec/web/controllers/schemas/create_spec.rb b/spec/web/controllers/schemas/create_spec.rb index 293ab0c..72b5f14 100644 --- a/spec/web/controllers/schemas/create_spec.rb +++ b/spec/web/controllers/schemas/create_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.describe Web::Controllers::Schemas::Create, type: :action do let(:action) { described_class.new } let(:params) { Hash[] } diff --git a/spec/web/controllers/schemas/index_spec.rb b/spec/web/controllers/schemas/index_spec.rb index 10c404d..f482aa3 100644 --- a/spec/web/controllers/schemas/index_spec.rb +++ b/spec/web/controllers/schemas/index_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.describe Web::Controllers::Schemas::Index, type: :action do let(:action) { described_class.new } let(:params) { Hash[] } diff --git a/spec/web/controllers/schemas/new_spec.rb b/spec/web/controllers/schemas/new_spec.rb index 328036c..222d93c 100644 --- a/spec/web/controllers/schemas/new_spec.rb +++ b/spec/web/controllers/schemas/new_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.describe Web::Controllers::Schemas::New, type: :action do let(:action) { described_class.new } let(:params) { Hash[] } diff --git a/spec/web/controllers/sites/create_spec.rb b/spec/web/controllers/sites/create_spec.rb index b84919f..0f3ea04 100644 --- a/spec/web/controllers/sites/create_spec.rb +++ b/spec/web/controllers/sites/create_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.describe Web::Controllers::Sites::Create, type: :action do let(:action) { described_class.new } let(:repository) { SiteRepository.new } diff --git a/spec/web/controllers/sites/destroy_spec.rb b/spec/web/controllers/sites/destroy_spec.rb index f1fa789..82e63f9 100644 --- a/spec/web/controllers/sites/destroy_spec.rb +++ b/spec/web/controllers/sites/destroy_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.describe Web::Controllers::Sites::Destroy, type: :action do let(:action) { described_class.new } let!(:site) { Fabricate(:site) } diff --git a/spec/web/controllers/sites/edit_spec.rb b/spec/web/controllers/sites/edit_spec.rb index 9d672c2..e334c32 100644 --- a/spec/web/controllers/sites/edit_spec.rb +++ b/spec/web/controllers/sites/edit_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.describe Web::Controllers::Sites::Edit, type: :action do let(:action) { described_class.new } let(:params) { Hash[] } diff --git a/spec/web/controllers/sites/index_spec.rb b/spec/web/controllers/sites/index_spec.rb index 9adadb2..a31dff1 100644 --- a/spec/web/controllers/sites/index_spec.rb +++ b/spec/web/controllers/sites/index_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.describe Web::Controllers::Sites::Index, type: :action do let(:action) { described_class.new } let(:params) { Hash[] } diff --git a/spec/web/controllers/sites/new_spec.rb b/spec/web/controllers/sites/new_spec.rb index 117cc38..649e4de 100644 --- a/spec/web/controllers/sites/new_spec.rb +++ b/spec/web/controllers/sites/new_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.describe Web::Controllers::Sites::New, type: :action do let(:action) { described_class.new } let(:params) { Hash[] } diff --git a/spec/web/controllers/sites/show_spec.rb b/spec/web/controllers/sites/show_spec.rb index 0ddb2d5..342685b 100644 --- a/spec/web/controllers/sites/show_spec.rb +++ b/spec/web/controllers/sites/show_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.describe Web::Controllers::Sites::Show, type: :action do let(:action) { described_class.new } let(:params) { Hash[] } diff --git a/spec/web/controllers/sites/update_spec.rb b/spec/web/controllers/sites/update_spec.rb index 8091731..364e7d9 100644 --- a/spec/web/controllers/sites/update_spec.rb +++ b/spec/web/controllers/sites/update_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.describe Web::Controllers::Sites::Update, type: :action do let(:action) { described_class.new } let(:repository) { SiteRepository.new } @@ -8,7 +10,9 @@ end context 'with valid params' do - let(:attributes) { { id: site.id, site: Fabricate.attributes_for(:site, name: 'hello') } } + let(:attributes) do + { id: site.id, site: Fabricate.attributes_for(:site, name: 'hello') } + end it 'is redirects' do response = action.call(attributes) diff --git a/spec/web/controllers/tasks/create_spec.rb b/spec/web/controllers/tasks/create_spec.rb index 20352e8..a842736 100644 --- a/spec/web/controllers/tasks/create_spec.rb +++ b/spec/web/controllers/tasks/create_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.describe Web::Controllers::Tasks::Create, type: :action do let(:action) { described_class.new } let(:params) { Hash[] } diff --git a/spec/web/controllers/tasks/index_spec.rb b/spec/web/controllers/tasks/index_spec.rb index 92ead93..efc6566 100644 --- a/spec/web/controllers/tasks/index_spec.rb +++ b/spec/web/controllers/tasks/index_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.describe Web::Controllers::Tasks::Index, type: :action do let(:action) { described_class.new } let(:params) { Hash[] } diff --git a/spec/web/controllers/tasks/new_spec.rb b/spec/web/controllers/tasks/new_spec.rb index 9795b57..7ba7e77 100644 --- a/spec/web/controllers/tasks/new_spec.rb +++ b/spec/web/controllers/tasks/new_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + RSpec.describe Web::Controllers::Tasks::New, type: :action do let(:action) { described_class.new } let(:params) { Hash[] } diff --git a/spec/web/views/home/index_spec.rb b/spec/web/views/home/index_spec.rb index abe9008..3b81b5d 100644 --- a/spec/web/views/home/index_spec.rb +++ b/spec/web/views/home/index_spec.rb @@ -1,6 +1,9 @@ +# frozen_string_literal: true + RSpec.describe Web::Views::Home::Index, type: :view do let(:exposures) { Hash[format: :html] } - let(:template) { Hanami::View::Template.new('apps/web/templates/home/index.html.haml') } + let(:template) \ + { Hanami::View::Template.new('apps/web/templates/home/index.html.haml') } let(:view) { described_class.new(template, exposures) } let(:rendered) { view.render } diff --git a/spec/web/views/schemas/create_spec.rb b/spec/web/views/schemas/create_spec.rb index fdc46c2..9e164a4 100644 --- a/spec/web/views/schemas/create_spec.rb +++ b/spec/web/views/schemas/create_spec.rb @@ -1,6 +1,10 @@ +# frozen_string_literal: true + RSpec.describe Web::Views::Schemas::Create, type: :view do let(:exposures) { Hash[format: :html] } - let(:template) { Hanami::View::Template.new('apps/web/templates/schemas/create.html.erb') } + let(:template) do + Hanami::View::Template.new('apps/web/templates/schemas/create.html.erb') + end let(:view) { described_class.new(template, exposures) } let(:rendered) { view.render } diff --git a/spec/web/views/schemas/index_spec.rb b/spec/web/views/schemas/index_spec.rb index d48aa9a..3bbb76d 100644 --- a/spec/web/views/schemas/index_spec.rb +++ b/spec/web/views/schemas/index_spec.rb @@ -1,6 +1,10 @@ +# frozen_string_literal: true + RSpec.describe Web::Views::Schemas::Index, type: :view do let(:exposures) { Hash[format: :html] } - let(:template) { Hanami::View::Template.new('apps/web/templates/schemas/index.html.erb') } + let(:template) do + Hanami::View::Template.new('apps/web/templates/schemas/index.html.erb') + end let(:view) { described_class.new(template, exposures) } let(:rendered) { view.render } diff --git a/spec/web/views/schemas/new_spec.rb b/spec/web/views/schemas/new_spec.rb index 012d1c7..3735579 100644 --- a/spec/web/views/schemas/new_spec.rb +++ b/spec/web/views/schemas/new_spec.rb @@ -1,6 +1,10 @@ +# frozen_string_literal: true + RSpec.describe Web::Views::Schemas::New, type: :view do let(:exposures) { Hash[format: :html] } - let(:template) { Hanami::View::Template.new('apps/web/templates/schemas/new.html.erb') } + let(:template) do + Hanami::View::Template.new('apps/web/templates/schemas/new.html.erb') + end let(:view) { described_class.new(template, exposures) } let(:rendered) { view.render } diff --git a/spec/web/views/sites/edit_spec.rb b/spec/web/views/sites/edit_spec.rb index 06be8ab..c4a21d8 100644 --- a/spec/web/views/sites/edit_spec.rb +++ b/spec/web/views/sites/edit_spec.rb @@ -1,6 +1,10 @@ +# frozen_string_literal: true + RSpec.describe Web::Views::Sites::Edit, type: :view do let(:exposures) { Hash[format: :html] } - let(:template) { Hanami::View::Template.new('apps/web/templates/sites/edit.html.haml') } + let(:template) do + Hanami::View::Template.new('apps/web/templates/sites/edit.html.haml') + end let(:view) { described_class.new(template, exposures) } let(:rendered) { view.render } diff --git a/spec/web/views/sites/index_spec.rb b/spec/web/views/sites/index_spec.rb index 1356d53..b4433a4 100644 --- a/spec/web/views/sites/index_spec.rb +++ b/spec/web/views/sites/index_spec.rb @@ -1,6 +1,10 @@ +# frozen_string_literal: true + RSpec.describe Web::Views::Sites::Index, type: :view do let(:exposures) { Hash[format: :html] } - let(:template) { Hanami::View::Template.new('apps/web/templates/sites/index.html.haml') } + let(:template) do + Hanami::View::Template.new('apps/web/templates/sites/index.html.haml') + end let(:view) { described_class.new(template, exposures) } let(:rendered) { view.render } diff --git a/spec/web/views/sites/new_spec.rb b/spec/web/views/sites/new_spec.rb index 6ec5409..1853986 100644 --- a/spec/web/views/sites/new_spec.rb +++ b/spec/web/views/sites/new_spec.rb @@ -1,6 +1,10 @@ +# frozen_string_literal: true + RSpec.describe Web::Views::Sites::New, type: :view do let(:exposures) { Hash[format: :html] } - let(:template) { Hanami::View::Template.new('apps/web/templates/sites/new.html.haml') } + let(:template) do + Hanami::View::Template.new('apps/web/templates/sites/new.html.haml') + end let(:view) { described_class.new(template, exposures) } let(:rendered) { view.render } diff --git a/spec/web/views/sites/show_spec.rb b/spec/web/views/sites/show_spec.rb index e257d30..aca0a94 100644 --- a/spec/web/views/sites/show_spec.rb +++ b/spec/web/views/sites/show_spec.rb @@ -1,6 +1,10 @@ +# frozen_string_literal: true + RSpec.describe Web::Views::Sites::Show, type: :view do let(:exposures) { Hash[format: :html] } - let(:template) { Hanami::View::Template.new('apps/web/templates/sites/show.html.haml') } + let(:template) do + Hanami::View::Template.new('apps/web/templates/sites/show.html.haml') + end let(:view) { described_class.new(template, exposures) } let(:rendered) { view.render } diff --git a/spec/web/views/tasks/create_spec.rb b/spec/web/views/tasks/create_spec.rb index 7800492..d4e0336 100644 --- a/spec/web/views/tasks/create_spec.rb +++ b/spec/web/views/tasks/create_spec.rb @@ -1,6 +1,10 @@ +# frozen_string_literal: true + RSpec.describe Web::Views::Tasks::Create, type: :view do let(:exposures) { Hash[format: :html] } - let(:template) { Hanami::View::Template.new('apps/web/templates/tasks/create.html.erb') } + let(:template) do + Hanami::View::Template.new('apps/web/templates/tasks/create.html.erb') + end let(:view) { described_class.new(template, exposures) } let(:rendered) { view.render } diff --git a/spec/web/views/tasks/index_spec.rb b/spec/web/views/tasks/index_spec.rb index 6ae6ef2..53b6169 100644 --- a/spec/web/views/tasks/index_spec.rb +++ b/spec/web/views/tasks/index_spec.rb @@ -1,6 +1,10 @@ +# frozen_string_literal: true + RSpec.describe Web::Views::Tasks::Index, type: :view do let(:exposures) { Hash[format: :html] } - let(:template) { Hanami::View::Template.new('apps/web/templates/tasks/index.html.erb') } + let(:template) do + Hanami::View::Template.new('apps/web/templates/tasks/index.html.erb') + end let(:view) { described_class.new(template, exposures) } let(:rendered) { view.render } diff --git a/spec/web/views/tasks/new_spec.rb b/spec/web/views/tasks/new_spec.rb index 5bd4e14..68501d2 100644 --- a/spec/web/views/tasks/new_spec.rb +++ b/spec/web/views/tasks/new_spec.rb @@ -1,6 +1,10 @@ +# frozen_string_literal: true + RSpec.describe Web::Views::Tasks::New, type: :view do let(:exposures) { Hash[format: :html] } - let(:template) { Hanami::View::Template.new('apps/web/templates/tasks/new.html.erb') } + let(:template) do + Hanami::View::Template.new('apps/web/templates/tasks/new.html.erb') + end let(:view) { described_class.new(template, exposures) } let(:rendered) { view.render }