Sign in

    moonrockz/moonspec/core does not have a README file

    Hooks

    pub(open) trait Hooks {
    before_scenario(Self, ScenarioInfo) -> Unit raise = _
    after_scenario(Self, ScenarioInfo, String?) -> Unit raise = _
    before_step(Self, StepInfo) -> Unit raise = _
    after_step(Self, StepInfo, String?) -> Unit raise = _
    }

    Lifecycle hooks for scenario execution.

    All methods have default no-op implementations. Users optionally implement this on their world struct for setup/teardown logic.

    The String? result parameter is None for success, Some(message) for failure.

    World

    pub(open) trait World {
    register_steps(Self, StepRegistry) -> Unit
    }

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

    Called once per scenario with a fresh Default-constructed instance. Closures registered via StepRegistry 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 register_steps(self, s) { s.given("a count of {int}", fn(args) { match args[0] { @moonspec.IntArg(n) => self.count = n | _ => () } }) }

    ScenarioInfo

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

    Information about a scenario being executed.
    impl Eq for ScenarioInfo

    StepArg

    pub(all) enum StepArg {
    IntArg(Int)
    FloatArg(Double)
    StringArg(String)
    WordArg(String)
    CustomArg(String)
    }

    A typed step argument extracted from step text via Cucumber Expressions.
    impl Eq for StepArg
    impl Show for StepArg

    StepArg::from_param

    Convert a cucumber-expressions Param to a typed StepArg.

    StepEntry

    type StepEntry

    A registered step definition: compiled expression + handler.

    StepHandler

    pub type StepHandler (Array[StepArg]) -> 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) -> ((Array[StepArg]) -> Unit raise)
    Convert newtype to its underlying type, automatically derived.

    StepInfo

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

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

    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) -> (StepHandler, Array[StepArg], String)?

    Find a matching step definition for the given step text. Returns (handler, extracted_args, expression_source) or None.

    StepRegistry::given

    fn StepRegistry::given(self : StepRegistry, pattern : String, handler : (Array[StepArg]) -> Unit raise) -> Unit

    Register a Given step.

    StepRegistry::len

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

    Number of registered step definitions.

    StepRegistry::new

    Create an empty step registry with default parameter types.

    StepRegistry::step

    fn StepRegistry::step(self : StepRegistry, pattern : String, handler : (Array[StepArg]) -> Unit raise) -> Unit

    Register a step that matches any keyword.

    StepRegistry::then

    fn StepRegistry::then(self : StepRegistry, pattern : String, handler : (Array[StepArg]) -> Unit raise) -> Unit

    Register a Then step.

    StepRegistry::when

    fn StepRegistry::when(self : StepRegistry, pattern : String, handler : (Array[StepArg]) -> Unit raise) -> Unit

    Register a When step.

    core_version

    fn core_version() -> String

    moonspec core — World, Steps, and Hooks traits.