cucumber_lint 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +0 -4
  3. data/.travis.yml +9 -0
  4. data/Gemfile +7 -5
  5. data/Gemfile.lock +3 -1
  6. data/README.md +28 -40
  7. data/Rakefile +12 -6
  8. data/cucumber_lint.gemspec +2 -0
  9. data/features/cucumber_lint/fix/nothing.feature +12 -0
  10. data/features/cucumber_lint/fix/repeating_steps.feature +25 -0
  11. data/features/cucumber_lint/fix/table_whitespace.feature +25 -0
  12. data/features/cucumber_lint/fix/uppercase_table_headers.feature +25 -0
  13. data/features/cucumber_lint/lint/nothing.feature +12 -0
  14. data/features/cucumber_lint/lint/repeating_steps.feature +31 -0
  15. data/features/cucumber_lint/lint/table_whitespace.feature +27 -0
  16. data/features/cucumber_lint/lint/uppercase_table_headers.feature +30 -0
  17. data/features/step_definitions/cli_steps.rb +9 -6
  18. data/features/step_definitions/fixtures/repeating_steps/bad.feature.example +12 -0
  19. data/features/step_definitions/fixtures/repeating_steps/good.feature.example +12 -0
  20. data/features/step_definitions/fixtures/table_whitespace/bad.feature.example +20 -0
  21. data/features/step_definitions/fixtures/table_whitespace/good.feature.example +20 -0
  22. data/features/step_definitions/fixtures/uppercase_table_headers/bad.feature.example +20 -0
  23. data/features/step_definitions/fixtures/uppercase_table_headers/good.feature.example +20 -0
  24. data/lib/core_ext/hash.rb +29 -0
  25. data/lib/cucumber_lint/cli.rb +50 -38
  26. data/lib/cucumber_lint/fix_list.rb +37 -0
  27. data/lib/cucumber_lint/linter/feature_linter.rb +92 -0
  28. data/lib/cucumber_lint/linter/scenario_outline_linter.rb +34 -0
  29. data/lib/cucumber_lint/linter/steps_linter.rb +49 -0
  30. data/lib/cucumber_lint/linter/table_linter.rb +70 -0
  31. data/lib/cucumber_lint/linter.rb +21 -0
  32. data/lib/cucumber_lint/version.rb +2 -2
  33. data/lib/cucumber_lint.rb +7 -4
  34. metadata +64 -16
  35. data/features/cucumber_lint/cli_fix.feature +0 -51
  36. data/features/cucumber_lint/cli_lint.feature +0 -55
  37. data/features/cucumber_lint/feature_formatter.feature +0 -106
  38. data/features/cucumber_lint/steps_formatter.feature +0 -30
  39. data/features/cucumber_lint/table_formatter.feature +0 -45
  40. data/features/step_definitions/fixtures/formatted.feature.example +0 -9
  41. data/features/step_definitions/fixtures/unformatted.feature.example +0 -9
  42. data/features/step_definitions/steps_formatter_steps.rb +0 -15
  43. data/features/step_definitions/table_formatter_steps.rb +0 -15
  44. data/lib/core_ext/array.rb +0 -22
  45. data/lib/cucumber_lint/feature_formatter.rb +0 -48
  46. data/lib/cucumber_lint/steps_formatter.rb +0 -50
  47. data/lib/cucumber_lint/table_formatter.rb +0 -65
  48. data/spec/core_ext/array_spec.rb +0 -19
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d357226ed5d21c9e3b55736ba03019f023dce69e
4
- data.tar.gz: 4b0998c48b5d3e4df9ac658b979ac543dc032811
3
+ metadata.gz: 59f628a63c86ef172e490dc170991ddef1985a98
4
+ data.tar.gz: e2d61829e08b5a7401c2956a10835600f9ea9721
5
5
  SHA512:
