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

Restore before and after hooks (#141) #142

Merged
merged 10 commits into from
Oct 18, 2021
Merged

Conversation

ilslv
Copy link
Member

@ilslv ilslv commented Oct 14, 2021

Resolves #141

Synopsis

In 0.10.0 before and after hooks were removed.

Solution

Re-implement them.

Checklist

  • Created PR:
    • In draft mode
    • Name contains Draft: prefix
    • Name contains issue reference
    • Has assignee
  • Documentation is updated (if required)
  • Tests are updated (if required)
  • Changes conform code style
  • CHANGELOG entry is added (if required)
  • FCM (final commit message) is posted
    • and approved
  • Review is completed and changes are approved
  • Before merge:
    • Milestone is set
    • PR's name and description are correct and up-to-date
    • Draft: prefix is removed
    • All temporary labels are removed

This PR is nominated at RU RustCon Contest

@ilslv ilslv added the enhancement Improvement of existing features or bugfix label Oct 14, 2021
@ilslv ilslv added this to the 0.11 milestone Oct 14, 2021
@ilslv ilslv self-assigned this Oct 14, 2021
@ilslv
Copy link
Member Author

ilslv commented Oct 15, 2021

FCM

Restore before and after scenario hooks (#142, #141)

@ilslv ilslv marked this pull request as ready for review October 15, 2021 12:42
@ilslv ilslv requested a review from tyranron October 15, 2021 12:42
@ilslv ilslv modified the milestones: 0.11, 0.10 Oct 18, 2021
@tyranron tyranron changed the title Draft: Return before and after hooks (#141) Restore before and after hooks (#141) Oct 18, 2021
Copy link
Member

@tyranron tyranron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ilslv good, but please tend to do more polishing in future. There were plenty of little inconveniences.

src/event.rs Outdated
/// [`Scenario`]: gherkin::Scenario
/// [`Step`]: gherkin::Step
#[derive(Clone, Copy, Debug)]
pub enum HookTy {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In type names it's better not to use shortcuts. They're good for local variables only.

src/event.rs Outdated
Failed(Option<Arc<World>>, Info),
}

impl fmt::Display for HookTy {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, do not mix declarations and impls of different types. It's very misleading.

src/event.rs Outdated
HookTy::Before => "Before",
HookTy::After => "After",
};
write!(f, "{}", s)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can just piggyback to Debug impl here.

tests/wait.rs Outdated

let err = AssertUnwindSafe(res)
.catch_unwind()
.await
.expect_err("should err");
let err = err.downcast_ref::<String>().unwrap();

assert_eq!(err, "2 steps failed, 1 parsing error");
assert_eq!(err, "2 steps failed, 1 parsing error, 0 hook errors");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, it has little sense to write something like "0 errors has happened". We should write about errors only when they really happen.

@@ -209,6 +219,33 @@ impl Basic {
}
}

fn hook_failed<W: Debug>(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docs 😱 ???

@tyranron tyranron force-pushed the return-before-and-after-hooks branch from 0199ab6 to 3d30bee Compare October 18, 2021 11:34
@tyranron tyranron merged commit b82659e into main Oct 18, 2021
@tyranron tyranron deleted the return-before-and-after-hooks branch October 18, 2021 11:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement of existing features or bugfix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Return before and after hooks
2 participants