All Projects → enkessler → Cuke_linter

enkessler / Cuke_linter

Licence: mit
A linting tool for Cucumber

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Cuke linter

sonar-gherkin-plugin
SonarQube Cucumber Gherkin Analyzer
Stars: ✭ 33 (+37.5%)
Mutual labels:  linter, gherkin, cucumber
Awesome-Cucumber
A collection of awesome Cucumber and Gherkin-related resources
Stars: ✭ 33 (+37.5%)
Mutual labels:  gherkin, cucumber
vscode-cucumber
Code snippets to write scenarios faster + Syntax highlight for .feature files
Stars: ✭ 24 (+0%)
Mutual labels:  gherkin, cucumber
CucumberSwift
A lightweight swift Cucumber implementation
Stars: ✭ 40 (+66.67%)
Mutual labels:  gherkin, cucumber
base project for web automation projects
base project with example for web automation projects with serenity BDD, screenplay and cucumber
Stars: ✭ 17 (-29.17%)
Mutual labels:  gherkin, cucumber
cucumber-performance
A performance testing framework for cucumber
Stars: ✭ 28 (+16.67%)
Mutual labels:  gherkin, cucumber
gavel-spec
Behavior specification for Gavel, validator of HTTP transactions
Stars: ✭ 105 (+337.5%)
Mutual labels:  gherkin, cucumber
docs
Cucumber user documentation
Stars: ✭ 110 (+358.33%)
Mutual labels:  gherkin, cucumber
gherkin
Pure Rust implementation of Gherkin language (`.feature` file) for Cucumber testing framework.
Stars: ✭ 41 (+70.83%)
Mutual labels:  gherkin, cucumber
flutter gherkin
A Gherkin parsers and runner for Dart and Flutter which is very similar to cucumber
Stars: ✭ 160 (+566.67%)
Mutual labels:  gherkin, cucumber
mocha-cakes-2
A BDD plugin for Mocha testing framework
Stars: ✭ 44 (+83.33%)
Mutual labels:  gherkin, cucumber
Behat
BDD in PHP
Stars: ✭ 3,696 (+15300%)
Mutual labels:  gherkin, cucumber
Augurk
living documentation on your own terms
Stars: ✭ 38 (+58.33%)
Mutual labels:  gherkin, cucumber
scenari
Clojure BDD library - Executable Specification with Behavior-Driven Development
Stars: ✭ 57 (+137.5%)
Mutual labels:  gherkin, cucumber
cucumber6-ts-starter
Starter project to write and debug cucumber-js features in TypeScript language
Stars: ✭ 62 (+158.33%)
Mutual labels:  gherkin, cucumber
karate-runner
VSCode Extension for Karate
Stars: ✭ 23 (-4.17%)
Mutual labels:  gherkin, cucumber
Nightwatch Cucumber
[DEPRECATED] Cucumber.js plugin for Nightwatch.js.
Stars: ✭ 243 (+912.5%)
Mutual labels:  gherkin, cucumber
gherkin2markdown
Gherkin to Markdown converter
Stars: ✭ 24 (+0%)
Mutual labels:  gherkin, cucumber
cucumber-react
React components for Cucumber
Stars: ✭ 15 (-37.5%)
Mutual labels:  gherkin, cucumber
bat
Gherkin based DSL for testing HTTP APIs via Cucumber.JS
Stars: ✭ 30 (+25%)
Mutual labels:  gherkin, cucumber

Basic stuff: Gem Version Project License Downloads

User stuff: Cucumber Docs Yard Docs

Developer stuff: Build Status Build Status Coverage Status Maintainability Inline docs


CukeLinter

So you have started to use Cucumber to describe your system in the abstract, natural language style of Gherkin. But wait! All of your feature files are themselves code and that means that they may need the same protection from anti-patterns as the lower level source code of your system. Enter cuke_linter.

This gem provides linting functionality for .feature files by building upon the modeling capabilities of the cuke_modeler gem. By passing models through a set of linters, reports can be generated that will inform you of potential bugs, style violations, or anything else that you can define as a problem via custom linters!

Installation

Add this line to your application's Gemfile:

gem 'cuke_linter'

And then execute:

$ bundle

Or install it yourself as:

$ gem install cuke_linter

Usage

From the command line

The easiest way to use the gem is to use all of the defaults by invoking it from the command line directly.

$ cuke_linter

Additional command line options can be provided that can adjust the default behavior. See documentation for specifics.

From a Ruby script

The linter can also be used inside of a Ruby script, like so:

require 'cuke_linter'

CukeLinter.lint

The linting will happen against a tree of CukeModeler models that is generated based on the current directory. You can generate your own model trees and use them instead, if desired, or even provide specific file paths that will be modeled and linted.

cuke_linter comes with a set of pre-made linters and will use them by default but custom linters can be used instead. Custom linters can be any object that responds to #lint and returns a detected issue (or nil) in the format of

{ problem: 'some linting issue',
  location: 'path/to/file:line_number' }

Note that a linter will receive, in turn, every model in a model tree in order for it to have the chance to detect problems with it. Checking the model's class before attempting to lint it is recommended.

In order to simplify the process of creating custom linters a base class is provided (see documentation).

cuke_linter comes with a set of pre-made formatters and will use them by default but custom formatters can be used instead. Custom formatters can be any object that responds to #format and takes input data in the following format:

[
 { linter: 'some linter name',
   problem: 'some linting issue',
   location: 'path/to/file:line_number' },
 { linter: 'some linter name',
   problem: 'some linting issue',
   location: 'path/to/file:line_number' },
   # etc.
]

All formatted data will be output to STDOUT unless a file location is provided as an alternative.

Below is an example of using non-default linting options.

require 'cuke_linter'

class MyCustomLinter

  def name
    'MyCustomLinter'
  end

  def lint(model)
    return nil unless model.is_a?(CukeModeler::Scenario)

    if model.name.empty?
      { problem: 'Scenario has no name', 
        location: "#{model.get_ancestor(:feature_file).path}:#{model.source_line}" }
    else
      nil
    end
  end

end

class MyCustomFormatter

  def format(linting_data)
    formatted_data = ''

    linting_data.each do |lint_item|
      formatted_data << "#{lint_item[:linter]}\n"
      formatted_data << "  #{lint_item[:problem]}\n"
      formatted_data << "    #{lint_item[:location]}\n"
    end

    formatted_data
  end

end

linter               = MyCustomLinter.new
formatter            = MyCustomFormatter.new
output_path          = "#{__dir__}/my_report.txt"
model_tree_root      = CukeModeler::Directory.new(Dir.pwd)
additional_file_path = 'path/to/some.feature'

# Providing the formatter twice so that output also is printed to the console
CukeLinter.lint(linters: [linter],
                formatters: [[formatter], [formatter, output_path]],
                model_trees: [model_tree_root],
                file_paths: [additional_file_path])

Configuration

Rather than using the default linters or providing a custom set of of modified linters every time linting occurs, which linters to use and any linter specific modifications (such as choosing a non-default dialect) can be configured in a more static manner via a configuration file or setting the configuration directly in code. See documentation for specifics.

Everything Else

For more detailed examples of usage, see the documentation here.

Development and Contributing

See CONTRIBUTING.md

License

The gem is available as open source under the terms of the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].