gherkin_language 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 81c9bc84bfd759e138af42fc5badda27881e0392
4
- data.tar.gz: 875f612c67a66184c6b6b6654ee556642d3a843f
3
+ metadata.gz: 04aee53e8b36b777bf0889ce6b0cdcd94fdef265
4
+ data.tar.gz: 54aaa1ba0d8625f05aeb8ee79e09878657988957
5
5
  SHA512:
6
- metadata.gz: c58c13eacf296ed1d23a9826535cfef0cfdbb6e8d79d9383e59ad026404a254d6c3c04c9ba6e833d24992ee923c23e7f534e8ca3c450786df396b0ea449e9c23
7
- data.tar.gz: 90e86a9d251f6d3c8b053b01223c846ebde6e620e30a3c03be3792a402d204394d7a591c5f90461f1c2a3a34b7c8a05f8756852892706d40ded949f8412bb432
6
+ metadata.gz: b3186581735b4460df28c170f865f4ee3cbb4e203cba63d77e78c3d6e1d9622a777483b9e104749972847c1a7eca36f93cd89c7f46afad1fca6be17d42903f12
7
+ data.tar.gz: 4563bb4bdfe7815bf4573c8352160c6db8fb86d01a120c0ae1155a053f7fdd423cc5e012f0a607f9d7ac17b98019c36a123147ae51d6571c555b863ad2cc0dc1
data/.rubocop.yml CHANGED
@@ -12,7 +12,7 @@ Metrics/AbcSize:
12
12
  # Offense count: 2
13
13
  # Configuration parameters: CountComments.
14
14
  Metrics/ClassLength:
15
- Max: 161
15
+ Max: 171
16
16
 
17
17
  # Offense count: 2
18
18
  Metrics/CyclomaticComplexity:
data/README.md CHANGED
@@ -21,6 +21,8 @@ To just extract the sentences, start it with `--sentences`. This could be helpfu
21
21
 
22
22
  To tag all words used, start it with `--tag`. This allows to build up a glossary based on the feature files provided.
23
23
 
24
+ To ignore specific rules, mention them with an `--ignore RULE`. This allows to bypass the checks.
25
+
24
26
 
25
27
  Glossary
26
28
  --------
data/Rakefile CHANGED
@@ -17,8 +17,8 @@ task test: :rubocop
17
17
  task test: :cucumber
18
18
 
19
19
  desc 'Publishes the Gem'
20
- task :push do
21
- sh 'gem push gherkin_language-0.0.6.gem'
20
+ task push: :build do
21
+ sh 'gem push gherkin_language-0.0.7.gem'
22
22
  end
23
23
 
24
24
  desc 'Checks ruby style'
@@ -12,7 +12,8 @@ Feature: Correct
12
12
  no_cache = true
13
13
  language = GherkinLanguage.new no_cache
14
14
  language.analyze 'test.feature'
15
- exit language.report
15
+ result = language.report
16
+ exit result unless result.nil?
16
17
 
17
18
  """
18
19
 
@@ -0,0 +1,53 @@
1
+ Feature: Exception
2
+ As a Business Analyst
3
+ I want to define exceptions for checks
4
+ so that I am able to bypass false positives
5
+
6
+ Background:
7
+ Given a file named "exception.rb" with:
8
+ """
9
+ $LOAD_PATH << '../../lib'
10
+ require 'gherkin_language'
11
+
12
+ no_cache = true
13
+ language = GherkinLanguage.new no_cache
14
+ language.ignore 'EN_A_VS_AN'
15
+ language.analyze 'test.feature'
16
+ exit language.report
17
+ """
18
+
19
+ Scenario: Accept ignored rules
20
+ Given a file named "test.feature" with:
21
+ """
22
+ Feature: Test
23
+ Scenario: Tag
24
+ Given an test
25
+ When execute
26
+ Then pass
27
+ """
28
+ When I run `ruby exception.rb`
29
+ Then it should pass with exactly:
30
+ """
31
+
32
+ """
33
+
34
+ Scenario: Fails for non ignored rules
35
+ Given a file named "test.feature" with:
36
+ """
37
+ Feature: Test
38
+ Scenario: Tag
39
+ Given a test
40
+ When exicute
41
+ Then pass
42
+ """
43
+ When I run `ruby exception.rb`
44
+ Then it should fail with exactly:
45
+ """
46
+ [misspelling] MORFOLOGIK_RULE_EN_US
47
+ Possible spelling mistake found
48
+ Context: Given a test when exicute then pass
49
+ Replacements: execute
50
+ References: test.feature
51
+ 1 unknown words: exicute
52
+
53
+ """
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'gherkin_language'
3
- s.version = '0.0.6'
4
- s.date = '2015-07-19'
3
+ s.version = '0.0.7'
4
+ s.date = '2015-10-04'
5
5
  s.summary = 'Gherkin Language'
6
6
  s.description = 'Check language of Gherkin Files'
7
7
  s.authors = ['Stefan Rohe']
@@ -161,6 +161,11 @@ class GherkinLanguage
161
161
  end
162
162
  @references = {}
163
163
  @line_to_reference = {}
164
+ @exceptions = []
165
+ end
166
+
167
+ def ignore(exception)
168
+ @exceptions.push exception
164
169
  end
165
170
 
166
171
  def analyze(file)
@@ -228,6 +233,9 @@ class GherkinLanguage
228
233
  used_refs = Set.new []
229
234
  errors.each do |error|
230
235
  used_refs.add @line_to_reference[error.from_y]
236
+ end
237
+ errors.select! { |error| !@exceptions.include? error.rule }
238
+ errors.each do |error|
231
239
  local_refs = @references[@line_to_reference[error.from_y]]
232
240
  puts error.str local_refs
233
241
  end
@@ -235,6 +243,13 @@ class GherkinLanguage
235
243
  puts red "#{unknown_words.count} unknown words: #{unknown_words * ', '}" unless unknown_words.empty?
236
244
  return -1 unless unknown_words.empty?
237
245
 
246
+ write_accepted_paragraphs used_refs
247
+
248
+ return -1 unless errors.empty?
249
+ 0
250
+ end
251
+
252
+ def write_accepted_paragraphs(used_refs)
238
253
  @references.each do |sentence, _refs|
239
254
  next if used_refs.include? sentence
240
255
  key = :without_glossary
@@ -248,8 +263,6 @@ class GherkinLanguage
248
263
  File.open(@settings_path, 'w') do |settings_file|
249
264
  settings_file.write @accepted_paragraphs.to_yaml
250
265
  end
251
- return -1 unless errors.empty?
252
- 0
253
266
  end
254
267
 
255
268
  def to_json(input, file = 'generated.feature')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gherkin_language
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Rohe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-19 00:00:00.000000000 Z
11
+ date: 2015-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gherkin
@@ -68,6 +68,7 @@ files:
68
68
  - Rakefile
69
69
  - bin/gherkin_language
70
70
  - features/correct.feature
71
+ - features/exception.feature
71
72
  - features/glossary.feature
72
73
  - features/report.feature
73
74
  - features/sentences.feature