From 4e1b6f2071c1884dacc33985440ac08234f7c42f Mon Sep 17 00:00:00 2001 From: POPPIN-FUMI Date: Thu, 21 Oct 2021 16:00:49 +0200 Subject: [PATCH] fix test --- .gitignore | 1 - .gitmodules | 3 ++ Gemfile.lock | 10 ++-- README.md | 6 +++ Steepfile | 28 +++++++++++ db/migrate/20210921194730_create_users.rb | 30 ++++++++++++ db/schema.rb | 46 +++++++++++++++++++ spec/api/generate/application_spec.rb | 27 ----------- spec/api/generate/manager_spec.rb | 21 --------- spec/api/generate/model_spec.rb | 20 -------- spec/api/generate/rspec_model_spec.rb | 21 --------- spec/cli/create_spec.rb | 1 + spec/cli/db_spec.rb | 8 ---- spec/{api => cli}/generate/connection_spec.rb | 2 + spec/{api => cli}/generate/edge_spec.rb | 2 + spec/{api => cli}/generate/mutation_spec.rb | 11 +++-- spec/{api => cli}/generate/policy_spec.rb | 2 + spec/{api => cli}/generate/query_spec.rb | 2 + spec/{api => cli}/generate/resolver_spec.rb | 2 + .../generate/rspec_factory_spec.rb | 2 + .../generate/rspec_mutation_spec.rb | 2 + .../generate/rspec_policy_spec.rb | 2 + .../{api => cli}/generate/rspec_query_spec.rb | 2 + .../generate/rspec_resolver_spec.rb | 2 + spec/souls_spec.rb | 2 +- vendor/rbs/gem_rbs_collection | 1 + 26 files changed, 148 insertions(+), 108 deletions(-) create mode 100644 .gitmodules create mode 100644 db/migrate/20210921194730_create_users.rb create mode 100644 db/schema.rb delete mode 100644 spec/api/generate/application_spec.rb delete mode 100644 spec/api/generate/manager_spec.rb delete mode 100644 spec/api/generate/model_spec.rb delete mode 100644 spec/api/generate/rspec_model_spec.rb delete mode 100644 spec/cli/db_spec.rb rename spec/{api => cli}/generate/connection_spec.rb (88%) rename spec/{api => cli}/generate/edge_spec.rb (87%) rename spec/{api => cli}/generate/mutation_spec.rb (60%) rename spec/{api => cli}/generate/policy_spec.rb (87%) rename spec/{api => cli}/generate/query_spec.rb (87%) rename spec/{api => cli}/generate/resolver_spec.rb (88%) rename spec/{api => cli}/generate/rspec_factory_spec.rb (87%) rename spec/{api => cli}/generate/rspec_mutation_spec.rb (87%) rename spec/{api => cli}/generate/rspec_policy_spec.rb (87%) rename spec/{api => cli}/generate/rspec_query_spec.rb (87%) rename spec/{api => cli}/generate/rspec_resolver_spec.rb (87%) create mode 160000 vendor/rbs/gem_rbs_collection diff --git a/.gitignore b/.gitignore index eacc227b..24eae8eb 100644 --- a/.gitignore +++ b/.gitignore @@ -13,5 +13,4 @@ .env .irb_history /app/ -/db/ /vendor/rbs/gem_rbs_collection/ \ No newline at end of file diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..22dc2878 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "vendor/rbs/gem_rbs_collection"] + path = vendor/rbs/gem_rbs_collection + url = https://github.com/ruby/gem_rbs_collection.git diff --git a/Gemfile.lock b/Gemfile.lock index 0e7222f7..d2b5fc98 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -28,7 +28,7 @@ GEM public_suffix (>= 2.0.2, < 5.0) ast (2.4.2) backport (1.2.0) - benchmark (0.1.1) + benchmark (0.2.0) concurrent-ruby (1.1.9) diff-lcs (1.4.4) e2mmap (0.1.0) @@ -74,12 +74,12 @@ GEM gapic-common (>= 0.7, < 2.a) google-cloud-errors (~> 1.0) grpc-google-iam-v1 (>= 0.6.10, < 2.a) - google-protobuf (3.18.1-x86_64-linux) + google-protobuf (3.19.0-x86_64-linux) googleapis-common-protos (1.3.12) google-protobuf (~> 3.14) googleapis-common-protos-types (~> 1.2) grpc (~> 1.27) - googleapis-common-protos-types (1.2.0) + googleapis-common-protos-types (1.3.0) google-protobuf (~> 3.14) googleauth (1.0.0) faraday (>= 0.17.3, < 2.0) @@ -124,7 +124,7 @@ GEM tty-color (~> 0.5) pg (1.2.3) public_suffix (4.0.6) - racc (1.5.2) + racc (1.6.0) rack (2.2.3) rack-protection (2.1.0) rack @@ -222,7 +222,7 @@ GEM unicode-display_width (>= 1.1) wisper (2.0.1) yard (0.9.26) - zeitwerk (2.4.2) + zeitwerk (2.5.1) PLATFORMS x86_64-linux diff --git a/README.md b/README.md index 6678a7ca..22011f47 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,12 @@ Check your GraphQL PlayGround After checking out the repo, run `bin/setup` to install dependencies. Then, run `souls t` to run the tests. You can also run `souls c` for an interactive prompt that will allow you to experiment. +You need to add submodule + +```bash +git submodule add -f https://github.com/ruby/gem_rbs_collection.git vendor/rbs/gem_rbs_collection +``` + To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org/gems/souls). ## Contributing diff --git a/Steepfile b/Steepfile index 21f8e109..b70e68cc 100644 --- a/Steepfile +++ b/Steepfile @@ -24,4 +24,32 @@ target :app do # check 'app' # check "lib/souls/api/generate/edge.rb" + check "apps/scraper/app" + check "apps/scraper/db/seeds.rb" + check "apps/scraper/constants" + check "apps/scraper/app.rb" + check "apps/scraper/app" + check "apps/scraper/db/seeds.rb" + check "apps/scraper/constants" + check "apps/scraper/app.rb" + check "apps/scraper/app" + check "apps/scraper/db/seeds.rb" + check "apps/scraper/constants" + check "apps/scraper/app.rb" + check "apps/scraper/app" + check "apps/scraper/db/seeds.rb" + check "apps/scraper/constants" + check "apps/scraper/app.rb" + check "apps/scraper/app" + check "apps/scraper/db/seeds.rb" + check "apps/scraper/constants" + check "apps/scraper/app.rb" + check "apps/scraper/app" + check "apps/scraper/db/seeds.rb" + check "apps/scraper/constants" + check "apps/scraper/app.rb" + check "apps/scraper/app" + check "apps/scraper/db/seeds.rb" + check "apps/scraper/constants" + check "apps/scraper/app.rb" end diff --git a/db/migrate/20210921194730_create_users.rb b/db/migrate/20210921194730_create_users.rb new file mode 100644 index 00000000..eab3a6b5 --- /dev/null +++ b/db/migrate/20210921194730_create_users.rb @@ -0,0 +1,30 @@ +class CreateUsers < ActiveRecord::Migration[6.1] + def change + create_table :users do |t| + t.string :uid, null: false, unique: true + t.string :username, null: false, default: "" + t.string :screen_name, null: false, default: "" + t.string :last_name, null: false, default: "" + t.string :first_name, null: false, default: "" + t.string :last_name_kanji, null: false, default: "" + t.string :first_name_kanji, null: false, default: "" + t.string :last_name_kana, null: false, default: "" + t.string :first_name_kana, null: false, default: "" + t.string :email, null: false, unique: true + t.string :tel, null: false, default: "" + t.string :icon_url, null: false, default: "" + t.string :birthday, null: false, default: "" + t.string :gender, null: false, default: "" + t.string :lang, null: false, default: "ja" + t.string :category, null: false, default: "user" + t.integer :roles_mask, null: false, default: 1 + t.boolean :is_deleted, null: false, default: false + t.timestamps + end + add_index :users, :uid + add_index :users, :screen_name + add_index :users, :email, unique: true + add_index :users, :username + add_index :users, :is_deleted + end +end \ No newline at end of file diff --git a/db/schema.rb b/db/schema.rb new file mode 100644 index 00000000..7b380d2a --- /dev/null +++ b/db/schema.rb @@ -0,0 +1,46 @@ +# 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. +# +# This file is the source Rails uses to define your schema when running `bin/rails +# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to +# be faster and is potentially less error prone than running all of your +# migrations from scratch. Old migrations may fail to apply correctly if those +# migrations use external dependencies or application code. +# +# It's strongly recommended that you check this file into your version control system. + +ActiveRecord::Schema.define(version: 2021_08_23_090158) do + + # These are extensions that must be enabled in order to support this database + enable_extension "plpgsql" + + create_table "users", force: :cascade do |t| + t.string "uid", null: false + t.string "username", default: "", null: false + t.string "screen_name", default: "", null: false + t.string "last_name", default: "", null: false + t.string "first_name", default: "", null: false + t.string "last_name_kanji", default: "", null: false + t.string "first_name_kanji", default: "", null: false + t.string "last_name_kana", default: "", null: false + t.string "first_name_kana", default: "", null: false + t.string "email", null: false + t.string "tel", default: "", null: false + t.string "icon_url", default: "", null: false + t.string "birthday", default: "", null: false + t.string "gender", default: "", null: false + t.string "lang", default: "ja", null: false + t.string "category", default: "user", null: false + t.integer "roles_mask", default: 1, null: false + t.boolean "is_deleted", default: false, null: false + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + t.index ["email"], name: "index_users_on_email", unique: true + t.index ["is_deleted"], name: "index_users_on_is_deleted" + t.index ["screen_name"], name: "index_users_on_screen_name" + t.index ["uid"], name: "index_users_on_uid" + t.index ["username"], name: "index_users_on_username" + end + +end diff --git a/spec/api/generate/application_spec.rb b/spec/api/generate/application_spec.rb deleted file mode 100644 index 7fed4b03..00000000 --- a/spec/api/generate/application_spec.rb +++ /dev/null @@ -1,27 +0,0 @@ -RSpec.describe(Souls::Generate) do - describe "Generate Scaffold" do - def clear_crud_files - file_paths = [ - "./app", - "./spec/factories", - "./spec/models", - "./spec/mutations", - "./spec/queries", - "./spec/resolvers", - "./spec/policies" - ] - file_paths.each { |path| FileUtils.rm_rf(path) if Dir.exist?(path) } - end - it "creates CRUD files from schema.rb" do - a1 = Souls::Generate.new.invoke(:scaffold, ["user"], {}) - expect(a1).to(eq(true)) - clear_crud_files - end - - it "creates All CRUD files from schema.rb" do - a1 = Souls::Generate.new.invoke(:scaffold_all, [], {}) - expect(a1).to(eq(true)) - clear_crud_files - end - end -end \ No newline at end of file diff --git a/spec/api/generate/manager_spec.rb b/spec/api/generate/manager_spec.rb deleted file mode 100644 index cfe58097..00000000 --- a/spec/api/generate/manager_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -RSpec.describe(Souls::Generate) do - describe "Generate Manager" do - let(:class_name) { "user" } - let(:file_name) { "user_login" } - - before do - file_dir = "./app/graphql/mutations/managers/#{class_name}_manager/" - FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir) - file_path = "#{file_dir}#{file_name.singularize}.rb" - FileUtils.rm(file_path) if File.exist?(file_path) - end - - it "creates manager file" do - file_dir = "./app/graphql/mutations/managers/#{class_name}_manager/" - file_path = "#{file_dir}#{file_name.singularize}.rb" - a1 = Souls::Generate.new.invoke(:manager, ["user"], {mutation: "user_login"}) - expect(a1).to(eq(file_path)) - FileUtils.rm_rf(file_dir) - end - end -end \ No newline at end of file diff --git a/spec/api/generate/model_spec.rb b/spec/api/generate/model_spec.rb deleted file mode 100644 index ba518d7d..00000000 --- a/spec/api/generate/model_spec.rb +++ /dev/null @@ -1,20 +0,0 @@ -RSpec.describe(Souls::Generate) do - describe "Generate Model" do - let(:class_name) { "user" } - - before do - file_dir = "./app/models/" - FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir) - file_path = "#{file_dir}#{class_name.singularize}.rb" - FileUtils.rm(file_path) if File.exist?(file_path) - end - - it "creates model.rb file" do - file_dir = "./app/models/" - file_path = "./app/models/#{class_name.singularize}.rb" - a1 = Souls::Generate.new.model(class_name) - expect(a1).to(eq(file_path)) - FileUtils.rm_rf(file_dir) - end - end -end \ No newline at end of file diff --git a/spec/api/generate/rspec_model_spec.rb b/spec/api/generate/rspec_model_spec.rb deleted file mode 100644 index 35d26c5d..00000000 --- a/spec/api/generate/rspec_model_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -RSpec.describe(Souls::Generate) do - describe "Generate Rspec Model" do - let(:class_name) { "user" } - let(:file_name) { "user_spec" } - - before do - file_dir = "./spec/models/" - FileUtils.mkdir_p(file_dir) unless Dir.exist?(file_dir) - file_path = "#{file_dir}#{file_name}.rb" - FileUtils.rm(file_path) if File.exist?(file_path) - end - - it "creates model file" do - file_dir = "./spec/models/" - file_path = "#{file_dir}#{file_name}.rb" - a1 = Souls::Generate.new.invoke(:rspec_model, ["user"], {}) - expect(a1).to(eq(file_path)) - FileUtils.rm_rf(file_dir) - end - end -end \ No newline at end of file diff --git a/spec/cli/create_spec.rb b/spec/cli/create_spec.rb index 7be3dfcd..6c0b5d9b 100644 --- a/spec/cli/create_spec.rb +++ b/spec/cli/create_spec.rb @@ -12,6 +12,7 @@ FileUtils.mv "tmp/souls-api.rb", "apps/api/#{mother_conf}" FileUtils.mv "tmp/Procfile.dev", "Procfile.dev" FileUtils.rm_rf "apps/scraper" + FileUtils.rm_rf "sig/scraper" FileUtils.rm_rf ".github/workflows/scraper.yml" end end diff --git a/spec/cli/db_spec.rb b/spec/cli/db_spec.rb deleted file mode 100644 index cb8b0a4e..00000000 --- a/spec/cli/db_spec.rb +++ /dev/null @@ -1,8 +0,0 @@ -RSpec.describe(Souls::CLI) do - describe "souls db:$METHOD command" do - it "souls db:migrate" do - a1 = Souls::CLI.new.invoke(:migrate, [], {}) - expect(a1).to(eq(true)) - end - end -end \ No newline at end of file diff --git a/spec/api/generate/connection_spec.rb b/spec/cli/generate/connection_spec.rb similarity index 88% rename from spec/api/generate/connection_spec.rb rename to spec/cli/generate/connection_spec.rb index 1933cbff..319a2a4b 100644 --- a/spec/api/generate/connection_spec.rb +++ b/spec/cli/generate/connection_spec.rb @@ -15,6 +15,8 @@ a1 = Souls::Generate.new.connection(class_name) expect(a1).to(eq(file_path)) FileUtils.rm_rf(file_dir) + rescue StandardError => error + FileUtils.rm(file_path) if File.exist?(file_path) end end end \ No newline at end of file diff --git a/spec/api/generate/edge_spec.rb b/spec/cli/generate/edge_spec.rb similarity index 87% rename from spec/api/generate/edge_spec.rb rename to spec/cli/generate/edge_spec.rb index fcf73d40..2147ee93 100644 --- a/spec/api/generate/edge_spec.rb +++ b/spec/cli/generate/edge_spec.rb @@ -15,6 +15,8 @@ a1 = Souls::Generate.new.edge(class_name) expect(a1).to(eq(file_path)) FileUtils.rm_rf(file_dir) + rescue StandardError => error + FileUtils.rm(file_path) if File.exist?(file_path) end end end \ No newline at end of file diff --git a/spec/api/generate/mutation_spec.rb b/spec/cli/generate/mutation_spec.rb similarity index 60% rename from spec/api/generate/mutation_spec.rb rename to spec/cli/generate/mutation_spec.rb index e7959f71..e996c52c 100644 --- a/spec/api/generate/mutation_spec.rb +++ b/spec/cli/generate/mutation_spec.rb @@ -1,5 +1,5 @@ RSpec.describe(Souls::Generate) do - describe "Generate Create Mutation" do + describe "Generate Mutation" do let(:class_name) { "user" } before do @@ -9,12 +9,15 @@ FileUtils.rm(file_path) if File.exist?(file_path) end - it "create_mutation" do + it "destroy delete mutation" do file_dir = "./app/graphql/mutations/base/#{class_name}/" - file_path = "#{file_dir}create_#{class_name.singularize}.rb" + file_path = "#{file_dir}destroy_delete_#{class_name.singularize}.rb" a1 = Souls::Generate.new.mutation(class_name) expect(a1).to(eq(file_path)) - FileUtils.rm_rf("./app/graphql/mutations") + rm_path = "./apps/api/app/graphql/mutations/base/#{class_name}/" + FileUtils.rm_rf(rm_path) + rescue StandardError => error + FileUtils.rm_rf(rm_path) if Dir.exist?(rm_path) end end end \ No newline at end of file diff --git a/spec/api/generate/policy_spec.rb b/spec/cli/generate/policy_spec.rb similarity index 87% rename from spec/api/generate/policy_spec.rb rename to spec/cli/generate/policy_spec.rb index 8d89354d..28b616bc 100644 --- a/spec/api/generate/policy_spec.rb +++ b/spec/cli/generate/policy_spec.rb @@ -16,6 +16,8 @@ a1 = Souls::Generate.new.invoke(:policy, ["user"], {}) expect(a1).to(eq(file_path)) FileUtils.rm_rf(file_dir) + rescue StandardError => error + FileUtils.rm(file_path) if File.exist?(file_path) end end end \ No newline at end of file diff --git a/spec/api/generate/query_spec.rb b/spec/cli/generate/query_spec.rb similarity index 87% rename from spec/api/generate/query_spec.rb rename to spec/cli/generate/query_spec.rb index edad6020..4475cdd1 100644 --- a/spec/api/generate/query_spec.rb +++ b/spec/cli/generate/query_spec.rb @@ -16,6 +16,8 @@ a1 = Souls::Generate.new.invoke(:query, ["user"], {}) expect(a1).to(eq(file_path)) FileUtils.rm_rf(file_dir) + rescue StandardError => error + FileUtils.rm(file_path) if File.exist?(file_path) end end end \ No newline at end of file diff --git a/spec/api/generate/resolver_spec.rb b/spec/cli/generate/resolver_spec.rb similarity index 88% rename from spec/api/generate/resolver_spec.rb rename to spec/cli/generate/resolver_spec.rb index 0e9d2eb2..1f643bc6 100644 --- a/spec/api/generate/resolver_spec.rb +++ b/spec/cli/generate/resolver_spec.rb @@ -16,6 +16,8 @@ a1 = Souls::Generate.new.invoke(:resolver, ["user"], {}) expect(a1).to(eq(file_path)) FileUtils.rm_rf(file_dir) + rescue StandardError => error + FileUtils.rm(file_path) if File.exist?(file_path) end end end \ No newline at end of file diff --git a/spec/api/generate/rspec_factory_spec.rb b/spec/cli/generate/rspec_factory_spec.rb similarity index 87% rename from spec/api/generate/rspec_factory_spec.rb rename to spec/cli/generate/rspec_factory_spec.rb index 2f245dce..9046f021 100644 --- a/spec/api/generate/rspec_factory_spec.rb +++ b/spec/cli/generate/rspec_factory_spec.rb @@ -16,6 +16,8 @@ a1 = Souls::Generate.new.invoke(:rspec_factory, ["user"], {}) expect(a1).to(eq(file_path)) FileUtils.rm_rf(file_dir) + rescue StandardError => error + FileUtils.rm_rf(file_dir) if Dir.exist?(file_dir) end end end \ No newline at end of file diff --git a/spec/api/generate/rspec_mutation_spec.rb b/spec/cli/generate/rspec_mutation_spec.rb similarity index 87% rename from spec/api/generate/rspec_mutation_spec.rb rename to spec/cli/generate/rspec_mutation_spec.rb index 471853b6..043f1890 100644 --- a/spec/api/generate/rspec_mutation_spec.rb +++ b/spec/cli/generate/rspec_mutation_spec.rb @@ -16,6 +16,8 @@ a1 = Souls::Generate.new.invoke(:rspec_mutation, ["user"], {}) expect(a1).to(eq(file_path)) FileUtils.rm_rf("./spec/mutations") + rescue StandardError => error + FileUtils.rm_rf(file_path) if File.exist?(file_path) end end end \ No newline at end of file diff --git a/spec/api/generate/rspec_policy_spec.rb b/spec/cli/generate/rspec_policy_spec.rb similarity index 87% rename from spec/api/generate/rspec_policy_spec.rb rename to spec/cli/generate/rspec_policy_spec.rb index 8c962091..55582ca2 100644 --- a/spec/api/generate/rspec_policy_spec.rb +++ b/spec/cli/generate/rspec_policy_spec.rb @@ -16,6 +16,8 @@ a1 = Souls::Generate.new.invoke(:rspec_policy, ["user"], {}) expect(a1).to(eq(file_path)) FileUtils.rm_rf(file_dir) + rescue StandardError => error + FileUtils.rm_rf(file_dir) if Dir.exist?(file_dir) end end end \ No newline at end of file diff --git a/spec/api/generate/rspec_query_spec.rb b/spec/cli/generate/rspec_query_spec.rb similarity index 87% rename from spec/api/generate/rspec_query_spec.rb rename to spec/cli/generate/rspec_query_spec.rb index 82741ccf..89ac672c 100644 --- a/spec/api/generate/rspec_query_spec.rb +++ b/spec/cli/generate/rspec_query_spec.rb @@ -16,6 +16,8 @@ a1 = Souls::Generate.new.invoke(:rspec_query, ["user"], {}) expect(a1).to(eq(file_path)) FileUtils.rm_rf(file_dir) + rescue StandardError => error + FileUtils.rm_rf(file_dir) if Dir.exist?(file_dir) end end end \ No newline at end of file diff --git a/spec/api/generate/rspec_resolver_spec.rb b/spec/cli/generate/rspec_resolver_spec.rb similarity index 87% rename from spec/api/generate/rspec_resolver_spec.rb rename to spec/cli/generate/rspec_resolver_spec.rb index c44995e9..e7df6ee8 100644 --- a/spec/api/generate/rspec_resolver_spec.rb +++ b/spec/cli/generate/rspec_resolver_spec.rb @@ -16,6 +16,8 @@ a1 = Souls::Generate.new.invoke(:rspec_resolver, ["user"], {}) expect(a1).to(eq(file_path)) FileUtils.rm_rf(file_dir) + rescue StandardError => error + FileUtils.rm_rf(file_dir) if Dir.exist?(file_dir) end end end \ No newline at end of file diff --git a/spec/souls_spec.rb b/spec/souls_spec.rb index d39fce15..4c5a3bdd 100644 --- a/spec/souls_spec.rb +++ b/spec/souls_spec.rb @@ -18,7 +18,7 @@ end it "has user tables" do - expect(Souls.get_tables).to(eq(["article_categories", "articles", "comments", "users"])) + expect(Souls.get_tables).to(eq(["users"])) end end end diff --git a/vendor/rbs/gem_rbs_collection b/vendor/rbs/gem_rbs_collection new file mode 160000 index 00000000..617bf103 --- /dev/null +++ b/vendor/rbs/gem_rbs_collection @@ -0,0 +1 @@ +Subproject commit 617bf1033baf96887e76cafd6dd88340a8006b54