6
- metadata.gz: 851e8c5aaa639c14fb2185cec529f03f29bce5b9ccaa8c6177da58257b93f85bf77d69ab54dfc4ed1c59645b4944961c844d736c3cad8008fa2742cf79febc65
7
- data.tar.gz: c769b2952189beb4f574a01bfec1479f6716de886280ee239696b4d4328313dec4adc013d314d25606b9a5f2c737f2768ad8492d7303e730b01d1243725ce328
6
+ metadata.gz: f447e200f24df005c46b2a9902e40372e9f1e0b2b17d5f34a88fa1ac51b6f87383412f8023a9bcdc553193321b34c801c62c04b8187c8251fc174f701d8da52e
7
+ data.tar.gz: 8a7e79e55b286855daff422796482af173d987a2fe84c29b7d0b570aecf692414cbe5238bf0a576a93892f1548688a6826a17a65b0c2379e6f79cab927597742
data/.rubocop.yml CHANGED
@@ -6,10 +6,6 @@ Metrics/MethodLength:
6
6
  Max: 11
7
7
 
8
8
 
9
- Style/Documentation:
10
- Enabled: false
11
-
12
-
13
9
  Style/EmptyLines:
14
10
  Enabled: false
15
11
 
data/.travis.yml ADDED
@@ -0,0 +1,9 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - 2.2.0
5
+
6
+ cache: bundler
7
+
8
+ script:
9
+ - rake
data/Gemfile CHANGED
@@ -4,8 +4,10 @@ ruby '2.2.0'
4
4
 
5
5
  gemspec
6
6
 
7
- gem 'cucumber'
8
- gem 'open4'
9
- gem 'rake'
10
- gem 'rspec'
11
- gem 'rubocop'
7
+ group :development do
8
+ gem 'cucumber'
9
+ gem 'open4'
10
+ gem 'rake'
11
+ gem 'rspec'
12
+ gem 'rubocop'
13
+ end
data/Gemfile.lock CHANGED
@@ -1,8 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cucumber_lint (0.0.3)
4
+ cucumber_lint (0.0.4)
5
5
  colorize (~> 0.7.5)
6
+ gherkin (~> 2.12.2, >= 2.12.2)
7
+ multi_json (~> 1.10.1, >= 1.10.1)
6
8
 
7
9
  GEM
8
10
  remote: http://rubygems.org/
data/README.md CHANGED
@@ -1,4 +1,8 @@
1
1
  # cucumber_lint
