阿鲁巴黄瓜测试(ruby1.9.2)

发布于 2024-10-08 07:11:59 字数 1281 浏览 5 评论 0原文

我刚刚安装了 aruba gem,它是 cucumber 的扩展。它允许您测试命令行应用程序 - 例如 Rails 中的生成器(但是,正如文档指出的那样,您可以将它用于任何 cmd 应用程序)。

我一直在关注这个关键实验室关于使用它的文章,但由于某种原因它没有通过第一步:第一步是绿色的(创建应用程序),但以下步骤尝试cd test_app 找不到它并失败。

Given I run "rails new test_app"                       # features/step_definitions/aruba_steps.rb:95
And I cd to "test_app"                                 # features/step_definitions/aruba_steps.rb:91
  tmp/aruba/test_app is not a directory. (RuntimeError)
  ./features/step_definitions/aruba_steps.rb:92:in `/^I cd to "([^"]*)"$/'
  features/generators.feature:9:in `And I cd to "test_app"'

看起来应用程序文件夹实际上并未被创建,尽管在基本目录中我可以看到 tmp/aruba/ 折叠 is 。在研究了源代码一段时间后,我无法想出任何原因。 还有其他人有过使用这颗宝石的经历并发现了同样的东西吗?

是否有任何不错的 BDD 替代方案来测试生成器或 rake 任务等?

根据 Ryans 的回答:

一旦我将以下内容添加到 features/support/env.rb 中(从基础 Rails 目录工作):

Before do
  @dirs = [File.expand_path(File.dirname(__FILE__) + '/../../../aruba_test_dir')]
end

这样 Cucumber 就可以在外部构建应用程序当前 Rails 应用程序的版本,这解决了这个问题。

I've just installed the aruba gem which is an extension to cucumber. It allows you to test command line applications - like generators in Rails (but, as the documentation points out, you could use it for any cmd app).

I have been following this pivotal labs article about using it, but for some reason it doesn't get past the first step: the first step is green ( the creation of the app ), but the following step tries to cd test_app and can't find it and fails.

Given I run "rails new test_app"                       # features/step_definitions/aruba_steps.rb:95
And I cd to "test_app"                                 # features/step_definitions/aruba_steps.rb:91
  tmp/aruba/test_app is not a directory. (RuntimeError)
  ./features/step_definitions/aruba_steps.rb:92:in `/^I cd to "([^"]*)"$/'
  features/generators.feature:9:in `And I cd to "test_app"'

It would appear that the application folder isn't actually being created, although looking in the base dir I can see the tmp/aruba/ folding is . After poking around the source for a while I can't come up with anything as to why.
Has anybody else had any experience with this gem and found the same thing?

Are there any nice BDD alternatives to testing generators or rake tasks etc?

Further to Ryans answer:

Once I added the following to the features/support/env.rb (working from the base rails directory):

Before do
  @dirs = [File.expand_path(File.dirname(__FILE__) + '/../../../aruba_test_dir')]
end

So that cucumber is building the app outside of the current rails app, this fixes the issue.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

杀手六號 2024-10-15 07:11:59

我最初的想法:我认为如果 Rails 不在你的包中,就会导致这种情况。但你看起来是个聪明人,所以我尝试复制你的例子,发现我得到了同样的结果。

困惑的是,我确定我得到了输出:

Scenario: title
  Given I run "rails new test_app"
  Then the output should contain:
    """
      app/mailers
    """
  And I cd to "test_app"

事实证明,只需观察,输出包含app/mailers,该过程就可以正常工作。这是非常量子化的,很可能是 Aruba 或 Rails 中的一个错误。我不确定是哪一个。

My initial thoughts: I think what would cause this is if Rails wasn't inside your bundle. But you seem like a smart man and so I tried duplicating your example and found that I got the same thing.

Puzzled, I made sure that I was getting output:

Scenario: title
  Given I run "rails new test_app"
  Then the output should contain:
    """
      app/mailers
    """
  And I cd to "test_app"

It turns out by simply observing that the output contains app/mailers that this process works. It's very quantum and most probably a bug in Aruba or Rails. I'm not sure which.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文