0

我在第二章的行动书中有rails 3

Feature: My Account
  In order to manage my account
  As a money minder
  I want to ensure my money doesn't get lost

Scenario: Taking out money
  Given I have an account
  And it has a balance of 100
  When I take 10
  Then my balance should be 90 

在终端我得到了这个:

➜  accounts  cucumber features
Feature: My Account
  In order to manage my account
  As a money minder
  I want to ensure my money doesn't get lost

  Scenario: Taking out money     # features/account.feature:6
    Given I have an account      # features/account.feature:7
    And it has a balance of 100  # features/account.feature:8
    When I take 10               # features/account.feature:9
    Then my balance should be 90 # features/account.feature:10

1 scenario (1 undefined)
4 steps (4 undefined)
0m0.002s

You can implement step definitions for undefined steps with these snippets:

Given(/^I have an account$/) do
  pending # express the regexp above with the code you wish you had
end

Given(/^it has a balance of (\d+)$/) do |arg1|
  pending # express the regexp above with the code you wish you had
end

When(/^I take (\d+)$/) do |arg1|
  pending # express the regexp above with the code you wish you had
end

Then(/^my balance should be (\d+)$/) do |arg1|
  pending # express the regexp above with the code you wish you had
end

If you want snippets in a different programming language,
just make sure a file with the appropriate file extension
exists where cucumber looks for step definitions.

我在

 Rails -v 3.2.12
Ruby -v 1.9.3
cucumber (1.3.2)
cucumber-rails (1.2.1)

那我该怎么办?这本书在接下来的章节中也使用了黄瓜。

这是我第一次使用黄瓜,所以我需要一个解释,我在谷歌上搜索并找到了一篇文章,但我没有从中得到重点,我希望我能找到一个更简单的解释

4

1 回答 1

0

看看blog.codeship.io中的测试星期二系列,尤其是这两个屏幕截图:

http://blog.codeship.io/2013/04/30/bdd-with-cucumber.html

http://blog.codeship.io/2013/05/07/testing-tuesday-4-continuous-integration-and-deployment-with-cucumber.html

两者都在一步一步地解释你想要什么。

于 2013-08-26T15:43:00.343 回答