Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mock an entire module #12

Open
nrxus opened this issue Jan 1, 2020 · 0 comments
Open

Mock an entire module #12

nrxus opened this issue Jan 1, 2020 · 0 comments

Comments

@nrxus
Copy link
Owner

nrxus commented Jan 1, 2020

Ideally something like this would work

// imagine this is the start of a module
#![faux::mock]

struct Foo {}

impl Foo {}

/* more structs and impls here */

Unfortunately custom inner attributes are not supported

I would also be okay with

#[faux::mock]
mod foo; // mocks all of foo.rs

But this currently returns a ModItem with no body.

The alternative is:

// inside foo.rs
#[faux::mock]
mod inner_foo {
  struct Foo {}

  impl Foo {}
}

pub use inner_foo::*;

There is a clear ergonomic hit to this latter approach though. I would very much dislike foricng the user to write this kind of code just to support faux. This makes me unsure if a mod-level macro would be that useful until either option 1 or 2 are allowed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant