Skip to content

Commit 8fbef18

Browse files
authored
Fix docs (#261)
1 parent c113386 commit 8fbef18

File tree

2 files changed

+36
-8
lines changed
  • core/src/integration/kotlin/io/github/serpro69/kfaker/docs
  • docs/src/orchid/resources/wiki

2 files changed

+36
-8
lines changed

core/src/integration/kotlin/io/github/serpro69/kfaker/docs/Extras.kt

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -273,19 +273,29 @@ class Extras : DescribeSpec({
273273
)
274274
// END extras_random_instance_nineteen
275275

276-
it("should use defaults") {
276+
it("should use random values") {
277277
// START extras_random_instance_twenty
278+
val testClass: TestClass = Faker().randomClass.randomClassInstance()
279+
assertNotEquals(Int.MIN_VALUE, testClass.iMin)
280+
assertNotEquals(Int.MAX_VALUE, testClass.iMax)
281+
assertNotEquals("sometimes a string... is just a string", testClass.s)
282+
assertNotEquals(369, testClass.foo.i)
283+
// END extras_random_instance_twenty
284+
}
285+
286+
it("should use defaults") {
287+
// START extras_random_instance_twenty_one
278288
val testClass: TestClass = Faker().randomClass.randomClassInstance {
279289
defaultValuesStrategy = USE_DEFAULTS
280290
}
281291
assertEquals(Int.MIN_VALUE, testClass.iMin)
282292
assertEquals(Int.MAX_VALUE, testClass.iMax)
283293
assertEquals("sometimes a string... is just a string", testClass.s)
284294
assertEquals(369, testClass.foo.i)
285-
// END extras_random_instance_twenty
295+
// END extras_random_instance_twenty_one
286296
}
287297

288-
// START extras_random_instance_twenty_one
298+
// START extras_random_instance_twenty_two
289299
it("should randomly pick a default or a random value") {
290300
val testClass: TestClass = Faker().randomClass.randomClassInstance {
291301
defaultValuesStrategy = PICK_RANDOMLY
@@ -302,7 +312,7 @@ class Extras : DescribeSpec({
302312
&& testClass.s == "sometimes a string... is just a string"
303313
&& testClass.foo.i == 369
304314
))
305-
// END extras_random_instance_twenty_one
315+
// END extras_random_instance_twenty_two
306316
}
307317
}
308318

docs/src/orchid/resources/wiki/extras.md

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -376,29 +376,47 @@ The above has the following rules:
376376

377377
### Default values selection
378378

379-
By default, all parameters of a [selected constructor](#deterministic-constructor-selection) would be generated with randomized values. This behavior can be changed with `defaultValuesStrategy` configuration option.
379+
By default, all parameters of a [selected constructor](#deterministic-constructor-selection) would be generated with randomized values:
380380

381-
One can choose between generating values only for non-optional constructor parameters:
382381
{% tabs %}
383382

384383
{% kotlin "Kotlin" %}
385384
{% filter compileAs('md') %}
386385
```kotlin
387386
{% snippet 'extras_random_instance_nineteen' %}
387+
{% snippet 'extras_random_instance_twenty' %}
388388
```
389389
{% endfilter %}
390390
{% endkotlin %}
391391

392392
{% endtabs %}
393393

394-
or randomly choosing between picking a default value and a randomly-generated one:
394+
This behavior can be changed with `defaultValuesStrategy` configuration option.
395+
396+
One can choose between generating values only for non-optional constructor parameters:
395397

396398
{% tabs %}
397399

398400
{% kotlin "Kotlin" %}
399401
{% filter compileAs('md') %}
400402
```kotlin
401-
{% snippet 'extras_random_instance_twenty' %}
403+
{% snippet 'extras_random_instance_twenty_one' %}
404+
```
405+
{% endfilter %}
406+
{% endkotlin %}
407+
408+
{% endtabs %}
409+
410+
<br>
411+
412+
...or randomly selecting between a default value and a randomly-generated one:
413+
414+
{% tabs %}
415+
416+
{% kotlin "Kotlin" %}
417+
{% filter compileAs('md') %}
418+
```kotlin
419+
{% snippet 'extras_random_instance_twenty_two' %}
402420
```
403421
{% endfilter %}
404422
{% endkotlin %}

0 commit comments

Comments
 (0)