ts_schema_spec 0.6.1 → 0.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e3c86744b3644ad258aa39eff8ff11b55df1cc933003276126f7b1b3d9952d91
4
- data.tar.gz: e0a59266d59248a00e092c96b85978bde02bf19d1dd85f6b382addc3ca9fb32b
3
+ metadata.gz: aa0e8f7875f653a96d983cef0b248b9a1aeeb94afc948ebf1ef1ac3bf75154f3
4
+ data.tar.gz: 4b0a49cea4dc148e4a28228f9fb877331cf04543e8f906e8ceffd04ba798f8e4
5
5
  SHA512:
6
- metadata.gz: dbcc3f50c232a8cf847db8804abc4af17140f884c051b414fea6f6cd56d0f93127c2e002b2856c255305dc3685b236329dd2a58dc6e552f99dc11b6d441ccd4d
7
- data.tar.gz: 83f7161eebc10dd01d0634fa4eb022c7d5afa5f8ace26690bfa5022c5fa624409f167497dcaf9c2ef2cd3b05ea452dccf7124bd64581c5cba456b162cad2fc97
6
+ metadata.gz: aeb87cc7d2e5fffc8a0b3c31519fe0b40f0d22f2a44216c32f9129252bff2e25d8327fc1064c61609ac25da881af50d35a2eb56e8fd9b2f14e204a675d7251f0
7
+ data.tar.gz: 6b5a662b7e8cba8b5a00cf85c4a7f8f33f76738d255a01c46633221e6d46452cf9f4e743b071be8bd8cc046677ef5957f5f407ee71b4ba96f182a55a38b20d4f
data/README.md CHANGED
@@ -148,14 +148,14 @@ empty array.
148
148
 
149
149
  ## API
150
150
 
151
- | Call | Returns |
152
- | --------------------------------------- | ----------------------------------------------------------- |
153
- | `TsSchemaSpec.schema_for(path, type)` | a `JSONSchemer` schema scoped to that exported type |
154
- | `match_ts_schema(path, type)` | matcher; validates a hash, or every item of an array |
155
- | `react_component_props(name[, html])` | array of props hashes, one per mount |
156
- | `TsSchemaSpec::Skill.check!(root)` | raises if the installed skill is stale or missing |
157
- | `TsSchemaSpec.configure` | sets `tsconfig` and extra generator arguments |
158
- | `TsSchemaSpec.clear_cache!` | drops the generated-schema cache |
151
+ | Call | Returns |
152
+ | ------------------------------------- | ---------------------------------------------------- |
153
+ | `TsSchemaSpec.schema_for(path, type)` | a `JSONSchemer` schema scoped to that exported type |
154
+ | `match_ts_schema(path, type)` | matcher; validates a hash, or every item of an array |
155
+ | `react_component_props(name[, html])` | array of props hashes, one per mount |
156
+ | `TsSchemaSpec::Skill.check!(root)` | raises if the installed skill is stale or missing |
157
+ | `TsSchemaSpec.configure` | sets `tsconfig` and extra generator arguments |
158
+ | `TsSchemaSpec.clear_cache!` | drops the generated-schema cache |
159
159
 
160
160
  `match_ts_schema` was called `match_schema` before 0.6.1. The old name still
161
161
  works but is deprecated and will be removed.
@@ -246,14 +246,14 @@ The cache lives in the process, so parallel test workers each pay for it once.
246
246
 
247
247
  ## Troubleshooting
248
248
 
249
- | Symptom | Cause |
250
- | ---------------------------------------------------- | -------------------------------------------------------------- |
251
- | `GenerationError: ... Is it exported?` | the type has no `export`, or the name is misspelled |
252
- | `GenerationError` listing a rerunnable command | run it — the generator's own stderr is in the message |
253
- | passes against an obviously wrong payload | the type is all-optional, or an unresolved import became `{}` |
254
- | `could not run npx ts-json-schema-generator` | the generator is not in your `node_modules` |
255
- | `disallowed additional property` | see above — the payload sends what TypeScript does not declare |
256
- | `has no data-react-props attribute` | hand-written markup, or a mount from another integration |
249
+ | Symptom | Cause |
250
+ | ---------------------------------------------- | -------------------------------------------------------------- |
251
+ | `GenerationError: ... Is it exported?` | the type has no `export`, or the name is misspelled |
252
+ | `GenerationError` listing a rerunnable command | run it — the generator's own stderr is in the message |
253
+ | passes against an obviously wrong payload | the type is all-optional, or an unresolved import became `{}` |
254
+ | `could not run npx ts-json-schema-generator` | the generator is not in your `node_modules` |
255
+ | `disallowed additional property` | see above — the payload sends what TypeScript does not declare |
256
+ | `has no data-react-props attribute` | hand-written markup, or a mount from another integration |
257
257
 
258
258
  ## What this can't catch
259
259
 
@@ -263,7 +263,7 @@ Worth knowing before you rely on it.
263
263
  a spec for; an uncovered endpoint is exactly as exposed as before. That is what
264
264
  the skill is for, and it is convention rather than enforcement.
265
265
 
266
- **It only checks what TypeScript declares.** If Rails *intends* to send a field
266
+ **It only checks what TypeScript declares.** If Rails _intends_ to send a field
267
267
  nobody typed — say `as_json(only:)` carrying a misspelled attribute, which
268
268
  Rails drops silently — no generated schema requires it, so nothing fails. A
269
269
  structured serializer catches that class of mistake; this does not.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TsSchemaSpec
4
- VERSION = "0.6.1"
4
+ VERSION = "0.6.3"
5
5
  end
@@ -65,9 +65,9 @@ implying the spec covers them.
65
65
 
66
66
  ## Step 4 — Write the test
67
67
 
68
- | Action | Data source |
69
- | ------ | ----------- |
70
- | `render json:` | `response.parsed_body["key"]` |
68
+ | Action | Data source |
69
+ | ----------------- | ---------------------------------------- |
70
+ | `render json:` | `response.parsed_body["key"]` |
71
71
  | `react_component` | `react_component_props("ComponentName")` |
72
72
 
73
73
  `react_component_props` returns **an array**, one entry per mount, and needs
@@ -79,6 +79,8 @@ times on an empty array and asserts nothing.
79
79
  describe "the props handed to MyComponent" do
80
80
  render_views
81
81
 
82
+ my_component = "app/javascript/MyComponent.tsx"
83
+
82
84
  it "matches MyComponentProps" do
83
85
  record = create(:factory_name, trait_a: true)
84
86
  create(:factory_name, :some_trait)
@@ -87,13 +89,14 @@ describe "the props handed to MyComponent" do
87
89
 
88
90
  expect(response).to be_successful
89
91
  props = react_component_props("MyComponent")
90
- expect(props).to match_ts_schema("app/javascript/MyComponent.tsx", "MyComponentProps")
92
+ expect(props).to match_ts_schema(my_component, "MyComponentProps")
91
93
  end
92
94
  end
93
95
  ```
94
96
 
95
- Name the file and type at the assertion. When several examples read the same
96
- source, bind the path to a constant or a let variable.
97
+ Name the file and type at the assertion. Bind the path to a local variable or a
98
+ `let`, not a constant: a constant assigned inside a `describe` block is global
99
+ and collides between spec files.
97
100
 
98
101
  Rules:
99
102
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ts_schema_spec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vernon Coffey