2021-07-17 20:01:27 +00:00
|
|
|
require "./example"
|
|
|
|
require "./location"
|
|
|
|
require "./metadata"
|
2021-07-17 17:10:44 +00:00
|
|
|
require "./node_builder"
|
|
|
|
|
|
|
|
module Spectator
|
2021-07-17 20:01:27 +00:00
|
|
|
# Constructs pending examples.
|
|
|
|
# Call `#build` to produce an `Example`.
|
2021-07-17 17:10:44 +00:00
|
|
|
class PendingExampleBuilder < NodeBuilder
|
2021-07-17 20:01:27 +00:00
|
|
|
# Creates the builder.
|
|
|
|
# The *name*, *location*, and *metadata* will be applied to the `Example` produced by `#build`.
|
2021-07-17 20:04:17 +00:00
|
|
|
# A default *reason* can be given in case the user didn't provide one.
|
|
|
|
def initialize(@name : String? = nil, @location : Location? = nil,
|
2022-11-30 06:22:42 +00:00
|
|
|
@metadata : Metadata? = nil, @reason : String? = nil)
|
2021-07-17 17:10:44 +00:00
|
|
|
end
|
|
|
|
|
2021-07-17 20:01:27 +00:00
|
|
|
# Constructs an example with previously defined attributes.
|
|
|
|
# The *parent* is an already constructed example group to nest the new example under.
|
|
|
|
# It can be nil if the new example won't have a parent.
|
|
|
|
def build(parent = nil)
|
2021-07-17 20:04:17 +00:00
|
|
|
Example.pending(@name, @location, parent, @metadata, @reason)
|
2021-07-17 17:10:44 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|