gherkin_lint 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 02a51af014c3217570afcb623301a99b27308f46
4
- data.tar.gz: d3553032dd6ffa4dfaabed5fea306d1e7b8d0986
3
+ metadata.gz: 55bcc404f41403702960d9d2947515739567023f
4
+ data.tar.gz: a26de407f1adb5dfd372da3f4e32a395ff85d20a
5
5
  SHA512:
6
- metadata.gz: f8348eaf5ef2256d0c98d5648210f582aa29d99b3d601841472dd2b5d11b44fcbbbd45eb6c46e2a99b8df6da9ff6ba8e646d52a2ab0ff8bbd6705a48a95651ff
7
- data.tar.gz: e631d0f584509c85e2a64c94834c7fc0093d53d7fd93c24d83fac31d190c34818a89ce62701f46eb066bd4bd374e0fc723451f9509cec4de661bdd5076f80bf0
6
+ metadata.gz: 15112d1f645e2c06b58d9022d44e5004ac38c75c87caf8ba5d2c9776eb1eeabe62f61b05908ca058fe8f7a64736758d2d7e029d1fd673eaae321bf2db073bee4
7
+ data.tar.gz: 4c93f4a4e9e479d2f9764ec71e4064d9aa6f50a43a26c7ce511f976c11a0fe5f4b45a4224f1575412c999de9633a2df0934fb4caa587ddecef37f46947b790a8
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2016-02-28 13:48:49 +0100 using RuboCop version 0.36.0.
3
+ # on 2016-02-28 15:30:26 +0100 using RuboCop version 0.37.2.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
@@ -11,8 +11,14 @@
11
11
  Metrics/ClassLength:
12
12
  Max: 116
13
13
 
14
- # Offense count: 3
14
+ # Offense count: 28
15
15
  # Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
16
16
  # URISchemes: http, https
17
17
  Metrics/LineLength:
18
18
  Max: 118
19
+
20
+ # Offense count: 1
21
+ # Cop supports --auto-correct.
22
+ Performance/Casecmp:
23
+ Exclude:
24
+ - 'lib/gherkin_lint/linter/invalid_file_name.rb'
data/Rakefile CHANGED
@@ -11,7 +11,7 @@ end
11
11
 
12
12
  desc 'Publishes the Gem'
13
13
  task :push do
14
- sh 'gem push gherkin_lint-0.1.1.gem'
14
+ sh 'gem push gherkin_lint-0.1.2.gem'
15
15
  end
16
16
 
17
17
  desc 'Checks ruby style'
@@ -0,0 +1,67 @@
1
+ Feature: Avoid Scripting
2
+ As a Business Analyst
3
+ I want to be warned about scripted tests
4
+ so that all my tests follow the guideline of single action per scenario.
5
+
6
+ Background: Prepare Testee
7
+ Given a file named "lint.rb" with:
8
+ """
9
+ $LOAD_PATH << '../../lib'
10
+ require 'gherkin_lint'
11
+
12
+ linter = GherkinLint::GherkinLint.new
13
+ linter.enable %w(AvoidScripting)
14
+ linter.analyze 'lint.feature'
15
+ exit linter.report
16
+
17
+ """
18
+
19
+ Scenario: Multiple Actions
20
+ Given a file named "lint.feature" with:
21
+ """
22
+ Feature: Test
23
+ Scenario: A
24
+ Given setup
25
+ When action
26
+ And something else
27
+ Then verify
28
+ """
29
+ When I run `ruby lint.rb`
30
+ Then it should fail with exactly:
31
+ """
32
+ AvoidScripting - Multiple Actions
33
+ lint.feature (2): Test.A
34
+ """
35
+
36
+ Scenario: Repeat Action-Verfication Steps
37
+ Given a file named "lint.feature" with:
38
+ """
39
+ Feature: Test
40
+ Scenario: A
41
+ Given setup
42
+ When test
43
+ Then verify
44
+ When test
45
+ Then verify
46
+ """
47
+ When I run `ruby lint.rb`
48
+ Then it should fail with exactly:
49
+ """
50
+ AvoidScripting - Multiple Actions
51
+ lint.feature (2): Test.A
52
+ """
53
+
54
+ Scenario: Valid Example
55
+ Given a file named "lint.feature" with:
56
+ """
57
+ Feature: Test
58
+ Scenario: A
59
+ Given setup
60
+ When test
61
+ Then verification
62
+ """
63
+ When I run `ruby lint.rb`
64
+ Then it should pass with exactly:
65
+ """
66
+
67
+ """
@@ -9,7 +9,6 @@ Feature: Invalid File Name
9
9
  $LOAD_PATH << '../../lib'
10
10
  require 'gherkin_lint'
11
11
  require 'optparse'
12
- options = {}
13
12
  OptionParser.new { |opts| }.parse!
14
13
 
15
14
  linter = GherkinLint::GherkinLint.new
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'gherkin_lint'
3
- s.version = '0.1.1'
4
- s.date = '2016-02-28'
3
+ s.version = '0.1.2'
4
+ s.date = '2016-04-17'
5
5
  s.summary = 'Gherkin Lint'
