gherkin_checker 1.1.7 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +32 -10
- data/lib/gherkin_checker/version.rb +1 -1
- data/lib/gherkin_checker.rb +80 -54
- metadata +4 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 187d4e241a76c4044dc0f41c640c4b3b5022508614482d6c6369dd72b4c9888a
|
4
|
+
data.tar.gz: 3e679ba099d82061788ae12270bb0d73f15673289e089ca35436a2d0418934d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9184c1441b70cd8f8f8f6db7a1499b3f6cf476556e762a5f3b1318235e9a0ed1bf3dfbc7417aa6b1ff42f78ec4d1ca9ee278bd4edaec7bbfd57821063cea99fe
|
7
|
+
data.tar.gz: 3ba183a3a7af38e70823945f7228ac21311f3462b7d4f5be8c18047263b0f8f8e6d977ae560b61113c02148f0acb7a9dbc29b7b0b84cc87d22c6bc49b1846d25
|
data/README.md
CHANGED
@@ -1,22 +1,44 @@
|
|
1
|
-
#
|
1
|
+
# gherkin_checker
|
2
2
|
|
3
|
-
.feature
|
3
|
+
**GherkinChecker** is a tool for validating and enforcing rules on Gherkin `.feature` files. It allows users to set custom tag and structure requirements for feature files to maintain consistency and quality in test scenarios.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
|
-
|
7
|
+
Install the gem and add it to your application's Gemfile by running:
|
8
8
|
|
9
|
-
|
9
|
+
```sh
|
10
|
+
gem install gherkin_checker
|
11
|
+
````
|
10
12
|
|
11
|
-
|
13
|
+
## Usage
|
12
14
|
|
13
|
-
|
15
|
+
After successful installation, navigate to your project repository and create a configuration file named gherkin_checker.yml. Define your custom rules for Gherkin checking within this file. Below is a sample configuration format:
|
14
16
|
|
15
|
-
|
17
|
+
```yaml
|
18
|
+
feature_files_path: '{to/your/path}'
|
19
|
+
mandatory_tags:
|
20
|
+
must_be:
|
21
|
+
- "Text1"
|
22
|
+
one_of:
|
23
|
+
- "Text2"
|
24
|
+
- "Text3"
|
25
|
+
- "Text4"
|
26
|
+
```
|
16
27
|
|
17
|
-
|
28
|
+
**Configuration Parameters**
|
29
|
+
|
30
|
+
- **feature_files_path**: Specifies the path to the directory containing Gherkin feature files.
|
31
|
+
- **mandatory_tags**:
|
32
|
+
- **must_be**: Tags that must be present in every feature file.
|
33
|
+
- **one_of**: Tags where at least one must be present in each feature file.
|
34
|
+
|
35
|
+
To run Gherkin Checker on your project, execute the following command in the terminal:
|
36
|
+
|
37
|
+
```sh
|
38
|
+
gherkin_checker
|
39
|
+
````
|
18
40
|
|
19
|
-
|
41
|
+
This command will check your feature files according to the rules defined in gherkin_checker.yml and provide feedback based on any discrepancies found.
|
20
42
|
|
21
43
|
## Development
|
22
44
|
|
@@ -26,7 +48,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
26
48
|
|
27
49
|
## Contributing
|
28
50
|
|
29
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
51
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/dikako/gherkin_checker. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/gherkin_checker/blob/main/CODE_OF_CONDUCT.md).
|
30
52
|
|
31
53
|
## License
|
32
54
|
|
data/lib/gherkin_checker.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require "find"
|
4
4
|
require "yaml"
|
5
|
-
require "
|
5
|
+
require "gherkin/parser"
|
6
6
|
|
7
7
|
require_relative "gherkin_checker/version"
|
8
8
|
|
@@ -50,18 +50,20 @@ module GherkinChecker
|
|
50
50
|
return log_one_of_tags_warning if @one_of_tags.nil?
|
51
51
|
|
52
52
|
errors = []
|
53
|
-
|
54
|
-
is_tags_nil = data[:
|
55
|
-
tags = data[:
|
53
|
+
extract_scenario_data(file).each do |data|
|
54
|
+
is_tags_nil = data[:scenario_tags].nil?
|
55
|
+
tags = data[:scenario_tags]
|
56
56
|
file_line = data[:file_line]
|
57
|
-
scenario = data[:
|
57
|
+
scenario = data[:scenario_name]
|
58
|
+
error = data[:error]
|
58
59
|
|
59
60
|
if is_tags_nil
|
60
61
|
errors << {
|
61
62
|
check: :one_of_tags,
|
62
63
|
file_line: file_line,
|
63
|
-
|
64
|
-
|
64
|
+
scenario_name: scenario,
|
65
|
+
scenario_tags: tags,
|
66
|
+
error: error
|
65
67
|
}
|
66
68
|
end
|
67
69
|
|
@@ -72,8 +74,9 @@ module GherkinChecker
|
|
72
74
|
errors << {
|
73
75
|
check: :one_of_tags,
|
74
76
|
file_line: file_line,
|
75
|
-
|
76
|
-
|
77
|
+
scenario_name: scenario,
|
78
|
+
scenario_tags: tags,
|
79
|
+
error: error
|
77
80
|
}
|
78
81
|
end
|
79
82
|
|
@@ -84,18 +87,20 @@ module GherkinChecker
|
|
84
87
|
return log_must_be_tags_warning if @must_be_tags.nil?
|
85
88
|
|
86
89
|
errors = []
|
87
|
-
|
88
|
-
is_tags_nil = data[:
|
89
|
-
tags = data[:
|
90
|
+
extract_scenario_data(file).each do |data|
|
91
|
+
is_tags_nil = data[:scenario_tags].nil?
|
92
|
+
tags = data[:scenario_tags]
|
90
93
|
file_line = data[:file_line]
|
91
|
-
scenario = data[:
|
94
|
+
scenario = data[:scenario_name]
|
95
|
+
error = data[:error]
|
92
96
|
|
93
97
|
if is_tags_nil
|
94
98
|
errors << {
|
95
99
|
check: :must_be_tags,
|
96
100
|
file_line: file_line,
|
97
|
-
|
98
|
-
|
101
|
+
scenario_name: scenario,
|
102
|
+
scenario_tags: tags,
|
103
|
+
error: error
|
99
104
|
}
|
100
105
|
end
|
101
106
|
|
@@ -106,8 +111,9 @@ module GherkinChecker
|
|
106
111
|
errors << {
|
107
112
|
check: :must_be_tags,
|
108
113
|
file_line: file_line,
|
109
|
-
|
110
|
-
|
114
|
+
scenario_name: scenario,
|
115
|
+
scenario_tags: tags,
|
116
|
+
error: error
|
111
117
|
}
|
112
118
|
end
|
113
119
|
|
@@ -140,20 +146,25 @@ module GherkinChecker
|
|
140
146
|
else
|
141
147
|
log_message("Gherkin Checker found Error:", level: :error)
|
142
148
|
errors.each do |error|
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
149
|
+
error_message = error[:error]
|
150
|
+
if error_message.nil?
|
151
|
+
scenario_tags = error[:scenario_tags]
|
152
|
+
tags = scenario_tags
|
153
|
+
tags = scenario_tags.nil? ? "Tagging not set" : "Just found '#{tags}'"
|
154
|
+
|
155
|
+
message = case error[:check]
|
156
|
+
when :one_of_tags
|
157
|
+
"one_of_tags '#{@one_of_tags}' not found!, #{tags}"
|
158
|
+
when :must_be_tags
|
159
|
+
"must_be_tags '#{@must_be_tags}' not found!, #{tags}"
|
160
|
+
else
|
161
|
+
"error undefined"
|
162
|
+
end
|
163
|
+
|
164
|
+
log_message("#{error[:file_line]}: #{error[:scenario_name]} - #{message}", level: :error)
|
165
|
+
else
|
166
|
+
log_message("Error: #{error_message}", level: :error)
|
167
|
+
end
|
157
168
|
end
|
158
169
|
end
|
159
170
|
end
|
@@ -175,33 +186,48 @@ module GherkinChecker
|
|
175
186
|
puts "#{color}#{message}#{colors[:reset]}"
|
176
187
|
end
|
177
188
|
|
178
|
-
def
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
scenario_name =
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
189
|
+
def extract_scenario_data(file)
|
190
|
+
gherkin_parser = Gherkin::Parser.new
|
191
|
+
scenario_data = []
|
192
|
+
|
193
|
+
begin
|
194
|
+
content = File.read(file)
|
195
|
+
document = gherkin_parser.parse(content)
|
196
|
+
feature = document.feature
|
197
|
+
feature_name = feature.name
|
198
|
+
feature_tags = feature.tags.map(&:name)
|
199
|
+
|
200
|
+
feature.children.each do |child|
|
201
|
+
raise "Error: read scenario data" unless child.respond_to?(:scenario) && child.scenario
|
202
|
+
|
203
|
+
scenario = child.scenario
|
204
|
+
scenario_name = scenario.name
|
205
|
+
scenario_tags = scenario.tags.map(&:name)
|
206
|
+
scenario_tags = scenario_tags.map { |tag| tag.delete_prefix("@") }
|
207
|
+
location_line = scenario.location.line
|
208
|
+
location_column = scenario.location.column
|
209
|
+
|
210
|
+
scenario_data << {
|
211
|
+
feature_name: feature_name,
|
212
|
+
feature_tags: feature_tags,
|
213
|
+
file_line: "#{file}:#{location_line}:#{location_column}",
|
214
|
+
scenario_name: scenario_name,
|
215
|
+
scenario_tags: scenario_tags,
|
216
|
+
error: nil
|
199
217
|
}
|
200
|
-
current_tags = [] # Reset tags for next scenario
|
201
218
|
end
|
219
|
+
rescue StandardError => e
|
220
|
+
scenario_data << {
|
221
|
+
feature_name: nil,
|
222
|
+
feature_tags: nil,
|
223
|
+
file_line: nil,
|
224
|
+
scenario_name: nil,
|
225
|
+
scenario_tags: nil,
|
226
|
+
error: e.message
|
227
|
+
}
|
202
228
|
end
|
203
229
|
|
204
|
-
|
230
|
+
scenario_data
|
205
231
|
end
|
206
232
|
end
|
207
233
|
end
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gherkin_checker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dikakoko
|
8
|
-
autorequire:
|
9
8
|
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-07-25 00:00:00.000000000 Z
|
12
11
|
dependencies: []
|
13
12
|
description: Checking .feature files
|
14
13
|
email:
|
@@ -28,7 +27,6 @@ licenses:
|
|
28
27
|
metadata:
|
29
28
|
rubygems_mfa_required: 'true'
|
30
29
|
source_code_uri: https://github.com/dikako/gherkin_checker
|
31
|
-
post_install_message:
|
32
30
|
rdoc_options: []
|
33
31
|
require_paths:
|
34
32
|
- lib
|
@@ -36,15 +34,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
36
34
|
requirements:
|
37
35
|
- - ">="
|
38
36
|
- !ruby/object:Gem::Version
|
39
|
-
version: '3.
|
37
|
+
version: '3.4'
|
40
38
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
41
39
|
requirements:
|
42
40
|
- - ">="
|
43
41
|
- !ruby/object:Gem::Version
|
44
42
|
version: '0'
|
45
43
|
requirements: []
|
46
|
-
rubygems_version: 3.2
|
47
|
-
signing_key:
|
44
|
+
rubygems_version: 3.6.2
|
48
45
|
specification_version: 4
|
49
46
|
summary: ".feature files checkers"
|
50
47
|
test_files: []
|