• 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31

下記のページを参考にしました:
http://wiki.github.com/aslakhellesoy/cucumber/step-organisation

###モデル(テーブル)毎にstepsを作成する
原則はそれでいく、ただし認証などは別stepsとして作ったほうがベター:

  • employee_steps.rb
  • education_steps.rb
  • experience_steps.rb
  • authentication_steps.rb:認証用

all_steps.rbという巨大なファイルを作ることもできます。エレガントではないですけどね。

###モデルstepsには必ずGiven-When-Then stepを作る
モデルをカバーするようなstepsファイルでは、下記のCRUDをカバーするようなGiven-When-Then stepを書くことと。

  • 作成
  • 表示
  • 更新
  • 削除

###各stepsでは@variablesを作成して、オブジェクトの状態を保持できる
コントローラで取得する@userを下記のようなstepで記述できます:
rails>>
Give /^"(.*)"ユーザでログイン$/ do |login|
@user = User.find_by_login(login)
end
<<--
(注) 各stepで依存しあうことになり、再利用性が難しくなります
(注) 実際のログインシナリオはまた別にちゃんと記述する必要があります!

posted by satoko satoko on Fri 23 Jan 2009 at 15:42 with 0 comments