【发布时间】:2013-11-18 16:40:16
【问题描述】:
我确信这是一个非常愚蠢的问题,但我无法理解它。
我有以下红宝石代码:
sample_test = "Feature: Some terse yet descriptive text of what is desired
Textual description of the business value of this feature
Business rules that govern the scope of the feature
Any additional information that will make the feature easier to understand
Scenario: Some determinable business situation
Given some precondition
And some other precondition
When some action by the actor
And some other action
And yet another action
Then some testable outcome is achieved
And something else we can check happens too"
io = StringIO.new
pretty_formatter = Gherkin::Formatter::PrettyFormatter.new(io, true, false)
json_formatter = Gherkin::Formatter::JSONFormatter.new(io)
parser = Gherkin::Parser::Parser.new(json_formatter)
result = parser.parse(sample_test, '', 0)
这将返回True。
但我想得到一个 JSON 格式的结果。我应该使用什么来获取所有步骤的 JSON 输出?
【问题讨论】:
-
您能举例说明输出应该是什么样子吗?鉴于
sample_test,我不清楚 JSON blob 应该是什么样子。 -
没关系,我只想用小黄瓜解析器做我自己的事情。我认为这是一个很好的例子github.com/davidwilliam/cucumber_monitor#cucumbermonitor-api
-
如果您展示您希望输出的示例,您将有更好的机会获得答案。
-
感谢@Davidann,尽管之前在谷歌上搜索过所有问题,但我现在找到了答案。