From 4423f25089c71b43192936e00afbaa99f7fa6c57 Mon Sep 17 00:00:00 2001 From: Reese Williams Date: Sun, 12 Feb 2023 11:19:13 -0600 Subject: [PATCH] Allow `test` to be an unparenthesized method --- fixtures/small/rspec_its_actual.rb | 4 ++++ fixtures/small/rspec_its_expected.rb | 4 ++++ librubyfmt/src/format.rs | 4 ++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/fixtures/small/rspec_its_actual.rb b/fixtures/small/rspec_its_actual.rb index c34b18cc..2b4cc143 100644 --- a/fixtures/small/rspec_its_actual.rb +++ b/fixtures/small/rspec_its_actual.rb @@ -39,6 +39,10 @@ opinion: "please don't name your DSL 'describe', but a little too late now I guess" do end +test "some really good test name" do + assert(true) +end + RSpec.describe "bees" do end diff --git a/fixtures/small/rspec_its_expected.rb b/fixtures/small/rspec_its_expected.rb index 658f0246..8e5c69a7 100644 --- a/fixtures/small/rspec_its_expected.rb +++ b/fixtures/small/rspec_its_expected.rb @@ -43,6 +43,10 @@ ) do end +test "some really good test name" do + assert(true) +end + RSpec.describe "bees" do end diff --git a/librubyfmt/src/format.rs b/librubyfmt/src/format.rs index 8cf9f7e4..57185ea2 100644 --- a/librubyfmt/src/format.rs +++ b/librubyfmt/src/format.rs @@ -696,7 +696,7 @@ pub fn args_has_single_def_expression(args: &ArgsAddStarOrExpressionListOrArgsFo } lazy_static! { - static ref RSPEC_METHODS: HashSet<&'static str> = vec!["it", "describe"].into_iter().collect(); + static ref TEST_METHODS: HashSet<&'static str> = vec!["it", "describe", "test"].into_iter().collect(); static ref GEMFILE_METHODS: HashSet<&'static str> = vec![ // Gemfile "gem", @@ -2762,7 +2762,7 @@ fn can_elide_parens_for_reserved_names(cc: &[CallChainElement]) -> bool { Ident(_, ident, _), ))) => { let ident = ident.as_str(); - RSPEC_METHODS.contains(ident) || GEMFILE_METHODS.contains(ident) + TEST_METHODS.contains(ident) || GEMFILE_METHODS.contains(ident) } _ => false, };