Skip to content

Commit e67f16f

Browse files
committed
fix tests
1 parent 19259ec commit e67f16f

File tree

4 files changed

+49
-47
lines changed

4 files changed

+49
-47
lines changed

.generator/conftest.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@
2020

2121

2222
MODIFIED_FEATURES = {pathlib.Path(p).resolve() for p in os.getenv("BDD_MODIFIED_FEATURES", "").split(" ") if p}
23-
2423
ROOT_PATH = pathlib.Path(__file__).parent.parent
25-
26-
2724
PATTERN_ALPHANUM = re.compile(r"[^A-Za-z0-9]+")
2825

2926

.generator/src/generator/formatter.py

Lines changed: 2 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -5,49 +5,8 @@
55
from functools import singledispatch
66

77

8-
KEYWORDS = {
9-
"__FILE__",
10-
"and",
11-
"def",
12-
"end",
13-
"in",
14-
"or",
15-
"self",
16-
"unless",
17-
"__LINE__",
18-
"begin",
19-
"defined?",
20-
"ensure",
21-
"module",
22-
"redo",
23-
"super",
24-
"until",
25-
"BEGIN",
26-
"break",
27-
"do",
28-
"false",
29-
"next",
30-
"rescue",
31-
"then",
32-
"when",
33-
"END",
34-
"case",
35-
"else",
36-
"for",
37-
"nil",
38-
"retry",
39-
"true",
40-
"while",
41-
"alias",
42-
"class",
43-
"elsif",
44-
"if",
45-
"not",
46-
"return",
47-
"undef",
48-
"yield",
49-
"hash",
50-
}
8+
with (pathlib.Path(__file__).parent / "keywords.json").open() as f:
9+
KEYWORDS = json.load(f)
5110

5211
with (pathlib.Path(__file__).parent / "replacement.json").open() as f:
5312
EDGE_CASES = json.load(f)
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
[
2+
"__FILE__",
3+
"and",
4+
"def",
5+
"end",
6+
"in",
7+
"or",
8+
"self",
9+
"unless",
10+
"__LINE__",
11+
"begin",
12+
"defined?",
13+
"ensure",
14+
"module",
15+
"redo",
16+
"super",
17+
"until",
18+
"BEGIN",
19+
"break",
20+
"do",
21+
"false",
22+
"next",
23+
"rescue",
24+
"then",
25+
"when",
26+
"END",
27+
"case",
28+
"else",
29+
"for",
30+
"nil",
31+
"retry",
32+
"true",
33+
"while",
34+
"alias",
35+
"class",
36+
"elsif",
37+
"if",
38+
"not",
39+
"return",
40+
"undef",
41+
"yield",
42+
"hash"
43+
]

features/support/templating.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
require 'json'
22

3+
KEYWORDS = JSON.parse(File.read(File.join(__dir__, "..", "..", ".generator", "src", "generator", "keywords.json")))
34
EDGE_CASES = JSON.parse(File.read(File.join(__dir__, "..", "..", ".generator", "src", "generator", "replacement.json")))
45
REPLACED_KEYS = EDGE_CASES.keys.map { |k| Regexp.quote(k) }.join("|")
56

@@ -20,7 +21,9 @@ def lookup(dotted_path)
2021
when Hash
2122
result = result.include?(part.to_sym) ? result[part.to_sym] : result[part]
2223
else
23-
result = result.send(part.snakecase)
24+
s = part.snakecase
25+
s = "_#{s}" if KEYWORDS.include? s
26+
result = result.send(s)
2427
end
2528
end
2629
end

0 commit comments

Comments
 (0)