• 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

[追記 2009.01.20]script/generate featureの項を追加

moroさんの記事を読んで、Cucumber wktk!と思っていたのでtry

http://d.hatena.ne.jp/moro/20081112/1226486135
http://d.hatena.ne.jp/moro/20081118/1226977015
http://gist.github.com/26024

こちらの導入手順を参考しました:
http://wiki.github.com/aslakhellesoy/cucumber/ruby-on-rails

必要なgemをinstall

  • rspec
  • rspec-rails
  • cucumber
  • webrat

ローカルには0.1.15を入れたのですが、念のため0.1.13で依存しているというgem:aslakhellesoy-webratもinstallしました。

   1    gem sources -a http://gems.github.com
   2    sudo gem install aslakhellesoy-webrat

Webratを使うようにCucumberのenvに書く

${RAILS_ROOT}/features/support/env.rb

   1  require "webrat"
   2  Webrat.configure do |config|
   3    config.mode = :rails
   4  end     

script/generate feature

moroさんところのcucumberの構造辺りで紹介されているgeneratorでfeatureやstepsを生成:

   1  $ ruby script/generate feature Product

Webratの仕様が変わってた

moroさんのgistを下記に保存して使用し始めたのですが、

   1  ${RAILS_ROOT}/features/step_definitions/webrat_ja_steps.rb

細かい仕様が変更されていました:
ディレクトリstep_definitionsの位置も変わっているのに加えて、visits => visit、fills_in => fill_inなどが変更されていました。ただ、前もって調べなくても、rake featuresすると仕様変更された旨のmessageが出るので安心です。

   1   visit home_path 
   2   fill_in "Email", :with => "good@example.com"

またpendingされたstepには、下記のようにsnippetsが出力されて便利だなぁと思いました:

   1  You can use these snippets to implement pending steps which have no step definition:
   2  When /^パラメータを入力する product_comment\[body\]=dummy comment!$/ do
   3  end

Refs

http://moriq.tdiary.net/20081022.html
http://d.hatena.ne.jp/hs9587/20081231/1230691812
http://barkingiguana.com/2008/11/11/getting-started-with-story-driven-development-for-rails-with-cucumber

posted by Png satoko on Mon 19 Jan 2009 at 15:44
Contents
Cucumber 0.1.15を動かす
Comments
KingofSmack: Here also good reads for this mobile applicatio... '14-5
satoko: stackoverflowでも同じエラーを挙げている人がいたので、1.3でアップロードしたよっ... '10-12
ujihisa: :%s/blog/glob/g '10-7
satoko: しゅが〜様 返事が遅くなって申し訳ありません。また、投稿百景ご購入ありがとうございます。 ... '09-10
しゅが~: こんにちは。投稿百景を発売日翌日から利用しています。本当にいいAppを作っていただきました。罫... '09-10
Services from s21g
twpro(ツイプロ)
Twitterプロフィールを快適検索
地価2009
土地の値段を調べてみよう
MyRestaurant
自分だけのレストラン手帳
Formula
ブログに数式を埋め込める数式コミュニティ