1
我想要更熟悉一些Rails/ActiveRecord。在試圖這樣做時,我試圖使用Cucumber來幫助進行一些「發現」測試。關於Cucumber/Pickle的問題
我有以下
Feature: Describing a task
In order to work with tasks
As a user
I want to be able to know what makes up a task and to improve my understanding of ActiveRecord
Scenario: A task has certain core fields
Given the following tasks exist
| id | name |
| 1 | some task |
And the following estimates exist
| task_id | hours | explanation |
| 1 | 8 | initial estimate |
| 1 | 6 | better undertsanding of task |
| 1 | 16 | no control over inputs to create task |
| 2 | 22 | for other task |
Then a task: "task" should exist with name: "some task" #this works
Then the estimate "estimate" should exist with explanation: "initial estimate" #this works
Then the estimate "estimate" should be one of task: "task"'s estimates #this works
Then the task "task" should have 3 estimates #this one fails
編輯
我沒有自定義的步驟 - 嘗試使用使用什麼出來與黃瓜泡菜盒子(只是限制我的困惑)。
這些模型
class Estimate < ActiveRecord::Base
belongs_to :Task, :class_name => "Task", :foreign_key => "Task_id"
end
和
class Task < ActiveRecord::Base
has_many :estimates
end
任何人都可以點我在正確的方向(或者,如果我需要發佈更多的代碼)?
感謝,
喬
你能張貼你的步驟/模型請。 – jonnii 2010-01-21 23:06:04
已添加。感謝您的期待 – Joe 2010-01-22 00:28:09