-
Notifications
You must be signed in to change notification settings - Fork 71
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
Support for attachments #256
Comments
@laughingbiscuit thanks for proposal. @ilslv would be nice to have this feature. Both It's also not obvious how images are rendered to console. Needs some further investigation. |
@tyranron to be able to call // From this
#[given("step")]
fn step(w: &mut World, step: Step) {}
// Or this
#[given("step")]
fn step(w: &mut World, #[step] s: Step) {}
// To this
#[given("step")]
fn step(w: &mut World, Context(step): Context<Step>) {} This is extendable, future-proof solution, that even will allow us to add user provided context, if we want to. Also specifying only #[given(regex = "from (\\S+) to (\\S+)(?:(?:,| and) (\\S+))?(?:(?:,| and) (\\S+))?")]
fn step(w: &mut World, from: String, to: Vec<String>) {}
// impl FromStr ^^^^^^ ^^^^^^^^^^^ impl FromIterator<Item = impl FromStr> |
Yeah, this is definitely to have, but is a separate topic.
Could you sketch how it should look with
Actually, I don't understand, doesn't the Maybe we could wire |
#[given("...")]
fn step(w: &mut World, cucumber::Extract(context): cucumber::Extract(cucumber::Context)) {
context.attach(...)
}
I meant global user-provided context. For now docs are saying that it's not responsibility of this crate, but this may be changed in the future.
Basically, we need a way to get |
Also we should provide |
@ilslv I'm still quite confused with the notion of If we look at JS implementation, it has In our case, the #[derive(Deref)]
struct Context<T> {
#[deref]
inner: T,
// attachments and whatever
} This way, we can add our #[given("step")]
fn step(w: &mut World, scenario: Context<Scenario>) {
scenario.attach();
scenario.steps; // accessible via `Deref`
} Or maybe it's worth to attach the context to the #[given("step")]
fn step(w: &mut Context<World>, scenario: Context<Scenario>) {
w.attach();
} Seem much more reasonable regarding What do you think on that? |
I don't like the idea of making
But I understand and partially agree with point made here. The solution I see is to make our contexts hierarchical: user-defined We have 3 ways of implementing it:
All in all my proposal moving forward is following: replace |
@ilslv if we make a Sounds reasonable. The only thing that feels strange here is the mutability question. As for now, |
I don't quite understand this point. The way I see it, |
Looking through the docs, I cant see an attach dunction like in cucumber jvm/js/rb. The purpose would be to attach images or assets to the cucumber json result for display in a report.
Any thoughts?
https://github.com/cucumber/cucumber-js/blob/main/docs/support_files/attachments.md
https://javadoc.io/static/io.cucumber/cucumber-java8/6.9.1/io/cucumber/java8/Scenario.html#attach(byte%5B%5D,java.lang.String,java.lang.String)
The text was updated successfully, but these errors were encountered: