Skip to content

Commit

Permalink
Move example app to specs
Browse files Browse the repository at this point in the history
  • Loading branch information
mattkhan committed Aug 17, 2024
1 parent 35d2455 commit 25f13ce
Show file tree
Hide file tree
Showing 105 changed files with 129 additions and 308 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
name: Example Schema Snapshot Test
name: RSpec

on:
pull_request:
push:
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
Expand All @@ -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
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.3.2
19 changes: 19 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
19 changes: 19 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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

Expand All @@ -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
Expand Down
31 changes: 0 additions & 31 deletions example/Gemfile

This file was deleted.

Loading

0 comments on commit 25f13ce

Please sign in to comment.