在 Ruby on Rails 开发中使用 Cucumber 传递 autospec 中的选项
我总是运行 autospec
来同时运行功能和 RSpec,但在本地计算机上运行所有功能通常非常耗时。我会在提交代码之前运行每个功能。
我想在 autospec 命令中传递参数。 autospec
显然不直接接受参数。这是 autospec -h 的输出:
autotest [options]
options:
-h
-help You're looking at it.
-v Be verbose.
Prints files that autotest doesn't know how to map to
tests.
-q Be more quiet.
-f Fast start.
Doesn't initially run tests at start.
我在 config 目录中有一个 cucumber.yml 。我的 Rails 根目录中还有 rerun.txt
。 cucumber -h
为我提供了大量有关参数的信息。
如何针对标记为 @wip
的功能运行 autospec
?我想我可以利用config/cucumber.yml
。有配置文件定义。我可以运行 cucumber -p wip 来仅运行 @wip 标记的功能,但我想使用 autospec 来执行此操作。
我将不胜感激任何有关使用许多规范和功能文件的提示。
I always run autospec
to run features and RSpec at the same time, but running all the features is often time-consuming on my local computer. I would run every feature before committing code.
I would like to pass the argument in autospec
command. autospec
doesn't obviously doesn't accept the arguments directly. Here's the output of autospec -h
:
autotest [options]
options:
-h
-help You're looking at it.
-v Be verbose.
Prints files that autotest doesn't know how to map to
tests.
-q Be more quiet.
-f Fast start.
Doesn't initially run tests at start.
I do have a cucumber.yml
in config
directory. I also have rerun.txt
in the Rails root directory. cucumber -h
gives me a lot of information about arguments.
How can I run autospec
against features that are tagged as @wip
? I think I can make use of config/cucumber.yml
. There are profile definitions. I can run cucumber -p wip
to run only @wip-tagged features, but I'd like to do this with autospec
.
I would appreciate any tips for working with many spec and feature files.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您使用的是 OSX,则可以尝试使用 Kicker gem 在文件更改时启动 Cucumber:
不幸的是,我不知道是否有类似的程序可以在 windows/linux 上进行任意文件监视
If you're on OSX, you can try using the Kicker gem to launch cucumber when files change:
Unfortunately, I don't know if there's a comparable program to do arbitrary file watches on windows/linux
如果您的
cucumber.yml
文件中有autotest
配置文件,autospec 将使用该配置文件而不是默认配置文件。我正在使用类似的东西来运行
@wip
任务:这基本上是说:“运行用 @wip 标记的前三个场景”。
如果您希望在运行整个套件时(通常在红色 => 绿色转换之后)有与 autospec 不同的行为,您还可以添加
autotest-all
配置文件。这是一个帮助您入门的粗略示例:If you have an
autotest
profile in yourcucumber.yml
file, autospec will use that one instead of the default profile.I'm using something like this to run
@wip
tasks:This basically says: "run first three scenarios tagged with @wip".
You could also add an
autotest-all
profile, if you want a different behavior from autospec when running the entire suite (normally after a red => green transition). Here's a rough example to get you started:好吧,一个技巧是,您可以通过将 AUTOFEATURE 设置为 false 来运行规范而不运行功能:
这样您就可以运行规范,直到它们全部变为绿色,然后将 AUTOFEATURE 设置回 true 并让您的功能运行,当它们全部通过时你可以开始重构。
Well, one tip is that you can run specs without running features, by setting AUTOFEATURE to false:
That way you can run your specs until they are all green, then set AUTOFEATURE back to true and get your features running, and when they all pass you can get to refactoring.
我不使用自动测试或自动规范来运行功能,而是定期手动运行它们。 Cucumber 功能不像 rspec 测试那么智能,并且会针对最小的更改运行。 TDD 固然很好,但它应该加快速度,而不是减慢速度。
因此,我运行:
在一个窗口中,并且
I do not run features with autotest or autospec, but instead run them manually periodically. Cucumber features are not as smart as rspec tests and will run for the smallest change. TDD is all well and good, but it's supposed to speed things up, not slow them down.
Thus, I run:
in one window, and