Skip to main content

Fixture

Struct Fixture 

Source
pub struct Fixture { /* private fields */ }
Expand description

One project, on disk, detected the way the host detects it.

The files are written into a temporary directory that lives as long as the fixture. The detection is the real one: the same scoring, the same family and plugin choice, on the markers a manifest declares – so a fixture test fails when the plugin’s own markers stop matching, which is exactly the kind of breakage a hand-built context cannot catch.

Implementations§

Source§

impl Fixture

Source

pub fn new() -> Self

An empty project.

Source

pub fn file(self, name: &str, contents: &str) -> Self

Write one file, creating its directory if it has one.

Source

pub fn plugin( self, name: &str, family: &str, strong: &[&str], weak: &[&str], ) -> Self

Declare a plugin, with the markers its manifest would carry.

Source

pub fn pin(self, family: &str, plugin: &str) -> Self

Pin a family to a plugin, as a .pmpx.toml would.

Source

pub fn prefer(self, families: &[&str]) -> Self

Order families, for the cases where two of them tie.

Source

pub fn declares<I, S>(self, names: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

The files the plugin’s manifest says it wants to see.

Only these are read into the context – the declaration is the allowlist, so a test that asks for something undeclared gets a context without it, exactly as the host would.

Source

pub fn path(&self) -> &Path

The project directory.

Source

pub fn context(&self) -> Context<'static>

Run the detection and build the context the host would hand over.

The verb and the arguments are not part of a Context: they are what the plugin is called with, so a test passes them to command itself.

§Panics

When the detection picks nothing – which in a fixture test almost always means the markers a plugin declares do not match the files the test wrote, so the panic says which files are there.

Trait Implementations§

Source§

impl Default for Fixture

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.