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
|
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 standard Cucumber project directory structure
Scenario: Two Ruby step definitions, in the same file
Given a file named "features/step_definitions/foo_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
And the output should contain the following JSON:
"""
[
{"source": "foo", "flags": "i"},
{"source": "b.r", "flags": "mx"}
]
"""
Scenario: Non-default directory structure
Given a file named "my_weird/place/foo_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
And the output should contain the following JSON:
"""
[
{"source": "foo", "flags": ""},
{"source": "b.r", "flags": "x"}
]
"""
|