Sign in

    moonrockz/moonspec/core does not have a README file

    Attachable

    pub trait Attachable {
    attach(Self, String, String, file_name? : String) -> Unit
    attach_bytes(Self, Bytes, String, file_name? : String) -> Unit
    attach_url(Self, String, String) -> Unit
    pending_attachments(Self) -> Array[PendingAttachment]
    }

    Trait for any context that can buffer attachments.

    MessageSink

    pub(open) trait MessageSink {
    on_message(Self,
    Envelope
    ) -> Unit
    }

    A sink that receives cucumber-messages Envelope events during a test run.

    StepLibrary

    pub(open) trait StepLibrary {
    steps(Self) -> ArrayView[StepDef]
    }

    A composable group of step definitions.

    Implement this on structs that provide reusable step definitions. Libraries return an immutable view of their steps via ArrayView.

    World

    pub(open) trait World {
    configure(Self, Setup) -> Unit
    }

    Step registration trait. Users implement this on their world struct.

    Called once per scenario with a fresh Default-constructed instance. Closures registered via Setup capture self, sharing world state between steps within the same scenario. Since MoonBit structs are reference types, mutations through closures are visible to all step handlers.

    Example:
    struct MyWorld { mut count : Int } derive(Default) impl @moonspec.World for MyWorld with configure(self, s) { s.given("a count of {int}", fn(ctx) { match ctx[0] { { value: IntVal(n), .. } => self.count = n; _ => () } }) }

    MoonspecError

    pub suberror MoonspecError {
    UndefinedStep(String, String, String, Array[String])
    PendingStep(String, String, String)
    StepFailed(String, String, String)
    ScenarioFailed(String, String, Array[MoonspecError])
    RunFailed(String, Array[MoonspecError])
    }

    Structured error hierarchy for moonspec.

    Step-level errors aggregate into ScenarioFailed, which aggregates into RunFailed. This enables rich diagnostics and the run_or_fail! API.

    CaseHookCtx

    pub(all) struct CaseHookCtx {
    // private fields
    }

    Hook context for test case-level hooks (before/after_test_case).

    CaseHookCtx::attach

    fn CaseHookCtx::attach(self : CaseHookCtx, body : String, media_type : String, file_name? : String) -> Unit

    CaseHookCtx::attach_bytes

    fn CaseHookCtx::attach_bytes(self : CaseHookCtx, data : Bytes, media_type : String, file_name? : String) -> Unit

    CaseHookCtx::attach_url

    fn CaseHookCtx::attach_url(self : CaseHookCtx, url : String, media_type : String) -> Unit

    CaseHookCtx::new

    fn CaseHookCtx::new(scenario : ScenarioInfo) -> CaseHookCtx

    CaseHookCtx::pending_attachments

    fn CaseHookCtx::pending_attachments(self : CaseHookCtx) -> Array[PendingAttachment]

    CaseHookCtx::scenario

    fn CaseHookCtx::scenario(self : CaseHookCtx) -> ScenarioInfo

    Cells

    pub struct Cells {
    // private fields

    fn new(data : Array[String]) -> Cells
    }

    Immutable wrapper around an array of cell values in a DataTable row.
    impl Eq for Cells
    impl Show for Cells

    Cells::get

    fn Cells::get(self : Cells, index : Int) -> String

    Cells::length

    fn Cells::length(self : Cells) -> Int

    Cells::values

    fn Cells::values(self : Cells) -> ArrayView[String]

    Column

    pub(all) struct Column {
    name : String
    index : Int

    fn new(name~ : String, index~ : Int) -> Column
    }

    A named column in a DataTable, derived from the header row.
    impl Eq for Column
    impl Show for Column

    Columns

    pub struct Columns {
    // private fields

    fn new(data : Array[Column]) -> Columns
    }

    Immutable wrapper around an array of columns in a DataTable.
    impl Eq for Columns
    impl Show for Columns

    Columns::find

    fn Columns::find(self : Columns, name : String) -> Column?

    Columns::get

    fn Columns::get(self : Columns, index : Int) -> Column

    Columns::length

    fn Columns::length(self : Columns) -> Int

    Columns::values

    fn Columns::values(self : Columns) -> ArrayView[Column]

    CompiledStep

    type CompiledStep

    Internal: a compiled step entry pairing a StepDef with its parsed expression.

    Ctx

    pub(all) struct Ctx {
    // private fields
    }

    Step execution context. Wraps matched arguments with scenario/step metadata and an attachment buffer.

    Ctx::arg

    fn Ctx::arg(self : Ctx, index : Int) -> StepArg

    Explicit index access to a step argument.

    Ctx::args

    fn Ctx::args(self : Ctx) -> ArrayView[StepArg]

    View of all step arguments.

    Ctx::attach

    fn Ctx::attach(self : Ctx, body : String, media_type : String, file_name? : String) -> Unit

    Attach text content to the current step/hook.

    Ctx::attach_bytes

    fn Ctx::attach_bytes(self : Ctx, data : Bytes, media_type : String, file_name? : String) -> Unit

    Attach binary content (Base64 encoded) to the current step/hook.

    Ctx::attach_url

    fn Ctx::attach_url(self : Ctx, url : String, media_type : String) -> Unit

    Attach an external URL reference to the current step/hook.

    Ctx::new

    fn Ctx::new(args : Array[StepArg], scenario : ScenarioInfo, step : StepInfo) -> Ctx

    Create a new Ctx.

    Ctx::op_get

    fn Ctx::op_get(self : Ctx, index : Int) -> StepArg

    Index access to step arguments.

    Ctx::pending_attachments

    fn Ctx::pending_attachments(self : Ctx) -> Array[PendingAttachment]

    Access buffered attachments (for executor draining).

    Ctx::scenario

    fn Ctx::scenario(self : Ctx) -> ScenarioInfo

    Scenario metadata (feature name, scenario name, tags).

    Ctx::step

    fn Ctx::step(self : Ctx) -> StepInfo

    Step metadata (keyword, text).

    Ctx::value

    fn Ctx::value(self : Ctx, index : Int) -> StepValue

    Convenience accessor: returns the StepValue at the given argument index.

    CustomParamTypeInfo

    pub(all) struct CustomParamTypeInfo {
    name : String
    patterns : Array[String]
    }

    Info about a custom parameter type, for envelope emission.

    DataTable

    pub(all) struct DataTable {
    rows : Rows
    columns : Columns

    fn new(raw_rows : Array[Array[String]]) -> DataTable
    }

    A DataTable from a Gherkin step. First row is treated as column headers.
    impl Eq for DataTable
    impl Show for DataTable

    DataTable::as_maps

    fn DataTable::as_maps(self : DataTable) -> Array[Map[String, String]]

    DataTable::col_count

    fn DataTable::col_count(self : DataTable) -> Int

    DataTable::from_rows

    fn DataTable::from_rows(raw_rows : Array[Array[String]]) -> DataTable

    Construct a DataTable from raw row data (public factory).

    DataTable::row_count

    fn DataTable::row_count(self : DataTable) -> Int

    DocString

    pub(all) struct DocString {
    content : String
    media_type : String?

    fn new(content~ : String, media_type? : String) -> DocString
    }

    A DocString from a Gherkin step — multi-line text with optional media type.
    impl Eq for DocString
    impl Show for DocString

    HookError

    pub(all) enum HookError {
    StepFailed(String, StepKeyword, String)
    ScenarioFailed(String, String, String)
    }

    Structured error reported to after-hooks.
    impl Eq for HookError
    impl Show for HookError

    HookHandler

    pub(all) enum HookHandler {
    RunHandler((RunHookCtx) -> Unit raise)
    RunAfterHandler((RunHookCtx, HookResult) -> Unit raise)
    CaseHandler((CaseHookCtx) -> Unit raise)
    CaseAfterHandler((CaseHookCtx, HookResult) -> Unit raise)
    StepHandler((StepHookCtx) -> Unit raise)
    StepAfterHandler((StepHookCtx, HookResult) -> Unit raise)
    }

    Typed handler for different hook scopes.

    HookRegistry

    pub(all) struct HookRegistry {
    // private fields
    }

    Registry of lifecycle hooks with auto-incrementing IDs.

    HookRegistry::add

    fn HookRegistry::add(self : HookRegistry, type_ : HookType, handler : HookHandler, source? : StepSource?) -> Unit

    Register a hook with the given type, handler, and optional source location.

    HookRegistry::by_type

    fn HookRegistry::by_type(self : HookRegistry, type_ : HookType) -> Array[RegisteredHook]

    Return all registered hooks matching the given type.

    HookRegistry::hooks

    Return all registered hooks as a read-only ArrayView.

    HookRegistry::new

    Create an empty hook registry.

    HookResult

    pub(all) enum HookResult {
    Passed
    Failed(Array[HookError])
    }

    Result passed to after-hooks indicating pass/fail with structured errors.
    impl Eq for HookResult
    impl Show for HookResult

    HookType

    pub(all) enum HookType {
    BeforeTestRun
    AfterTestRun
    BeforeTestCase
    AfterTestCase
    BeforeTestStep
    AfterTestStep
    }

    The six Cucumber lifecycle hook types.
    impl Eq for HookType
    impl Show for HookType

    PendingAttachment

    pub(all) enum PendingAttachment {
    Embedded(String,
    AttachmentContentEncoding
    , String, String?)
    External(String, String)
    }

    A buffered attachment waiting to be emitted as an envelope.

    RegisteredHook

    pub(all) struct RegisteredHook {
    id : String
    type_ : HookType
    handler : HookHandler
    source : StepSource?
    }

    A registered hook entry with id, type, handler, and source location.

    Row

    pub(all) struct Row {
    cells : Cells

    fn new(cells : Array[String]) -> Row
    }

    A single row in a DataTable, wrapping its cell values in an immutable Cells.
    impl Eq for Row
    impl Show for Row

    Rows

    pub struct Rows {
    // private fields

    fn new(data : Array[Row]) -> Rows
    }

    Immutable wrapper around an array of rows in a DataTable.
    impl Eq for Rows
    impl Show for Rows

    Rows::get

    fn Rows::get(self : Rows, index : Int) -> Row

    Rows::length

    fn Rows::length(self : Rows) -> Int

    Rows::values

    fn Rows::values(self : Rows) -> ArrayView[Row]

    RunHookCtx

    pub(all) struct RunHookCtx {
    // private fields
    }

    Hook context for test run-level hooks (before/after_test_run).

    RunHookCtx::attach

    fn RunHookCtx::attach(self : RunHookCtx, body : String, media_type : String, file_name? : String) -> Unit

    RunHookCtx::attach_bytes

    fn RunHookCtx::attach_bytes(self : RunHookCtx, data : Bytes, media_type : String, file_name? : String) -> Unit

    RunHookCtx::attach_url

    fn RunHookCtx::attach_url(self : RunHookCtx, url : String, media_type : String) -> Unit

    RunHookCtx::new

    fn RunHookCtx::new() -> RunHookCtx

    RunHookCtx::pending_attachments

    fn RunHookCtx::pending_attachments(self : RunHookCtx) -> Array[PendingAttachment]

    ScenarioInfo

    pub(all) struct ScenarioInfo {
    feature_name : String
    scenario_name : String
    tags : Array[String]
    }

    Information about a scenario being executed.
    impl Eq for ScenarioInfo

    Setup

    pub(all) struct Setup {
    // private fields
    }

    User-facing configuration facade for registering steps and parameter types. Wraps StepRegistry and ParamTypeRegistry as siblings.

    Setup::add_param_type

    Register a custom parameter type with name and regex patterns. An optional transformer converts matched text into a typed ParamValue.

    Setup::add_param_type_strings

    fn Setup::add_param_type_strings(self : Setup, name : String, patterns : Array[String], transformer? :
    Transformer
    ) -> Unit

    Register a custom parameter type with name and string regex patterns. Convenience method that avoids requiring callers to import cucumber-expressions. An optional transformer converts matched text into a typed ParamValue.

    Setup::after_test_case

    #callsite(autofill(loc))
    fn Setup::after_test_case(self : Setup, handler : (CaseHookCtx, HookResult) -> Unit raise, loc~ : SourceLoc) -> Unit

    Register a hook to run after each test case (scenario).

    Setup::after_test_run

    #callsite(autofill(loc))
    fn Setup::after_test_run(self : Setup, handler : (RunHookCtx, HookResult) -> Unit raise, loc~ : SourceLoc) -> Unit

    Register a hook to run after the entire test run.

    Setup::after_test_step

    #callsite(autofill(loc))
    fn Setup::after_test_step(self : Setup, handler : (StepHookCtx, HookResult) -> Unit raise, loc~ : SourceLoc) -> Unit

    Register a hook to run after each test step.

    Setup::before_test_case

    #callsite(autofill(loc))
    fn Setup::before_test_case(self : Setup, handler : (CaseHookCtx) -> Unit raise, loc~ : SourceLoc) -> Unit

    Register a hook to run before each test case (scenario).

    Setup::before_test_run

    #callsite(autofill(loc))
    fn Setup::before_test_run(self : Setup, handler : (RunHookCtx) -> Unit raise, loc~ : SourceLoc) -> Unit

    Register a hook to run before the entire test run.

    Setup::before_test_step

    #callsite(autofill(loc))
    fn Setup::before_test_step(self : Setup, handler : (StepHookCtx) -> Unit raise, loc~ : SourceLoc) -> Unit

    Register a hook to run before each test step.

    Setup::custom_param_types

    fn Setup::custom_param_types(self : Setup) -> Array[CustomParamTypeInfo]

    Return custom (non-built-in) parameter types for envelope emission. Built-in types (int, float, string, word, anonymous "") are excluded.

    Setup::given

    fn Setup::given(self : Setup, pattern : String, handler : (Ctx) -> Unit raise) -> Unit

    Register a Given step.

    Setup::hook_registry

    fn Setup::hook_registry(self : Setup) -> HookRegistry

    Access the underlying hook registry (for runner internals).

    Setup::new

    fn Setup::new() -> Setup

    Setup::param_registry

    Access the underlying param type registry (for runner internals).

    Setup::step

    fn Setup::step(self : Setup, pattern : String, handler : (Ctx) -> Unit raise) -> Unit

    Register a step that matches any keyword.

    Setup::step_registry

    fn Setup::step_registry(self : Setup) -> StepRegistry

    Access the underlying step registry (for runner internals).

    Setup::then

    fn Setup::then(self : Setup, pattern : String, handler : (Ctx) -> Unit raise) -> Unit

    Register a Then step.

    Setup::use_library

    fn[L : StepLibrary] Setup::use_library(self : Setup, library : L) -> Unit

    Compose a StepLibrary into this setup's registry.

    Setup::when

    fn Setup::when(self : Setup, pattern : String, handler : (Ctx) -> Unit raise) -> Unit

    Register a When step.

    StepArg

    pub(all) struct StepArg {
    value : StepValue
    raw : String
    }

    A step argument carrying both the typed value and the original matched text.
    impl Eq for StepArg
    impl Show for StepArg

    StepArg::from_param

    Convert a cucumber-expressions Param to a StepArg.

    StepDef

    pub(all) struct StepDef {
    keyword : StepKeyword
    pattern : String
    handler : StepHandler
    source : StepSource?
    id : StepDefId?
    }

    A first-class step definition: keyword, pattern, handler, and optional source.

    StepDef::given

    fn StepDef::given(pattern : String, handler : (Ctx) -> Unit raise, source? : StepSource) -> StepDef

    StepDef::step

    fn StepDef::step(pattern : String, handler : (Ctx) -> Unit raise, source? : StepSource) -> StepDef

    StepDef::then

    fn StepDef::then(pattern : String, handler : (Ctx) -> Unit raise, source? : StepSource) -> StepDef

    StepDef::when

    fn StepDef::when(pattern : String, handler : (Ctx) -> Unit raise, source? : StepSource) -> StepDef

    StepDefId

    pub(all) struct StepDefId {
    // private fields

    fn new(value : String) -> StepDefId
    }

    A unique identifier for a step definition, assigned by the StepRegistry.
    impl Eq for StepDefId
    impl Hash for StepDefId
    impl Show for StepDefId

    StepDefId::to_string

    fn StepDefId::to_string(self : StepDefId) -> String

    StepHandler

    pub type StepHandler (Ctx) -> Unit raise

    A step handler function that receives extracted arguments.

    StepHandler::inner

    #deprecated("Use `struct T(A)` to declare a newtype and use `.0` access the underlying type instead.")
    fn StepHandler::inner(self : StepHandler) -> ((Ctx) -> Unit raise)
    Convert newtype to its underlying type, automatically derived.

    StepHookCtx

    pub(all) struct StepHookCtx {
    // private fields
    }

    Hook context for test step-level hooks (before/after_test_step).

    StepHookCtx::attach

    fn StepHookCtx::attach(self : StepHookCtx, body : String, media_type : String, file_name? : String) -> Unit

    StepHookCtx::attach_bytes

    fn StepHookCtx::attach_bytes(self : StepHookCtx, data : Bytes, media_type : String, file_name? : String) -> Unit

    StepHookCtx::attach_url

    fn StepHookCtx::attach_url(self : StepHookCtx, url : String, media_type : String) -> Unit

    StepHookCtx::new

    fn StepHookCtx::new(scenario : ScenarioInfo, step : StepInfo) -> StepHookCtx

    StepHookCtx::pending_attachments

    fn StepHookCtx::pending_attachments(self : StepHookCtx) -> Array[PendingAttachment]

    StepHookCtx::scenario

    fn StepHookCtx::scenario(self : StepHookCtx) -> ScenarioInfo

    StepHookCtx::step

    fn StepHookCtx::step(self : StepHookCtx) -> StepInfo

    StepInfo

    pub(all) struct StepInfo {
    keyword : String
    text : String
    }

    Information about a step being executed.
    impl Eq for StepInfo
    impl Show for StepInfo

    StepKeyword

    pub(all) enum StepKeyword {
    Given
    When
    Then
    Step
    }

    Keyword classification for a step definition.
    impl Eq for StepKeyword
    impl Show for StepKeyword

    StepMatchResult

    pub(all) enum StepMatchResult {
    Matched(StepDef, Array[StepArg])
    Undefined(String, String, String, Array[String])
    }

    Result of matching step text against the registry.

    StepRegistry

    pub(all) struct StepRegistry {
    // private fields
    }

    Registry of step definitions keyed by Cucumber Expression patterns.

    StepRegistry::find_match

    fn StepRegistry::find_match(self : StepRegistry, text : String, keyword? : String) -> StepMatchResult

    Find a matching step definition for the given step text. Returns Matched with StepDef + extracted args, or Undefined with diagnostics.

    StepRegistry::len

    fn StepRegistry::len(self : StepRegistry) -> Int

    Number of registered step definitions.

    StepRegistry::new

    Create an empty step registry.

    StepRegistry::register_def

    fn StepRegistry::register_def(self : StepRegistry, step_def : StepDef, param_registry :
    ParamTypeRegistry
    ) -> Unit

    Register a StepDef directly, using the given param registry for expression parsing.

    StepRegistry::step_defs

    fn StepRegistry::step_defs(self : StepRegistry) -> Array[StepDef]

    Return all registered step definitions.

    StepRegistry::use_library

    fn[L : StepLibrary] StepRegistry::use_library(self : StepRegistry, library : L, param_registry :
    ParamTypeRegistry
    ) -> Unit

    Compose a StepLibrary into this registry using the given param registry.

    StepSource

    pub(all) struct StepSource {
    uri : String?
    line : Int?
    }

    Optional source location for a step definition (populated by codegen).
    impl Eq for StepSource
    impl Show for StepSource

    StepSource::new

    fn StepSource::new(uri? : String, line? : Int) -> StepSource

    StepValue

    pub(all) enum StepValue {
    IntVal(Int)
    FloatVal(Double)
    DoubleVal(Double)
    LongVal(Int64)
    ByteVal(Byte)
    ShortVal(Int)
    StringVal(String)
    WordVal(String)
    AnonymousVal(String)
    BigDecimalVal(
    Decimal
    )
    BigIntegerVal(
    BigInt
    )
    CustomVal(
    Any
    )
    DocStringVal(DocString)
    DataTableVal(DataTable)
    }

    A typed value extracted from step text, pattern-matchable for built-in types.

    pending_step_error

    fn pending_step_error(step~ : String, keyword~ : String, message~ : String) -> Error

    Create a PendingStep error.

    run_failed_error

    fn run_failed_error(summary~ : String, errors~ : Array[MoonspecError]) -> Error

    Create a RunFailed error.

    scenario_failed_error

    fn scenario_failed_error(scenario~ : String, feature~ : String, errors~ : Array[MoonspecError]) -> MoonspecError

    Create a ScenarioFailed error.

    step_failed_error

    fn step_failed_error(step~ : String, keyword~ : String, message~ : String) -> Error

    Create a StepFailed error.

    undefined_step_error

    fn undefined_step_error(step~ : String, keyword~ : String, snippet~ : String, suggestions~ : Array[String]) -> Error

    Create an UndefinedStep error.