From 25f13cead4105d10ce64ed9f3a1c49e5dd28e6cc Mon Sep 17 00:00:00 2001 From: mattkhan Date: Sat, 17 Aug 2024 00:17:40 -0700 Subject: [PATCH] Move example app to specs --- .../{example_minitest.yml => rspec.yml} | 14 +- .ruby-version | 1 + Gemfile | 19 ++ Gemfile.lock | 19 ++ README.md | 11 +- example/Gemfile | 31 --- example/Gemfile.lock | 231 ------------------ example/README.md | 24 -- example/config/boot.rb | 3 - .../anchor/example_schema_snapshot_spec.rb | 11 +- spec/anchor/version_spec.rb | 2 + {example => spec/example}/.dockerignore | 0 {example => spec/example}/.gitattributes | 0 {example => spec/example}/.gitignore | 0 {example => spec/example}/.irbrc | 0 {example => spec/example}/.ruby-version | 0 {example => spec/example}/Dockerfile | 0 {example => spec/example}/Rakefile | 0 .../example}/app/assets/config/manifest.js | 0 .../example}/app/assets/images/.keep | 0 .../app/assets/stylesheets/application.css | 0 .../app/controllers/application_controller.rb | 0 .../controllers/commentables_controller.rb | 0 .../app/controllers/comments_controller.rb | 0 .../example}/app/controllers/concerns/.keep | 0 .../app/controllers/exhaustives_controller.rb | 0 .../app/controllers/posts_controller.rb | 0 .../app/controllers/resources_controller.rb | 0 .../app/controllers/users_controller.rb | 0 .../app/helpers/application_helper.rb | 0 .../example}/app/models/application_record.rb | 0 .../example}/app/models/comment.rb | 0 .../example}/app/models/concerns/.keep | 0 .../example}/app/models/exhaustive.rb | 0 {example => spec/example}/app/models/post.rb | 0 {example => spec/example}/app/models/user.rb | 0 .../app/resources/application_resource.rb | 0 .../app/resources/comment_resource.rb | 0 .../app/resources/commentable_resource.rb | 0 .../app/resources/exhaustive_resource.rb | 0 .../example}/app/resources/post_resource.rb | 0 .../example}/app/resources/schema.rb | 0 .../example}/app/resources/user_resource.rb | 0 .../example}/app/resources/user_role_enum.rb | 0 {example => spec/example}/app/types/types.rb | 0 .../app/views/layouts/application.html.erb | 0 .../example}/bin/docker-entrypoint | 0 {example => spec/example}/bin/rails | 0 {example => spec/example}/bin/rake | 0 {example => spec/example}/bin/setup | 0 {example => spec/example}/config.ru | 0 .../example}/config/application.rb | 0 spec/example/config/boot.rb | 5 + .../example}/config/credentials.yml.enc | 0 {example => spec/example}/config/database.yml | 0 .../example}/config/environment.rb | 0 .../config/environments/development.rb | 0 .../config/environments/production.rb | 0 .../example}/config/environments/test.rb | 0 .../example}/config/initializers/anchor.rb | 0 .../example}/config/initializers/assets.rb | 0 .../initializers/content_security_policy.rb | 0 .../initializers/filter_parameter_logging.rb | 0 .../config/initializers/inflections.rb | 0 .../config/initializers/permissions_policy.rb | 0 .../example}/config/locales/en.yml | 0 {example => spec/example}/config/puma.rb | 0 {example => spec/example}/config/routes.rb | 0 {example => spec/example}/console_utils.rb | 0 .../db/migrate/20240708081401_create_users.rb | 0 .../db/migrate/20240708082249_create_posts.rb | 0 .../migrate/20240708082257_create_comments.rb | 0 .../20240708090420_add_role_to_users.rb | 0 .../20240720203832_create_exhaustives.rb | 0 ...20240721052120_add_loljk_to_exhaustives.rb | 0 ...0721184631_add_overrides_to_exhaustives.rb | 0 ...5211806_add_with_comment_to_exhaustives.rb | 0 {example => spec/example}/db/schema.rb | 0 {example => spec/example}/db/seeds.rb | 0 {example => spec/example}/lib/assets/.keep | 0 {example => spec/example}/lib/tasks/.keep | 0 .../example}/lib/tasks/anchor.rake | 0 {example => spec/example}/log/.keep | 0 {example => spec/example}/public/404.html | 0 {example => spec/example}/public/422.html | 0 {example => spec/example}/public/500.html | 0 .../public/apple-touch-icon-precomposed.png | 0 .../example}/public/apple-touch-icon.png | 0 {example => spec/example}/public/favicon.ico | 0 {example => spec/example}/public/robots.txt | 0 {example => spec/example}/storage/.keep | 0 .../example}/test/controllers/.keep | 0 .../test/files/all_fields_false_schema.ts | 0 .../example}/test/files/json_schema.json | 0 .../example}/test/files/schema.ts | 0 .../example}/test/files/test_schema.ts | 0 .../example}/test/fixtures/files/.keep | 0 {example => spec/example}/test/helpers/.keep | 0 .../example}/test/integration/.keep | 0 {example => spec/example}/test/models/.keep | 0 {example => spec/example}/test/test_helper.rb | 0 {example => spec/example}/tmp/.keep | 0 {example => spec/example}/tmp/pids/.keep | 0 {example => spec/example}/tmp/storage/.keep | 0 spec/rails_helper.rb | 66 +++++ 105 files changed, 129 insertions(+), 308 deletions(-) rename .github/workflows/{example_minitest.yml => rspec.yml} (79%) create mode 100644 .ruby-version delete mode 100644 example/Gemfile delete mode 100644 example/Gemfile.lock delete mode 100644 example/README.md delete mode 100644 example/config/boot.rb rename example/test/models/schema_test.rb => spec/anchor/example_schema_snapshot_spec.rb (82%) rename {example => spec/example}/.dockerignore (100%) rename {example => spec/example}/.gitattributes (100%) rename {example => spec/example}/.gitignore (100%) rename {example => spec/example}/.irbrc (100%) rename {example => spec/example}/.ruby-version (100%) rename {example => spec/example}/Dockerfile (100%) rename {example => spec/example}/Rakefile (100%) rename {example => spec/example}/app/assets/config/manifest.js (100%) rename {example => spec/example}/app/assets/images/.keep (100%) rename {example => spec/example}/app/assets/stylesheets/application.css (100%) rename {example => spec/example}/app/controllers/application_controller.rb (100%) rename {example => spec/example}/app/controllers/commentables_controller.rb (100%) rename {example => spec/example}/app/controllers/comments_controller.rb (100%) rename {example => spec/example}/app/controllers/concerns/.keep (100%) rename {example => spec/example}/app/controllers/exhaustives_controller.rb (100%) rename {example => spec/example}/app/controllers/posts_controller.rb (100%) rename {example => spec/example}/app/controllers/resources_controller.rb (100%) rename {example => spec/example}/app/controllers/users_controller.rb (100%) rename {example => spec/example}/app/helpers/application_helper.rb (100%) rename {example => spec/example}/app/models/application_record.rb (100%) rename {example => spec/example}/app/models/comment.rb (100%) rename {example => spec/example}/app/models/concerns/.keep (100%) rename {example => spec/example}/app/models/exhaustive.rb (100%) rename {example => spec/example}/app/models/post.rb (100%) rename {example => spec/example}/app/models/user.rb (100%) rename {example => spec/example}/app/resources/application_resource.rb (100%) rename {example => spec/example}/app/resources/comment_resource.rb (100%) rename {example => spec/example}/app/resources/commentable_resource.rb (100%) rename {example => spec/example}/app/resources/exhaustive_resource.rb (100%) rename {example => spec/example}/app/resources/post_resource.rb (100%) rename {example => spec/example}/app/resources/schema.rb (100%) rename {example => spec/example}/app/resources/user_resource.rb (100%) rename {example => spec/example}/app/resources/user_role_enum.rb (100%) rename {example => spec/example}/app/types/types.rb (100%) rename {example => spec/example}/app/views/layouts/application.html.erb (100%) rename {example => spec/example}/bin/docker-entrypoint (100%) rename {example => spec/example}/bin/rails (100%) rename {example => spec/example}/bin/rake (100%) rename {example => spec/example}/bin/setup (100%) rename {example => spec/example}/config.ru (100%) rename {example => spec/example}/config/application.rb (100%) create mode 100644 spec/example/config/boot.rb rename {example => spec/example}/config/credentials.yml.enc (100%) rename {example => spec/example}/config/database.yml (100%) rename {example => spec/example}/config/environment.rb (100%) rename {example => spec/example}/config/environments/development.rb (100%) rename {example => spec/example}/config/environments/production.rb (100%) rename {example => spec/example}/config/environments/test.rb (100%) rename {example => spec/example}/config/initializers/anchor.rb (100%) rename {example => spec/example}/config/initializers/assets.rb (100%) rename {example => spec/example}/config/initializers/content_security_policy.rb (100%) rename {example => spec/example}/config/initializers/filter_parameter_logging.rb (100%) rename {example => spec/example}/config/initializers/inflections.rb (100%) rename {example => spec/example}/config/initializers/permissions_policy.rb (100%) rename {example => spec/example}/config/locales/en.yml (100%) rename {example => spec/example}/config/puma.rb (100%) rename {example => spec/example}/config/routes.rb (100%) rename {example => spec/example}/console_utils.rb (100%) rename {example => spec/example}/db/migrate/20240708081401_create_users.rb (100%) rename {example => spec/example}/db/migrate/20240708082249_create_posts.rb (100%) rename {example => spec/example}/db/migrate/20240708082257_create_comments.rb (100%) rename {example => spec/example}/db/migrate/20240708090420_add_role_to_users.rb (100%) rename {example => spec/example}/db/migrate/20240720203832_create_exhaustives.rb (100%) rename {example => spec/example}/db/migrate/20240721052120_add_loljk_to_exhaustives.rb (100%) rename {example => spec/example}/db/migrate/20240721184631_add_overrides_to_exhaustives.rb (100%) rename {example => spec/example}/db/migrate/20240815211806_add_with_comment_to_exhaustives.rb (100%) rename {example => spec/example}/db/schema.rb (100%) rename {example => spec/example}/db/seeds.rb (100%) rename {example => spec/example}/lib/assets/.keep (100%) rename {example => spec/example}/lib/tasks/.keep (100%) rename {example => spec/example}/lib/tasks/anchor.rake (100%) rename {example => spec/example}/log/.keep (100%) rename {example => spec/example}/public/404.html (100%) rename {example => spec/example}/public/422.html (100%) rename {example => spec/example}/public/500.html (100%) rename {example => spec/example}/public/apple-touch-icon-precomposed.png (100%) rename {example => spec/example}/public/apple-touch-icon.png (100%) rename {example => spec/example}/public/favicon.ico (100%) rename {example => spec/example}/public/robots.txt (100%) rename {example => spec/example}/storage/.keep (100%) rename {example => spec/example}/test/controllers/.keep (100%) rename {example => spec/example}/test/files/all_fields_false_schema.ts (100%) rename {example => spec/example}/test/files/json_schema.json (100%) rename {example => spec/example}/test/files/schema.ts (100%) rename {example => spec/example}/test/files/test_schema.ts (100%) rename {example => spec/example}/test/fixtures/files/.keep (100%) rename {example => spec/example}/test/helpers/.keep (100%) rename {example => spec/example}/test/integration/.keep (100%) rename {example => spec/example}/test/models/.keep (100%) rename {example => spec/example}/test/test_helper.rb (100%) rename {example => spec/example}/tmp/.keep (100%) rename {example => spec/example}/tmp/pids/.keep (100%) rename {example => spec/example}/tmp/storage/.keep (100%) create mode 100644 spec/rails_helper.rb diff --git a/.github/workflows/example_minitest.yml b/.github/workflows/rspec.yml similarity index 79% rename from .github/workflows/example_minitest.yml rename to .github/workflows/rspec.yml index b13ea9f..da26e03 100644 --- a/.github/workflows/example_minitest.yml +++ b/.github/workflows/rspec.yml @@ -1,4 +1,4 @@ -name: Example Schema Snapshot Test +name: RSpec on: pull_request: @@ -6,13 +6,9 @@ on: branches: [main] jobs: - test: + rspec: runs-on: ubuntu-latest - defaults: - run: - working-directory: example - env: RAILS_ENV: test DATABASE_URL: postgres://postgres:postgres@localhost:5432 @@ -35,13 +31,13 @@ jobs: - name: Set up Ruby uses: ruby/setup-ruby@v1 with: - working-directory: example bundler-cache: true - name: Set up database + working-directory: spec/example run: | bin/rails db:create bin/rails db:schema:load - - name: Run tests - run: bin/rails test -b + - name: Run specs + run: bundle exec rspec diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000..4772543 --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +3.3.2 diff --git a/Gemfile b/Gemfile index 500155c..fc180ed 100644 --- a/Gemfile +++ b/Gemfile @@ -3,3 +3,22 @@ source "https://rubygems.org" ruby "3.3.2" gemspec + +gem "jsonapi-resources", "~> 0.1" + +# # The original asset pipeline for Rails [https://github.com/rails/sprockets-rails] +gem "sprockets-rails" + +# Use postgresql as the database for Active Record +gem "pg", "~> 1.1" + +# Use the Puma web server [https://github.com/puma/puma] +gem "puma", ">= 5.0" + +# Windows does not include zoneinfo files, so bundle the tzinfo-data gem +gem "tzinfo-data", platforms: %i[ windows jruby ] + +group :development, :test do + # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem + gem "debug", platforms: %i[ mri windows ] +end diff --git a/Gemfile.lock b/Gemfile.lock index 08a0a6d..2dd2044 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -85,6 +85,9 @@ GEM connection_pool (2.4.1) crass (1.0.6) date (3.3.4) + debug (1.9.2) + irb (~> 1.10) + reline (>= 0.3.8) diff-lcs (1.5.1) drb (2.2.1) erubi (1.13.0) @@ -134,8 +137,11 @@ GEM racc (~> 1.4) nokogiri (1.16.7-x86_64-linux) racc (~> 1.4) + pg (1.5.7) psych (5.1.2) stringio + puma (6.4.2) + nio4r (~> 2.0) racc (1.8.1) rack (3.1.7) rack-session (2.0.0) @@ -197,6 +203,13 @@ GEM rspec-support (~> 3.13) rspec-support (3.13.1) securerandom (0.3.1) + sprockets (4.2.1) + concurrent-ruby (~> 1.0) + rack (>= 2.2.4, < 4) + sprockets-rails (3.5.2) + actionpack (>= 6.1) + activesupport (>= 6.1) + sprockets (>= 3.0.0) stringio (3.1.1) thor (1.3.1) timeout (0.4.1) @@ -219,8 +232,14 @@ PLATFORMS x86_64-linux DEPENDENCIES + debug + jsonapi-resources (~> 0.1) jsonapi-resources-anchor! + pg (~> 1.1) + puma (>= 5.0) rspec-rails (~> 6.0) + sprockets-rails + tzinfo-data yard RUBY VERSION diff --git a/README.md b/README.md index 1c141c6..75a8d44 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # JSON:API Resource Schema Generation: Anchor -![Example Schema Snapshot Test](https://github.com/mattkhan/jsonapi-resources-anchor/actions/workflows/example_minitest.yml/badge.svg) +![RSpec](https://github.com/mattkhan/jsonapi-resources-anchor/actions/workflows/rspec.yml/badge.svg) Easily generate TypeScript schemas, JSON Schemas, or any schema of your choice from [cerebris/jsonapi-resources](https://github.com/cerebris/jsonapi-resources) @@ -19,9 +19,10 @@ types defined in `Anchor::Types`, see [Annotations](#annotations). This gem provides TypeScript and JSON Schema generators with `Anchor::TypeScript::SchemaGenerator` and `Anchor::JSONSchema::SchemaGenerator`. -See the [example](./example) Rails app for a fully functional example using -`Anchor`. See [schema_test.rb](./example/test/models/schema_test.rb) for -`Schema` generation examples. +See the [example](./spec/example) Rails app for a fully functional example using +`Anchor`. See +[example_schema_snapshot_spec.rb](./spec/anchor/example_schema_snapshot_spec.rb) +for `Schema` generation examples. ## Inference @@ -35,7 +36,7 @@ then mapped to an `Anchor::Type` in `Anchor::Types::Inference::ActiveRecord::SQL.from`. - `Anchor.config.ar_column_to_type` allows custom mappings, see - [example/initializers/anchor.rb](./examples/initializers/anchor.rb) + [spec/example/initializers/anchor.rb](./spec/examples/initializers/anchor.rb) - `Anchor.config.use_active_record_presence` can be set to `true` to infer nullable attributes (i.e. fields that do not specify `null: false` in schema.rb) as non-null when an unconditional diff --git a/example/Gemfile b/example/Gemfile deleted file mode 100644 index aea55dc..0000000 --- a/example/Gemfile +++ /dev/null @@ -1,31 +0,0 @@ -source "https://rubygems.org" - -ruby "3.3.2" - -# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main" -gem "rails", "~> 7.1.3", ">= 7.1.3.4" - -# The original asset pipeline for Rails [https://github.com/rails/sprockets-rails] -gem "sprockets-rails" - -# Use postgresql as the database for Active Record -gem "pg", "~> 1.1" - -# Use the Puma web server [https://github.com/puma/puma] -gem "puma", ">= 5.0" - -# Windows does not include zoneinfo files, so bundle the tzinfo-data gem -gem "tzinfo-data", platforms: %i[ windows jruby ] - -group :development, :test do - # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem - gem "debug", platforms: %i[ mri windows ] -end - -group :development do - # Speed up commands on slow machines / big apps [https://github.com/rails/spring] - # gem "spring" -end - -gem "jsonapi-resources", "~> 0.10.7" -gem "jsonapi-resources-anchor", ">= 0.0.0.pre", path: ".." diff --git a/example/Gemfile.lock b/example/Gemfile.lock deleted file mode 100644 index 5f4f9b5..0000000 --- a/example/Gemfile.lock +++ /dev/null @@ -1,231 +0,0 @@ -PATH - remote: .. - specs: - jsonapi-resources-anchor (0.0.0.pre) - jsonapi-resources (~> 0.1) - rails (>= 7.0) - -GEM - remote: https://rubygems.org/ - specs: - actioncable (7.1.3.4) - actionpack (= 7.1.3.4) - activesupport (= 7.1.3.4) - nio4r (~> 2.0) - websocket-driver (>= 0.6.1) - zeitwerk (~> 2.6) - actionmailbox (7.1.3.4) - actionpack (= 7.1.3.4) - activejob (= 7.1.3.4) - activerecord (= 7.1.3.4) - activestorage (= 7.1.3.4) - activesupport (= 7.1.3.4) - mail (>= 2.7.1) - net-imap - net-pop - net-smtp - actionmailer (7.1.3.4) - actionpack (= 7.1.3.4) - actionview (= 7.1.3.4) - activejob (= 7.1.3.4) - activesupport (= 7.1.3.4) - mail (~> 2.5, >= 2.5.4) - net-imap - net-pop - net-smtp - rails-dom-testing (~> 2.2) - actionpack (7.1.3.4) - actionview (= 7.1.3.4) - activesupport (= 7.1.3.4) - nokogiri (>= 1.8.5) - racc - rack (>= 2.2.4) - rack-session (>= 1.0.1) - rack-test (>= 0.6.3) - rails-dom-testing (~> 2.2) - rails-html-sanitizer (~> 1.6) - actiontext (7.1.3.4) - actionpack (= 7.1.3.4) - activerecord (= 7.1.3.4) - activestorage (= 7.1.3.4) - activesupport (= 7.1.3.4) - globalid (>= 0.6.0) - nokogiri (>= 1.8.5) - actionview (7.1.3.4) - activesupport (= 7.1.3.4) - builder (~> 3.1) - erubi (~> 1.11) - rails-dom-testing (~> 2.2) - rails-html-sanitizer (~> 1.6) - activejob (7.1.3.4) - activesupport (= 7.1.3.4) - globalid (>= 0.3.6) - activemodel (7.1.3.4) - activesupport (= 7.1.3.4) - activerecord (7.1.3.4) - activemodel (= 7.1.3.4) - activesupport (= 7.1.3.4) - timeout (>= 0.4.0) - activestorage (7.1.3.4) - actionpack (= 7.1.3.4) - activejob (= 7.1.3.4) - activerecord (= 7.1.3.4) - activesupport (= 7.1.3.4) - marcel (~> 1.0) - activesupport (7.1.3.4) - base64 - bigdecimal - concurrent-ruby (~> 1.0, >= 1.0.2) - connection_pool (>= 2.2.5) - drb - i18n (>= 1.6, < 2) - minitest (>= 5.1) - mutex_m - tzinfo (~> 2.0) - base64 (0.2.0) - bigdecimal (3.1.8) - builder (3.3.0) - concurrent-ruby (1.3.3) - connection_pool (2.4.1) - crass (1.0.6) - date (3.3.4) - debug (1.9.2) - irb (~> 1.10) - reline (>= 0.3.8) - drb (2.2.1) - erubi (1.13.0) - globalid (1.2.1) - activesupport (>= 6.1) - i18n (1.14.5) - concurrent-ruby (~> 1.0) - io-console (0.7.2) - irb (1.14.0) - rdoc (>= 4.0.0) - reline (>= 0.4.2) - jsonapi-resources (0.10.7) - activerecord (>= 4.1) - concurrent-ruby - railties (>= 4.1) - loofah (2.22.0) - crass (~> 1.0.2) - nokogiri (>= 1.12.0) - mail (2.8.1) - mini_mime (>= 0.1.1) - net-imap - net-pop - net-smtp - marcel (1.0.4) - mini_mime (1.1.5) - minitest (5.24.1) - mutex_m (0.2.0) - net-imap (0.4.14) - date - net-protocol - net-pop (0.1.2) - net-protocol - net-protocol (0.2.2) - timeout - net-smtp (0.5.0) - net-protocol - nio4r (2.7.3) - nokogiri (1.16.6-aarch64-linux) - racc (~> 1.4) - nokogiri (1.16.6-arm-linux) - racc (~> 1.4) - nokogiri (1.16.6-arm64-darwin) - racc (~> 1.4) - nokogiri (1.16.6-x86-linux) - racc (~> 1.4) - nokogiri (1.16.6-x86_64-darwin) - racc (~> 1.4) - nokogiri (1.16.6-x86_64-linux) - racc (~> 1.4) - pg (1.5.6) - psych (5.1.2) - stringio - puma (6.4.2) - nio4r (~> 2.0) - racc (1.8.0) - rack (3.1.6) - rack-session (2.0.0) - rack (>= 3.0.0) - rack-test (2.1.0) - rack (>= 1.3) - rackup (2.1.0) - rack (>= 3) - webrick (~> 1.8) - rails (7.1.3.4) - actioncable (= 7.1.3.4) - actionmailbox (= 7.1.3.4) - actionmailer (= 7.1.3.4) - actionpack (= 7.1.3.4) - actiontext (= 7.1.3.4) - actionview (= 7.1.3.4) - activejob (= 7.1.3.4) - activemodel (= 7.1.3.4) - activerecord (= 7.1.3.4) - activestorage (= 7.1.3.4) - activesupport (= 7.1.3.4) - bundler (>= 1.15.0) - railties (= 7.1.3.4) - rails-dom-testing (2.2.0) - activesupport (>= 5.0.0) - minitest - nokogiri (>= 1.6) - rails-html-sanitizer (1.6.0) - loofah (~> 2.21) - nokogiri (~> 1.14) - railties (7.1.3.4) - actionpack (= 7.1.3.4) - activesupport (= 7.1.3.4) - irb - rackup (>= 1.0.0) - rake (>= 12.2) - thor (~> 1.0, >= 1.2.2) - zeitwerk (~> 2.6) - rake (13.2.1) - rdoc (6.7.0) - psych (>= 4.0.0) - reline (0.5.9) - io-console (~> 0.5) - sprockets (4.2.1) - concurrent-ruby (~> 1.0) - rack (>= 2.2.4, < 4) - sprockets-rails (3.5.1) - actionpack (>= 6.1) - activesupport (>= 6.1) - sprockets (>= 3.0.0) - stringio (3.1.1) - thor (1.3.1) - timeout (0.4.1) - tzinfo (2.0.6) - concurrent-ruby (~> 1.0) - webrick (1.8.1) - websocket-driver (0.7.6) - websocket-extensions (>= 0.1.0) - websocket-extensions (0.1.5) - zeitwerk (2.6.16) - -PLATFORMS - aarch64-linux - arm-linux - arm64-darwin - x86-linux - x86_64-darwin - x86_64-linux - -DEPENDENCIES - debug - jsonapi-resources (~> 0.10.7) - jsonapi-resources-anchor (>= 0.0.0.pre)! - pg (~> 1.1) - puma (>= 5.0) - rails (~> 7.1.3, >= 7.1.3.4) - sprockets-rails - tzinfo-data - -RUBY VERSION - ruby 3.3.2p78 - -BUNDLED WITH - 2.5.9 diff --git a/example/README.md b/example/README.md deleted file mode 100644 index 7db80e4..0000000 --- a/example/README.md +++ /dev/null @@ -1,24 +0,0 @@ -# README - -This README would normally document whatever steps are necessary to get the -application up and running. - -Things you may want to cover: - -* Ruby version - -* System dependencies - -* Configuration - -* Database creation - -* Database initialization - -* How to run the test suite - -* Services (job queues, cache servers, search engines, etc.) - -* Deployment instructions - -* ... diff --git a/example/config/boot.rb b/example/config/boot.rb deleted file mode 100644 index 2820116..0000000 --- a/example/config/boot.rb +++ /dev/null @@ -1,3 +0,0 @@ -ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) - -require "bundler/setup" # Set up gems listed in the Gemfile. diff --git a/example/test/models/schema_test.rb b/spec/anchor/example_schema_snapshot_spec.rb similarity index 82% rename from example/test/models/schema_test.rb rename to spec/anchor/example_schema_snapshot_spec.rb index 46227a0..e40e35d 100644 --- a/example/test/models/schema_test.rb +++ b/spec/anchor/example_schema_snapshot_spec.rb @@ -1,6 +1,7 @@ -require "test_helper" +require "thor" +require "rails_helper" -class SchemaTest < ActiveSupport::TestCase +RSpec.describe "Example" do class SnapshotUpdate < Thor include Thor::Actions @@ -11,7 +12,7 @@ def prompt(...) = create_file(...) end def self.snapshot_test(filename, generate) - test "generates correct #{filename} schema" do + it "generates correct #{filename} schema" do schema = generate.call path = Rails.root.join("test/files", filename) unless File.file?(path) @@ -21,11 +22,11 @@ def self.snapshot_test(filename, generate) if ENV['THOR_MERGE'] && expected_schema != schema SnapshotUpdate.prompt(path, schema) - assert_equal File.read(path), schema + expect(File.read(path)).to eql(schema) return end - assert_equal expected_schema, schema + expect(expected_schema).to eql(schema) end end diff --git a/spec/anchor/version_spec.rb b/spec/anchor/version_spec.rb index 9311b75..b002d30 100644 --- a/spec/anchor/version_spec.rb +++ b/spec/anchor/version_spec.rb @@ -1,3 +1,5 @@ +require "rails_helper" + RSpec.describe Anchor do it 'has a version number' do expect(Anchor::VERSION).to be_a String diff --git a/example/.dockerignore b/spec/example/.dockerignore similarity index 100% rename from example/.dockerignore rename to spec/example/.dockerignore diff --git a/example/.gitattributes b/spec/example/.gitattributes similarity index 100% rename from example/.gitattributes rename to spec/example/.gitattributes diff --git a/example/.gitignore b/spec/example/.gitignore similarity index 100% rename from example/.gitignore rename to spec/example/.gitignore diff --git a/example/.irbrc b/spec/example/.irbrc similarity index 100% rename from example/.irbrc rename to spec/example/.irbrc diff --git a/example/.ruby-version b/spec/example/.ruby-version similarity index 100% rename from example/.ruby-version rename to spec/example/.ruby-version diff --git a/example/Dockerfile b/spec/example/Dockerfile similarity index 100% rename from example/Dockerfile rename to spec/example/Dockerfile diff --git a/example/Rakefile b/spec/example/Rakefile similarity index 100% rename from example/Rakefile rename to spec/example/Rakefile diff --git a/example/app/assets/config/manifest.js b/spec/example/app/assets/config/manifest.js similarity index 100% rename from example/app/assets/config/manifest.js rename to spec/example/app/assets/config/manifest.js diff --git a/example/app/assets/images/.keep b/spec/example/app/assets/images/.keep similarity index 100% rename from example/app/assets/images/.keep rename to spec/example/app/assets/images/.keep diff --git a/example/app/assets/stylesheets/application.css b/spec/example/app/assets/stylesheets/application.css similarity index 100% rename from example/app/assets/stylesheets/application.css rename to spec/example/app/assets/stylesheets/application.css diff --git a/example/app/controllers/application_controller.rb b/spec/example/app/controllers/application_controller.rb similarity index 100% rename from example/app/controllers/application_controller.rb rename to spec/example/app/controllers/application_controller.rb diff --git a/example/app/controllers/commentables_controller.rb b/spec/example/app/controllers/commentables_controller.rb similarity index 100% rename from example/app/controllers/commentables_controller.rb rename to spec/example/app/controllers/commentables_controller.rb diff --git a/example/app/controllers/comments_controller.rb b/spec/example/app/controllers/comments_controller.rb similarity index 100% rename from example/app/controllers/comments_controller.rb rename to spec/example/app/controllers/comments_controller.rb diff --git a/example/app/controllers/concerns/.keep b/spec/example/app/controllers/concerns/.keep similarity index 100% rename from example/app/controllers/concerns/.keep rename to spec/example/app/controllers/concerns/.keep diff --git a/example/app/controllers/exhaustives_controller.rb b/spec/example/app/controllers/exhaustives_controller.rb similarity index 100% rename from example/app/controllers/exhaustives_controller.rb rename to spec/example/app/controllers/exhaustives_controller.rb diff --git a/example/app/controllers/posts_controller.rb b/spec/example/app/controllers/posts_controller.rb similarity index 100% rename from example/app/controllers/posts_controller.rb rename to spec/example/app/controllers/posts_controller.rb diff --git a/example/app/controllers/resources_controller.rb b/spec/example/app/controllers/resources_controller.rb similarity index 100% rename from example/app/controllers/resources_controller.rb rename to spec/example/app/controllers/resources_controller.rb diff --git a/example/app/controllers/users_controller.rb b/spec/example/app/controllers/users_controller.rb similarity index 100% rename from example/app/controllers/users_controller.rb rename to spec/example/app/controllers/users_controller.rb diff --git a/example/app/helpers/application_helper.rb b/spec/example/app/helpers/application_helper.rb similarity index 100% rename from example/app/helpers/application_helper.rb rename to spec/example/app/helpers/application_helper.rb diff --git a/example/app/models/application_record.rb b/spec/example/app/models/application_record.rb similarity index 100% rename from example/app/models/application_record.rb rename to spec/example/app/models/application_record.rb diff --git a/example/app/models/comment.rb b/spec/example/app/models/comment.rb similarity index 100% rename from example/app/models/comment.rb rename to spec/example/app/models/comment.rb diff --git a/example/app/models/concerns/.keep b/spec/example/app/models/concerns/.keep similarity index 100% rename from example/app/models/concerns/.keep rename to spec/example/app/models/concerns/.keep diff --git a/example/app/models/exhaustive.rb b/spec/example/app/models/exhaustive.rb similarity index 100% rename from example/app/models/exhaustive.rb rename to spec/example/app/models/exhaustive.rb diff --git a/example/app/models/post.rb b/spec/example/app/models/post.rb similarity index 100% rename from example/app/models/post.rb rename to spec/example/app/models/post.rb diff --git a/example/app/models/user.rb b/spec/example/app/models/user.rb similarity index 100% rename from example/app/models/user.rb rename to spec/example/app/models/user.rb diff --git a/example/app/resources/application_resource.rb b/spec/example/app/resources/application_resource.rb similarity index 100% rename from example/app/resources/application_resource.rb rename to spec/example/app/resources/application_resource.rb diff --git a/example/app/resources/comment_resource.rb b/spec/example/app/resources/comment_resource.rb similarity index 100% rename from example/app/resources/comment_resource.rb rename to spec/example/app/resources/comment_resource.rb diff --git a/example/app/resources/commentable_resource.rb b/spec/example/app/resources/commentable_resource.rb similarity index 100% rename from example/app/resources/commentable_resource.rb rename to spec/example/app/resources/commentable_resource.rb diff --git a/example/app/resources/exhaustive_resource.rb b/spec/example/app/resources/exhaustive_resource.rb similarity index 100% rename from example/app/resources/exhaustive_resource.rb rename to spec/example/app/resources/exhaustive_resource.rb diff --git a/example/app/resources/post_resource.rb b/spec/example/app/resources/post_resource.rb similarity index 100% rename from example/app/resources/post_resource.rb rename to spec/example/app/resources/post_resource.rb diff --git a/example/app/resources/schema.rb b/spec/example/app/resources/schema.rb similarity index 100% rename from example/app/resources/schema.rb rename to spec/example/app/resources/schema.rb diff --git a/example/app/resources/user_resource.rb b/spec/example/app/resources/user_resource.rb similarity index 100% rename from example/app/resources/user_resource.rb rename to spec/example/app/resources/user_resource.rb diff --git a/example/app/resources/user_role_enum.rb b/spec/example/app/resources/user_role_enum.rb similarity index 100% rename from example/app/resources/user_role_enum.rb rename to spec/example/app/resources/user_role_enum.rb diff --git a/example/app/types/types.rb b/spec/example/app/types/types.rb similarity index 100% rename from example/app/types/types.rb rename to spec/example/app/types/types.rb diff --git a/example/app/views/layouts/application.html.erb b/spec/example/app/views/layouts/application.html.erb similarity index 100% rename from example/app/views/layouts/application.html.erb rename to spec/example/app/views/layouts/application.html.erb diff --git a/example/bin/docker-entrypoint b/spec/example/bin/docker-entrypoint similarity index 100% rename from example/bin/docker-entrypoint rename to spec/example/bin/docker-entrypoint diff --git a/example/bin/rails b/spec/example/bin/rails similarity index 100% rename from example/bin/rails rename to spec/example/bin/rails diff --git a/example/bin/rake b/spec/example/bin/rake similarity index 100% rename from example/bin/rake rename to spec/example/bin/rake diff --git a/example/bin/setup b/spec/example/bin/setup similarity index 100% rename from example/bin/setup rename to spec/example/bin/setup diff --git a/example/config.ru b/spec/example/config.ru similarity index 100% rename from example/config.ru rename to spec/example/config.ru diff --git a/example/config/application.rb b/spec/example/config/application.rb similarity index 100% rename from example/config/application.rb rename to spec/example/config/application.rb diff --git a/spec/example/config/boot.rb b/spec/example/config/boot.rb new file mode 100644 index 0000000..116591a --- /dev/null +++ b/spec/example/config/boot.rb @@ -0,0 +1,5 @@ +# 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/example/config/credentials.yml.enc b/spec/example/config/credentials.yml.enc similarity index 100% rename from example/config/credentials.yml.enc rename to spec/example/config/credentials.yml.enc diff --git a/example/config/database.yml b/spec/example/config/database.yml similarity index 100% rename from example/config/database.yml rename to spec/example/config/database.yml diff --git a/example/config/environment.rb b/spec/example/config/environment.rb similarity index 100% rename from example/config/environment.rb rename to spec/example/config/environment.rb diff --git a/example/config/environments/development.rb b/spec/example/config/environments/development.rb similarity index 100% rename from example/config/environments/development.rb rename to spec/example/config/environments/development.rb diff --git a/example/config/environments/production.rb b/spec/example/config/environments/production.rb similarity index 100% rename from example/config/environments/production.rb rename to spec/example/config/environments/production.rb diff --git a/example/config/environments/test.rb b/spec/example/config/environments/test.rb similarity index 100% rename from example/config/environments/test.rb rename to spec/example/config/environments/test.rb diff --git a/example/config/initializers/anchor.rb b/spec/example/config/initializers/anchor.rb similarity index 100% rename from example/config/initializers/anchor.rb rename to spec/example/config/initializers/anchor.rb diff --git a/example/config/initializers/assets.rb b/spec/example/config/initializers/assets.rb similarity index 100% rename from example/config/initializers/assets.rb rename to spec/example/config/initializers/assets.rb diff --git a/example/config/initializers/content_security_policy.rb b/spec/example/config/initializers/content_security_policy.rb similarity index 100% rename from example/config/initializers/content_security_policy.rb rename to spec/example/config/initializers/content_security_policy.rb diff --git a/example/config/initializers/filter_parameter_logging.rb b/spec/example/config/initializers/filter_parameter_logging.rb similarity index 100% rename from example/config/initializers/filter_parameter_logging.rb rename to spec/example/config/initializers/filter_parameter_logging.rb diff --git a/example/config/initializers/inflections.rb b/spec/example/config/initializers/inflections.rb similarity index 100% rename from example/config/initializers/inflections.rb rename to spec/example/config/initializers/inflections.rb diff --git a/example/config/initializers/permissions_policy.rb b/spec/example/config/initializers/permissions_policy.rb similarity index 100% rename from example/config/initializers/permissions_policy.rb rename to spec/example/config/initializers/permissions_policy.rb diff --git a/example/config/locales/en.yml b/spec/example/config/locales/en.yml similarity index 100% rename from example/config/locales/en.yml rename to spec/example/config/locales/en.yml diff --git a/example/config/puma.rb b/spec/example/config/puma.rb similarity index 100% rename from example/config/puma.rb rename to spec/example/config/puma.rb diff --git a/example/config/routes.rb b/spec/example/config/routes.rb similarity index 100% rename from example/config/routes.rb rename to spec/example/config/routes.rb diff --git a/example/console_utils.rb b/spec/example/console_utils.rb similarity index 100% rename from example/console_utils.rb rename to spec/example/console_utils.rb diff --git a/example/db/migrate/20240708081401_create_users.rb b/spec/example/db/migrate/20240708081401_create_users.rb similarity index 100% rename from example/db/migrate/20240708081401_create_users.rb rename to spec/example/db/migrate/20240708081401_create_users.rb diff --git a/example/db/migrate/20240708082249_create_posts.rb b/spec/example/db/migrate/20240708082249_create_posts.rb similarity index 100% rename from example/db/migrate/20240708082249_create_posts.rb rename to spec/example/db/migrate/20240708082249_create_posts.rb diff --git a/example/db/migrate/20240708082257_create_comments.rb b/spec/example/db/migrate/20240708082257_create_comments.rb similarity index 100% rename from example/db/migrate/20240708082257_create_comments.rb rename to spec/example/db/migrate/20240708082257_create_comments.rb diff --git a/example/db/migrate/20240708090420_add_role_to_users.rb b/spec/example/db/migrate/20240708090420_add_role_to_users.rb similarity index 100% rename from example/db/migrate/20240708090420_add_role_to_users.rb rename to spec/example/db/migrate/20240708090420_add_role_to_users.rb diff --git a/example/db/migrate/20240720203832_create_exhaustives.rb b/spec/example/db/migrate/20240720203832_create_exhaustives.rb similarity index 100% rename from example/db/migrate/20240720203832_create_exhaustives.rb rename to spec/example/db/migrate/20240720203832_create_exhaustives.rb diff --git a/example/db/migrate/20240721052120_add_loljk_to_exhaustives.rb b/spec/example/db/migrate/20240721052120_add_loljk_to_exhaustives.rb similarity index 100% rename from example/db/migrate/20240721052120_add_loljk_to_exhaustives.rb rename to spec/example/db/migrate/20240721052120_add_loljk_to_exhaustives.rb diff --git a/example/db/migrate/20240721184631_add_overrides_to_exhaustives.rb b/spec/example/db/migrate/20240721184631_add_overrides_to_exhaustives.rb similarity index 100% rename from example/db/migrate/20240721184631_add_overrides_to_exhaustives.rb rename to spec/example/db/migrate/20240721184631_add_overrides_to_exhaustives.rb diff --git a/example/db/migrate/20240815211806_add_with_comment_to_exhaustives.rb b/spec/example/db/migrate/20240815211806_add_with_comment_to_exhaustives.rb similarity index 100% rename from example/db/migrate/20240815211806_add_with_comment_to_exhaustives.rb rename to spec/example/db/migrate/20240815211806_add_with_comment_to_exhaustives.rb diff --git a/example/db/schema.rb b/spec/example/db/schema.rb similarity index 100% rename from example/db/schema.rb rename to spec/example/db/schema.rb diff --git a/example/db/seeds.rb b/spec/example/db/seeds.rb similarity index 100% rename from example/db/seeds.rb rename to spec/example/db/seeds.rb diff --git a/example/lib/assets/.keep b/spec/example/lib/assets/.keep similarity index 100% rename from example/lib/assets/.keep rename to spec/example/lib/assets/.keep diff --git a/example/lib/tasks/.keep b/spec/example/lib/tasks/.keep similarity index 100% rename from example/lib/tasks/.keep rename to spec/example/lib/tasks/.keep diff --git a/example/lib/tasks/anchor.rake b/spec/example/lib/tasks/anchor.rake similarity index 100% rename from example/lib/tasks/anchor.rake rename to spec/example/lib/tasks/anchor.rake diff --git a/example/log/.keep b/spec/example/log/.keep similarity index 100% rename from example/log/.keep rename to spec/example/log/.keep diff --git a/example/public/404.html b/spec/example/public/404.html similarity index 100% rename from example/public/404.html rename to spec/example/public/404.html diff --git a/example/public/422.html b/spec/example/public/422.html similarity index 100% rename from example/public/422.html rename to spec/example/public/422.html diff --git a/example/public/500.html b/spec/example/public/500.html similarity index 100% rename from example/public/500.html rename to spec/example/public/500.html diff --git a/example/public/apple-touch-icon-precomposed.png b/spec/example/public/apple-touch-icon-precomposed.png similarity index 100% rename from example/public/apple-touch-icon-precomposed.png rename to spec/example/public/apple-touch-icon-precomposed.png diff --git a/example/public/apple-touch-icon.png b/spec/example/public/apple-touch-icon.png similarity index 100% rename from example/public/apple-touch-icon.png rename to spec/example/public/apple-touch-icon.png diff --git a/example/public/favicon.ico b/spec/example/public/favicon.ico similarity index 100% rename from example/public/favicon.ico rename to spec/example/public/favicon.ico diff --git a/example/public/robots.txt b/spec/example/public/robots.txt similarity index 100% rename from example/public/robots.txt rename to spec/example/public/robots.txt diff --git a/example/storage/.keep b/spec/example/storage/.keep similarity index 100% rename from example/storage/.keep rename to spec/example/storage/.keep diff --git a/example/test/controllers/.keep b/spec/example/test/controllers/.keep similarity index 100% rename from example/test/controllers/.keep rename to spec/example/test/controllers/.keep diff --git a/example/test/files/all_fields_false_schema.ts b/spec/example/test/files/all_fields_false_schema.ts similarity index 100% rename from example/test/files/all_fields_false_schema.ts rename to spec/example/test/files/all_fields_false_schema.ts diff --git a/example/test/files/json_schema.json b/spec/example/test/files/json_schema.json similarity index 100% rename from example/test/files/json_schema.json rename to spec/example/test/files/json_schema.json diff --git a/example/test/files/schema.ts b/spec/example/test/files/schema.ts similarity index 100% rename from example/test/files/schema.ts rename to spec/example/test/files/schema.ts diff --git a/example/test/files/test_schema.ts b/spec/example/test/files/test_schema.ts similarity index 100% rename from example/test/files/test_schema.ts rename to spec/example/test/files/test_schema.ts diff --git a/example/test/fixtures/files/.keep b/spec/example/test/fixtures/files/.keep similarity index 100% rename from example/test/fixtures/files/.keep rename to spec/example/test/fixtures/files/.keep diff --git a/example/test/helpers/.keep b/spec/example/test/helpers/.keep similarity index 100% rename from example/test/helpers/.keep rename to spec/example/test/helpers/.keep diff --git a/example/test/integration/.keep b/spec/example/test/integration/.keep similarity index 100% rename from example/test/integration/.keep rename to spec/example/test/integration/.keep diff --git a/example/test/models/.keep b/spec/example/test/models/.keep similarity index 100% rename from example/test/models/.keep rename to spec/example/test/models/.keep diff --git a/example/test/test_helper.rb b/spec/example/test/test_helper.rb similarity index 100% rename from example/test/test_helper.rb rename to spec/example/test/test_helper.rb diff --git a/example/tmp/.keep b/spec/example/tmp/.keep similarity index 100% rename from example/tmp/.keep rename to spec/example/tmp/.keep diff --git a/example/tmp/pids/.keep b/spec/example/tmp/pids/.keep similarity index 100% rename from example/tmp/pids/.keep rename to spec/example/tmp/pids/.keep diff --git a/example/tmp/storage/.keep b/spec/example/tmp/storage/.keep similarity index 100% rename from example/tmp/storage/.keep rename to spec/example/tmp/storage/.keep diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb new file mode 100644 index 0000000..1318ad2 --- /dev/null +++ b/spec/rails_helper.rb @@ -0,0 +1,66 @@ +# This file is copied to spec/ when you run 'rails generate rspec:install' +require "spec_helper" +ENV["RAILS_ENV"] ||= "test" +require_relative "../spec/example/config/environment" +# Prevent database truncation if the environment is production +abort("The Rails environment is running in production mode!") if Rails.env.production? +require "rspec/rails" +# Add additional requires below this line. Rails is not loaded until this point! + +# Requires supporting ruby files with custom matchers and macros, etc, in +# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are +# run as spec files by default. This means that files in spec/support that end +# in _spec.rb will both be required and run as specs, causing the specs to be +# run twice. It is recommended that you do not name files matching this glob to +# end with _spec.rb. You can configure this pattern with the --pattern +# option on the command line or in ~/.rspec, .rspec or `.rspec-local`. +# +# The following line is provided for convenience purposes. It has the downside +# of increasing the boot-up time by auto-requiring all files in the support +# directory. Alternatively, in the individual `*_spec.rb` files, manually +# require only the support files necessary. +# +Rails.root.glob("spec/support/**/*.rb").sort.each { |f| require f } + +# Checks for pending migrations and applies them before tests are run. +# If you are not using ActiveRecord, you can remove these lines. +begin + ActiveRecord::Migration.maintain_test_schema! +rescue ActiveRecord::PendingMigrationError => e + abort e.to_s.strip +end +RSpec.configure do |config| + # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures + config.fixture_paths = [Rails.root.join("spec/fixtures")] + + # If you're not using ActiveRecord, or you'd prefer not to run each of your + # examples within a transaction, remove the following line or assign false + # instead of true. + config.use_transactional_fixtures = true + + # You can uncomment this line to turn off ActiveRecord support entirely. + # config.use_active_record = false + + # RSpec Rails can automatically mix in different behaviours to your tests + # based on their file location, for example enabling you to call `get` and + # `post` in specs under `spec/controllers`. + # + # You can disable this behaviour by removing the line below, and instead + # explicitly tag your specs with their type, e.g.: + # + # RSpec.describe UsersController, type: :controller do + # # ... + # end + # + # The different available types are documented in the features, such as in + # https://rspec.info/features/6-0/rspec-rails + config.infer_spec_type_from_file_location! + + # Filter lines from Rails gems in backtraces. + config.filter_rails_from_backtrace! + # arbitrary gems may also be filtered via: + # config.filter_gems_from_backtrace("gem name") + + # travel_to + config.include ActiveSupport::Testing::TimeHelpers +end