File: list_step_defs_as_json.feature

package info (click to toggle)
cucumber 2.4.0-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,076 kB
  • sloc: ruby: 17,016; javascript: 4,641; makefile: 12; sh: 10; tcl: 3
file content (50 lines) | stat: -rw-r--r-- 1,244 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
@spawn
Feature: List step defs as json

  In order to build tools on top of Cucumber
  As a tool developer
  I want to be able to query a features directory for all the step definitions it contains

  Background:
    Given a directory named "features"

  Scenario: Two Ruby step definitions, in the same file
    Given a file named "features/step_definitions/steps.rb" with:
      """
      Given(/foo/i)  { }
      Given(/b.r/xm) { }
      """
    When I run the following Ruby code:
      """
      require 'cucumber'
      puts Cucumber::StepDefinitions.new.to_json
      
      """
    Then it should pass with JSON:
      """
      [
        {"source": "foo", "flags": "i"},
        {"source": "b.r", "flags": "mx"}
      ]
      """

  Scenario: Non-default directory structure
    Given a file named "my_weird/place/steps.rb" with:
      """
      Given(/foo/)  { }
      Given(/b.r/x) { }
      """
    When I run the following Ruby code:
      """
      require 'cucumber'
      puts Cucumber::StepDefinitions.new(:autoload_code_paths => ['my_weird']).to_json
      
      """
    Then it should pass with JSON:
      """
      [
        {"source": "foo", "flags": ""},
        {"source": "b.r", "flags": "x"}
      ]
      
      """