2
+ [![Gem Version](https://badge.fury.io/rb/cucumber_lint.svg)](http://badge.fury.io/rb/cucumber_lint)
3
+ [![Build Status](https://travis-ci.org/charlierudolph/cucumber_lint.svg)](https://travis-ci.org/charlierudolph/cucumber_lint)
4
+ [![Dependency Status](https://gemnasium.com/charlierudolph/cucumber_lint.svg)](https://gemnasium.com/charlierudolph/cucumber_lint)
5
+ [![Code Climate](https://codeclimate.com/github/charlierudolph/cucumber_lint/badges/gpa.svg)](https://codeclimate.com/github/charlierudolph/cucumber_lint)
2
6
 
3
7
  A command line linter and formatter for cucumber features
4
8
 
@@ -15,48 +19,32 @@ cucumber_lint # Lints (exits with status 1 on failure, 0 on success)
15
19
  cucumber_lint --fix # Fixes all lint errors
16
20
  ```
17
21
 
18
- ### Tables
19
- * requires at a space leading and trailing cell content
20
- * requires pipes to be aligned
21
-
22
- Bad
23
- ````
24
- |header_column1|header_column2|
25
- |row1_column1|row1_column2|
26
- |row2_column1|row2_column2|
27
- |row3_column1|row3_column2|
28
- ```
29
- Bad
30
- ```
31
- | header_column1 | header_column2 |
32
- | row1_column1 | row1_column2 |
33
- | row2_column1 | row2_column2 |
34
- | row3_column1 | row3_column2 |
35
- ```
36
- Good
37
- ```
38
- | header_column1 | header_column2 |
39
- | row1_column1 | row1_column2 |
40
- | row2_column1 | row2_column2 |
41
- | row3_column1 | row3_column2 |
42
- ```
22
+ ### Features
43
23
 
44
- ### Steps
24
+ #### Repeating step keywords
45
25
  * Use `And` instead of repeating `Given`, `When`, or `Then`
46
26
 
47
- Bad
27
+ ```coffee
28
+ # Bad # Good
29
+ Given A Given A
30
+ Given B And B
31
+ When C When C
32
+ Then D Then D
33
+ Then E And E
48
34
  ```
49
- Given A
50
- Given B
51
- When C
52
- Then D
53
- Then E
54
- ```
55
- Good
56
- ```
57
- Given A
58
- And B
59
- When C
60
- Then D
61
- And E
35
+
36
+ #### Table whitespace
37
+ * requires leading and trailing space around the cell content
38
+ * requires pipes to be aligned
39
+
40
+
41
+ ```coffee
42
+ # Bad # Bad # Good
43
+ |VEGETABLE|CODENAME| | VEGETABLE | CODENAME | | VEGETABLE | CODENAME |
44
+ |Asparagus|Alpha| |Asparagus | Alpha | | Asparagus | Alpha |
45
+ |Broccoli|Bravo| |Broccoli | Bravo | | Broccoli | Bravo |
46
+ |Carrot|Charlie| | Carrot| Charlie | | Carrot | Charlie |
62
47
  ```
48
+
49
+ #### Table headers and scenario outline placeholders
50
+ * required to be uppercase
data/Rakefile CHANGED
@@ -1,17 +1,23 @@
1
1
  desc 'Run all linters and specs'
2
- task default: %w(lint spec features)
2
+ task default: %w(lint features)
3
3
 
4
4
 
5
- desc 'Run linters'
6
- task :lint do
5
+ desc 'Run all linters and specs'
6
+ task lint: %w(lint:ruby lint:cucumber)
7
+
8
+
9
+ desc 'Run ruby linters'
10
+ task 'lint:ruby' do
7
11
  sh 'bundle exec rubocop'
8
12
  end
9
13
 
10
- desc 'Run specs'
11
- task :spec do
12
- sh 'bundle exec rspec'
14
+
15
+ desc 'Run cucumber linters'
16
+ task 'lint:cucumber' do
17
+ sh 'bundle exec cucumber_lint'
13
18
  end
14
19
 
20
+
15
21
  desc 'Run features'
16
22
  task :features do
17
23
  sh 'bundle exec cucumber'
@@ -13,6 +13,8 @@ Gem::Specification.new do |spec|
13
13
  spec.license = 'MIT'
14
14
 
15
15
  spec.add_runtime_dependency 'colorize', '~> 0.7.5'
16
+ spec.add_runtime_dependency 'gherkin', '~> 2.12.2', '>= 2.12.2'
17
+ spec.add_runtime_dependency 'multi_json', '~> 1.10.1', '>= 1.10.1'
16
18
 
17
19
  spec.files = `git ls-files`.split("\n")
18
20
  spec.executables = spec.files.grep(/^bin\//) { |f| File.basename(f) }
@@ -0,0 +1,12 @@
1
+ Feature: fixing
2
+
3
+ Scenario: nothing
4
+ Given I have no files
5
+ When I run `cucumber_lint --fix`
6
+ Then I see the output
7
+ """
8
+
9
+
10
+ 0 files inspected
11
+ """
12
+ And it exits with status 0
@@ -0,0 +1,25 @@
1
+ Feature: fixing
2
+
3
+ Scenario: a feature with unformatted repeating steps
4
+ Given I have a feature with unformatted repeating steps
5
+ When I run `cucumber_lint --fix`
6
+ Then I see the output
7
+ """
8
+ W
9
+
10
+ 1 file inspected (0 passed, 1 written)
11
+ """
12
+ And it exits with status 0
13
+ And I now have a feature with formatted repeating steps
14
+
15
+
16
+ Scenario: a feature with formatted repeating steps
17
+ Given I have a feature with formatted repeating steps
18
+ When I run `cucumber_lint --fix`
19
+ Then I see the output
20
+ """
21
+ .
22
+
23
+ 1 file inspected (1 passed)
24
+ """
25
+ And it exits with status 0
@@ -0,0 +1,25 @@
1
+ Feature: fixing
2
+
3
+ Scenario: a feature with unformatted table whitespace
4
+ Given I have a feature with unformatted table whitespace
5
+ When I run `cucumber_lint --fix`
6
+ Then I see the output
7
+ """
8
+ W
9
+
10
+ 1 file inspected (0 passed, 1 written)
11
+ """
12
+ And it exits with status 0
13
+ And I now have a feature with formatted table whitespace
14
+
15
+
16
+ Scenario: a feature with formatted table whitespace
17
+ Given I have a feature with formatted table whitespace
18
+ When I run `cucumber_lint --fix`
19
+ Then I see the output
20
+ """
21
+ .
22
+
23
+ 1 file inspected (1 passed)
24
+ """
25
+ And it exits with status 0
@@ -0,0 +1,25 @@
1
+ Feature: fixing
2
+
3
+ Scenario: a feature with unformatted uppercase table headers
4
+ Given I have a feature with unformatted uppercase table headers
5
+ When I run `cucumber_lint --fix`
6
+ Then I see the output
7
+ """
8
+ W
9
+
10
+ 1 file inspected (0 passed, 1 written)
11
+ """
12
+ And it exits with status 0
13
+ And I now have a feature with formatted uppercase table headers
14
+
15
+
16
+ Scenario: a feature with formatted uppercase table headers
17
+ Given I have a feature with formatted uppercase table headers
18
+ When I run `cucumber_lint --fix`
19
+ Then I see the output
20
+ """
21
+ .
22
+
23
+ 1 file inspected (1 passed)
24
+ """
25
+ And it exits with status 0
@@ -0,0 +1,12 @@
1
+ Feature: linting
2
+
3
+ Scenario: nothing
4
+ Given I have no files
5
+ When I run `cucumber_lint`
6
+ Then I see the output
7
+ """
8
+
9
+
10
+ 0 files inspected
11
+ """
12
+ And it exits with status 0
@@ -0,0 +1,31 @@
1
+ Feature: linting
2
+
3
+ Scenario: a feature with unformatted repeating steps
4
+ Given I have a feature with unformatted repeating steps
5
+ When I run `cucumber_lint`
6
+ Then I see the output
7
+ """
8
+ F
9
+
10
+ ./features/repeating_steps.feature:5: Use "And" instead of repeating "Given"
11
+ ./features/repeating_steps.feature:6: Use "And" instead of repeating "Given"
12
+ ./features/repeating_steps.feature:8: Use "And" instead of repeating "When"
13
+ ./features/repeating_steps.feature:9: Use "And" instead of repeating "When"
14
+ ./features/repeating_steps.feature:11: Use "And" instead of repeating "Then"
15
+ ./features/repeating_steps.feature:12: Use "And" instead of repeating "Then"
16
+
17
+ 1 file inspected (0 passed, 1 failed)
18
+ """
19
+ And it exits with status 1
20
+
21
+
22
+ Scenario: a feature with formatted repeating steps
23
+ Given I have a feature with formatted repeating steps
24
+ When I run `cucumber_lint`
25
+ Then I see the output
26
+ """
27
+ .
28
+
29
+ 1 file inspected (1 passed)
30
+ """
31
+ And it exits with status 0
@@ -0,0 +1,27 @@
1
+ Feature: linting
2
+
3
+ Scenario: a feature with unformatted table whitespace
4
+ Given I have a feature with unformatted table whitespace
5
+ When I run `cucumber_lint`
6
+ Then I see the output
7
+ """
8
+ F
9
+
10
+ ./features/table_whitespace.feature:5: Fix table whitespace
11
+ ./features/table_whitespace.feature:17: Fix table whitespace
12
+
13
+ 1 file inspected (0 passed, 1 failed)
14
+ """
15
+ And it exits with status 1
16
+
17
+
18
+ Scenario: a feature with formatted table whitespace
19
+ Given I have a feature with formatted table whitespace
20
+ When I run `cucumber_lint`
21
+ Then I see the output
22
+ """
23
+ .
24
+
25
+ 1 file inspected (1 passed)
26
+ """
27
+ And it exits with status 0
@@ -0,0 +1,30 @@
1
+ Feature: fixing
2
+
3
+ Scenario: a feature with unformatted uppercase table headers
4
+ Given I have a feature with unformatted uppercase table headers
5
+ When I run `cucumber_lint`
6
+ Then I see the output
7
+ """
8
+ F
9
+
10
+ ./features/uppercase_table_headers.feature:5: Make table headers uppercase
11
+ ./features/uppercase_table_headers.feature:13: Make "<vegetable>" uppercase
12
+ ./features/uppercase_table_headers.feature:13: Make "<fruit>" uppercase
13
+ ./features/uppercase_table_headers.feature:14: Make "<codename>" uppercase
14
+ ./features/uppercase_table_headers.feature:17: Make table headers uppercase
15
+
16
+ 1 file inspected (0 passed, 1 failed)
17
+ """
18
+ And it exits with status 1
19
+
20
+
21
+ Scenario: a feature with formatted uppercase table headers
22
+ Given I have a feature with formatted uppercase table headers
23
+ When I run `cucumber_lint`
24
+ Then I see the output
25
+ """
26
+ .
27
+
28
+ 1 file inspected (1 passed)
29
+ """
30
+ And it exits with status 0
@@ -3,9 +3,11 @@ Given(/^I have no files$/) do
3
3
  end
4
4
 
5
5
 
6
- Given(/^I have an? (.+?) file at "features\/(.+?)"$/) do |filetype, filename|
7
- content = IO.read("#{FIXTURES_PATH}/#{filetype}.feature.example")
8
- IO.write "#{TMP_DIR}/features/#{filename}", content
6
+ Given(/^I have a feature with (unformatted|formatted) (.+?)$/) do |format, type|
7
+ feature_name = format == 'formatted' ? 'good' : 'bad'
8
+ feature_type = type.gsub(' ', '_')
9
+ content = IO.read("#{FIXTURES_PATH}/#{feature_type}/#{feature_name}.feature.example")
10
+ IO.write "#{TMP_DIR}/features/#{feature_type}.feature", content
9
11
  end
10
12
 
11
13
 
@@ -24,8 +26,9 @@ Then(/^it exits with status (\d+)$/) do |status|
24
26
  end
25
27
 
26
28
 
27
- Then(/^the file "features\/(.+?)" in now formatted$/) do |filename|
28
- expected = IO.read "#{FIXTURES_PATH}/formatted.feature.example"
29
- actual = IO.read "#{TMP_DIR}/features/#{filename}"
29
+ Then(/^I now have a feature with formatted (.+?)$/) do |type|
30
+ feature_type = type.gsub(' ', '_')
31
+ expected = IO.read("#{FIXTURES_PATH}/#{feature_type}/good.feature.example")
32
+ actual = IO.read "#{TMP_DIR}/features/#{feature_type}.feature"
30
33
  expect(actual).to eql expected
31
34
  end
@@ -0,0 +1,12 @@
1
+ Feature: Test Feature
2
+
3
+ Scenario: Test Scenario
4
+ Given A
5
+ Given B
6
+ Given C
7
+ When D
8
+ When E
9
+ When F
10
+ Then G
11
+ Then H
12
+ Then I
@@ -0,0 +1,12 @@
1
+ Feature: Test Feature
2
+
3
+ Scenario: Test Scenario
4
+ Given A
5
+ And B
6
+ And C
7
+ When D
8
+ And E
9
+ And F
10
+ Then G
11
+ And H
12
+ And I