在行动书的路轨3的黄瓜

时间:2013-08-26 15:31:06

标签: ruby-on-rails ruby-on-rails-3 cucumber

我在第二章

中有动作3中的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)

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

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

1 个答案:

答案 0 :(得分: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

两者都在逐步解释你想要的东西。