Skip to content

Commit

Permalink
Use gherkin 0.9 for i18n support
Browse files Browse the repository at this point in the history
  • Loading branch information
bbqsrc committed Jan 30, 2021
1 parent 31ffa1e commit 13a28e7
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 10 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "cucumber_rust"
version = "0.8.0"
version = "0.8.1"
edition = "2018"
authors = ["Brendan Molloy <brendan@bbqsrc.net>"]
description = "Cucumber testing framework for Rust, with async support. Fully native, no external test runners or dependencies."
Expand All @@ -18,7 +18,7 @@ macros = ["cucumber_rust_codegen", "inventory"]
[dependencies]
cucumber_rust_codegen = { version = "0.1", path = "./codegen", optional = true }

gherkin = { package = "gherkin_rust", version = "0.8.3" }
gherkin = { package = "gherkin_rust", version = "0.9" }

async-stream = "0.3.0"
async-trait = "0.1.40"
Expand Down
17 changes: 16 additions & 1 deletion src/cucumber.rs
Expand Up @@ -7,6 +7,7 @@
// except according to those terms.

use futures::StreamExt;
use gherkin::ParseFileError;
use regex::Regex;

use crate::steps::Steps;
Expand Down Expand Up @@ -97,7 +98,21 @@ impl<W: World> Cucumber<W> {
.map(|entry| gherkin::Feature::parse_path(entry.path()))
.collect::<Result<Vec<_>, _>>();

let mut features = features.unwrap_or_else(|e| panic!(e));
let mut features = features.unwrap_or_else(|e| match e {
ParseFileError::Reading { path, source } => {
eprintln!("Error reading '{}':", path.display());
eprintln!("{:?}", source);
std::process::exit(1);
}
ParseFileError::Parsing { path, error, source } => {
eprintln!("Error parsing '{}':", path.display());
if let Some(error) = error {
eprintln!("{}", error);
}
eprintln!("{:?}", source);
std::process::exit(1);
}
});
features.sort();

self.features = features;
Expand Down
2 changes: 1 addition & 1 deletion src/examples.rs
Expand Up @@ -52,7 +52,7 @@ impl ExampleValues {
modified
}

pub fn as_string(&self) -> String {
pub fn to_string(&self) -> String {
let mut values = Vec::with_capacity(self.keys.len());
for index in 0..self.keys.len() {
values.push(format!(
Expand Down
13 changes: 7 additions & 6 deletions src/output/default.rs
Expand Up @@ -183,7 +183,7 @@ impl BasicOutput {
) {
let cmt = self.file_line_col(feature.path.as_ref(), step.position);
let msg = if is_bg {
format!("(Background) {}", &step)
format!("⛓️ {}", &step)
} else {
step.to_string()
};
Expand Down Expand Up @@ -350,12 +350,13 @@ impl BasicOutput {
ScenarioEvent::Starting(example_values) => {
let cmt = self.file_line_col(feature.path.as_ref(), scenario.position);
let text = if example_values.is_empty() {
format!("Scenario: {} ", &scenario.name)
format!("{}: {} ", &scenario.keyword, &scenario.name)
} else {
format!(
"Scenario: {}\nUsing example: {}",
"{}: {}\n => {}",
&scenario.keyword,
&scenario.name,
&example_values.as_string(),
example_values.to_string(),
)
};
let indent = if rule.is_some() { " " } else { " " };
Expand All @@ -377,7 +378,7 @@ impl BasicOutput {
} else if *event == RuleEvent::Starting {
let cmt = self.file_line_col(feature.path.as_ref(), rule.position);
self.writeln_cmt(
&format!("Rule: {}", &rule.name),
&format!("{}: {}", &rule.keyword, &rule.name),
&cmt,
" ",
termcolor::Color::White,
Expand Down Expand Up @@ -440,7 +441,7 @@ impl EventHandler for BasicOutput {
CucumberEvent::Finished(ref r) => self.print_finish(r),
CucumberEvent::Feature(feature, event) => match event {
crate::event::FeatureEvent::Starting => {
let msg = format!("Feature: {}", &feature.name);
let msg = format!("{}: {}", &feature.keyword, &feature.name);
let cmt = self.file_line_col(feature.path.as_ref(), feature.position);
self.pending_feature_print_info = Some((msg, cmt));
self.printed_feature_start = false;
Expand Down
1 change: 1 addition & 0 deletions tests/integration_test.rs
Expand Up @@ -123,6 +123,7 @@ fn user_defined_event_handlers_are_expressible() {
let results = futures::executor::block_on(runner.run());

assert_eq!(results.features.total, 1);
assert_eq!(results.scenarios.total, 4);
assert_eq!(results.steps.total, 14);
assert_eq!(results.steps.passed, 4);
assert_eq!(results.scenarios.failed, 1);
Expand Down

0 comments on commit 13a28e7

Please sign in to comment.