开发者

Aruba cucumber tests (ruby1.9.2)

开发者 https://www.devze.com 2023-01-30 09:43 出处:网络
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

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_ste开发者_如何学运维ps.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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号