6
6
  s.description = 'Lint Gherkin Files'
7
7
  s.authors = ['Stefan Rohe']
@@ -4,6 +4,7 @@ require 'gherkin/formatter/json_formatter'
4
4
  require 'gherkin/parser/parser'
5
5
  require 'gherkin_lint/linter/avoid_outline_for_single_example'
6
6
  require 'gherkin_lint/linter/avoid_period'
7
+ require 'gherkin_lint/linter/avoid_scripting'
7
8
  require 'gherkin_lint/linter/background_does_more_than_setup'
8
9
  require 'gherkin_lint/linter/background_requires_multiple_scenarios'
9
10
  require 'gherkin_lint/linter/bad_scenario_name'
@@ -36,6 +37,7 @@ module GherkinLint
36
37
  class GherkinLint
37
38
  LINTER = [
38
39
  AvoidPeriod,
40
+ AvoidScripting,
39
41
  AvoidOutlineForSingleExample,
40
42
  BackgroundDoesMoreThanSetup,
41
43
  BackgroundRequiresMultipleScenarios,
@@ -106,7 +106,7 @@ module GherkinLint
106
106
  end
107
107
 
108
108
  def lint
109
- fail 'not implemented'
109
+ raise 'not implemented'
110
110
  end
111
111
 
112
112
  def reference(file, feature = nil, scenario = nil, step = nil)
@@ -0,0 +1,22 @@
1
+ require 'gherkin_lint/linter'
2
+
3
+ module GherkinLint
4
+ # service class to lint for avoid scripting
5
+ class AvoidScripting < Linter
6
+ def lint
7
+ filled_scenarios do |file, feature, scenario|
8
+ steps = filter_when_steps scenario['steps']
9
+
10
+ next if steps.length <= 1
11
+ references = [reference(file, feature, scenario)]
12
+ add_issue(references, 'Multiple Actions')
13
+ end
14
+ end
15
+
16
+ def filter_when_steps(steps)
17
+ steps = steps.drop_while { |step| step['keyword'] != 'When ' }
18
+ steps = steps.reverse.drop_while { |step| step['keyword'] != 'Then ' }.reverse
19
+ steps.select { |step| step['keyword'] != 'Then ' }
20
+ end
21
+ end
22
+ end
@@ -7,7 +7,7 @@ module GherkinLint
7
7
  features do |file, feature|
8
8
  next unless feature.include? 'name'
9
9
  expected_feature_name = title_case file
10
- next unless feature['name'].downcase != expected_feature_name.downcase
10
+ next if feature['name'].casecmp(expected_feature_name) == 0
11
11
  references = [reference(file, feature)]
12
12
  add_issue(references, "Feature name should be '#{expected_feature_name}'")
13
13
  end
@@ -6,7 +6,7 @@ module GherkinLint
6
6
  def lint
7
7
  filled_scenarios do |file, feature, scenario|
8
8
  when_steps = scenario['steps'].select { |step| step['keyword'] == 'When ' }
9
- next if when_steps.length > 0
9
+ next unless when_steps.empty?
10
10
  references = [reference(file, feature, scenario)]
11
11
  add_issue(references, 'No \'When\'-Step')
12
12
  end
@@ -6,7 +6,7 @@ module GherkinLint
6
6
  def lint
7
7
  filled_scenarios do |file, feature, scenario|
8
8
  then_steps = scenario['steps'].select { |step| step['keyword'] == 'Then ' }
9
- next if then_steps.length > 0
9
+ next unless then_steps.empty?
10
10
  references = [reference(file, feature, scenario)]
11
11
  add_issue(references, 'No verification step')
12
12
  end
@@ -7,7 +7,7 @@ module GherkinLint
7
7
  features do |file, feature|
8
8
  tags = gather_same_tags feature
9
9
  next if tags.nil?
10
- next if tags.length < 1
10
+ next if tags.empty?
11
11
  next unless feature['elements'].length > 1
12
12
  references = [reference(file, feature)]
13
13
  tags.each do |tag|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gherkin_lint
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Rohe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-28 00:00:00.000000000 Z
11
+ date: 2016-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gherkin
@@ -84,6 +84,7 @@ files:
84
84
  - bin/gherkin_lint
85
85
  - features/avoid_outline_for_single_example.feature
86
86
  - features/avoid_period.feature
87
+ - features/avoid_scripting.feature
87
88
  - features/background_does_more_than_setup.feature
88
89
  - features/background_requires_scenario.feature
89
90
  - features/bad_scenario_name.feature
@@ -115,6 +116,7 @@ files:
115
116
  - lib/gherkin_lint/linter.rb
116
117
  - lib/gherkin_lint/linter/avoid_outline_for_single_example.rb
117
118
  - lib/gherkin_lint/linter/avoid_period.rb
119
+ - lib/gherkin_lint/linter/avoid_scripting.rb
118
120
  - lib/gherkin_lint/linter/background_does_more_than_setup.rb
119
121
  - lib/gherkin_lint/linter/background_requires_multiple_scenarios.rb
120
122
  - lib/gherkin_lint/linter/bad_scenario_name.rb