復習のために再現してみる 2009-10-10 gemの確認$ sudo gem list nokogiri -b $ sudo gem list webrat -b cukeのバージョンひとつ古いけどまあいいか ちなみに履歴見ると cucumberとwebratがなくてしかもgemが古いって言われてgem自体のupdateを会場でえいやでやっている gemのupdateはえいやでしたくない $ sudo gem update --system $ sudo gem install cucumber $ sudo gem install webrat $ sudo gem install moro-miso -r --source=http://gems.github.com todokata1アプリを作る
create create app/controllers create app/helpers create app/models create app/views/layouts create config/environments create config/initializers create config/locales create db create doc create lib create lib/tasks create log create public/images create public/javascripts create public/stylesheets create script/performance create test/fixtures create test/functional create test/integration create test/performance create test/unit create vendor create vendor/plugins create tmp/sessions create tmp/sockets create tmp/cache create tmp/pids create Rakefile create README create app/controllers/application_controller.rb create app/helpers/application_helper.rb create config/database.yml create config/routes.rb create config/locales/en.yml create db/seeds.rb create config/initializers/backtrace_silencers.rb create config/initializers/inflections.rb create config/initializers/mime_types.rb create config/initializers/new_rails_defaults.rb create config/initializers/session_store.rb create config/environment.rb create config/boot.rb create config/environments/production.rb create config/environments/development.rb create config/environments/test.rb create script/about create script/console create script/dbconsole create script/destroy create script/generate create script/runner create script/server create script/plugin create script/performance/benchmarker create script/performance/profiler create test/test_helper.rb create test/performance/browsing_test.rb create public/404.html create public/422.html create public/500.html create public/index.html create public/favicon.ico create public/robots.txt create public/images/rails.png create public/javascripts/prototype.js create public/javascripts/effects.js create public/javascripts/dragdrop.js create public/javascripts/controls.js create public/javascripts/application.js create doc/README_FOR_APP create log/server.log create log/production.log create log/development.log create log/test.log ファイルがいっぱい。 アプリに移動して、ディレクトリ一覧 $ cd todokata1/ $ ls -al 合計 68 drwxrwsr-x 13 sane web 4096 10月 10 19:26 . drwxrwsr-x 11 sane web 4096 10月 10 19:26 .. -rw-rw-r-- 1 sane web 10011 10月 10 19:26 README -rw-rw-r-- 1 sane web 307 10月 10 19:26 Rakefile drwxrwsr-x 6 sane web 4096 10月 10 19:26 app drwxrwsr-x 5 sane web 4096 10月 10 19:26 config drwxrwsr-x 2 sane web 4096 10月 10 19:26 db drwxrwsr-x 2 sane web 4096 10月 10 19:26 doc drwxrwsr-x 3 sane web 4096 10月 10 19:26 lib drwxrwsr-x 2 sane web 4096 10月 10 19:26 log drwxrwsr-x 5 sane web 4096 10月 10 19:26 public drwxrwsr-x 3 sane web 4096 10月 10 19:26 script drwxrwsr-x 7 sane web 4096 10月 10 19:26 test drwxrwsr-x 6 sane web 4096 10月 10 19:26 tmp drwxrwsr-x 3 sane web 4096 10月 10 19:26 vendor script/generateに限らずだけれど、--helpつけると親切表示が一杯出る。 へー
Usage: script/generate generator [options] [args] Rails Info: -v, --version Show the Rails version number and quit. -h, --help Show this help message and quit. General Options: -p, --pretend Run but do not make any changes. -f, --force Overwrite files that already exist. -s, --skip Skip files that already exist. -q, --quiet Suppress normal output. -t, --backtrace Debugging: show backtrace on errors. -c, --svn Modify files with subversion. (Note: svn must be in path) -g, --git Modify files with git. (Note: git must be in path) Installed Generators Rubygems: cucumber, feature, integration_spec, miso, rspec, rspec_controller, rspec_model, rspec_scaffold Builtin: controller, helper, integration_test, mailer, metal, migration, model, observer, performance_test, plugin, resource, scaffold, session_migration 以下略 Installed Generatorsにcucumberとmisoがいるのを確認した。 $ script/generate cucumber create features/step_definitions create features/step_definitions/webrat_steps.rb create config/environments/cucumber.rb create features/support create features/support/env.rb create features/support/paths.rb exists lib/tasks create lib/tasks/cucumber.rake create script/cucumber $ script/generate miso exists features/step_definitions create features/step_definitions/webrat_ja_steps.rb create features/step_definitions/web_extra_ja_steps.rb $ script/generate scaffold todo todo:text exists app/models/ exists app/controllers/ exists app/helpers/ create app/views/todos exists app/views/layouts/ exists test/functional/ exists test/unit/ create test/unit/helpers/ exists public/stylesheets/ create app/views/todos/index.html.erb create app/views/todos/show.html.erb create app/views/todos/new.html.erb create app/views/todos/edit.html.erb create app/views/layouts/todos.html.erb create public/stylesheets/scaffold.css create app/controllers/todos_controller.rb create test/functional/todos_controller_test.rb create app/helpers/todos_helper.rb create test/unit/helpers/todos_helper_test.rb route map.resources :todos dependency model exists app/models/ exists test/unit/ exists test/fixtures/ create app/models/todo.rb create test/unit/todo_test.rb create test/fixtures/todos.yml create db/migrate create db/migrate/20091010105525_create_todos.rb $ script/generate feature todos exists features/step_definitions create features/manage_todos.feature create features/step_definitions/todos_steps.rb $ rake features (in /home/sane/railsapp/todokata1) You have 1 pending migrations: 20091010105525 CreateTodos Run "rake db:migrate" to update your database then try again. はい。 $ rake db:migrate (in /home/sane/railsapp/todokata1) == CreateTodos: migrating ==================================================== -- create_table(:todos) -> 0.0045s == CreateTodos: migrated (0.0053s) =========================================== $ rake features (in /home/sane/railsapp/todokata1) /usr/local/bin/ruby -I "/usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/lib:lib" "/usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/cucumber" --color --tags ~@wip --strict --format pretty features/manage_todos.feature Feature: Manage todos In order to [goal] [stakeholder] wants [behaviour] Scenario: Register new todos # features/manage_todos.feature:6 Given I am on the new todos page # features/step_definitions/webrat_steps.rb:6 undefined method `new_todos_path' for #<ActionController::Integration::Session:0xb7404fa4> (NoMethodError) /home/sane/railsapp/todokata1/features/support/paths.rb:14:in `/^I am on (.+)$/' features/manage_todos.feature:7:in `Given I am on the new todos page' And I press "Create" # features/step_definitions/webrat_steps.rb:14 Scenario: Delete todos # features/manage_todos.feature:10 Given the following todos: # features/step_definitions/todos_steps.rb:1 | | | | | | | | | | uninitialized constant Todos (NameError) features/manage_todos.feature:11:in `Given the following todos:' When I delete the 3rd todos # features/step_definitions/todos_steps.rb:5 Then I should see the following todos: # features/step_definitions/todos_steps.rb:12 | | | | | | | | Failing Scenarios: cucumber features/manage_todos.feature:6 # Scenario: Register new todos cucumber features/manage_todos.feature:10 # Scenario: Delete todos 2 scenarios (2 failed) 5 steps (2 failed, 3 skipped) 0m0.116s rake aborted! Command failed with status (1): [/usr/local/bin/ruby -I "/usr/local/lib/rub...] (See full trace by running task with --trace) エラー さてここからhistoryの順番が分からないので手探りで進む なんか、空っぽすぎておかしい cucumberでググって出てくる情報とちょっと違う 間違えたっぽいのでfeatureをデストローイする $ script/destroy feature todos rm features/step_definitions/todos_steps.rb rm features/manage_todos.feature notempty features/step_definitions notempty features もう一度genearate feature 今度はカラム情報も追加した $ script/generate feature todos todo:text exists features/step_definitions create features/manage_todos.feature create features/step_definitions/todos_steps.rb そもそもなにか命名規則を間違えたようだ が、それはあとで見直す 修正 undefined method `new_todos_path' for #<ActionController::Integration::Session:0xb7404fa4> (NoMethodError)
/home/sane/railsapp/todokata1/features/support/paths.rb:14:in `/^I am on (.+)$/' $ view features/support/paths.rb module NavigationHelpers # Maps a name to a path. Used by the # # When /^I go to (.+)$/ do |page_name| # # step definition in webrat_steps.rb # def path_to(page_name) case page_name when /the homepage/ '/' when /the new todos page/ new_todos_path when /the new todos page/ new_todos_path when /the new todos page/ new_todos_path 以下略 $ vi features/support/paths.rb
module NavigationHelpers
# Maps a name to a path. Used by the
#
# When /^I go to (.+)$/ do |page_name|
#
# step definition in webrat_steps.rb
#
def path_to(page_name)
case page_name
when /the homepage/
'/'
when /the new todos page/
new_todo_path
when /the new todos page/
new_todo_path
when /the new todos page/
new_todo_path 以下略 気を取り直してrake features $ rake features (in /home/sane/railsapp/todokata1) /usr/local/bin/ruby -I "/usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/lib:lib" "/usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/cucumber" --color --tags ~@wip --strict --format pretty features/manage_todos.feature Feature: Manage todos In order to [goal] [stakeholder] wants [behaviour] Scenario: Register new todos # features/manage_todos.feature:6 Given I am on the new todos page # features/step_definitions/webrat_steps.rb:6 When I fill in "Todo" with "todo 1" # features/step_definitions/webrat_steps.rb:26 And I press "Create" # features/step_definitions/webrat_steps.rb:14 Then I should see "todo 1" # features/step_definitions/webrat_steps.rb:118 Scenario: Delete todos # features/manage_todos.feature:12 Given the following todos: # features/step_definitions/todos_steps.rb:1 | todo | | todo 1 | | todo 2 | | todo 3 | | todo 4 | uninitialized constant Todos (NameError) features/manage_todos.feature:13:in `Given the following todos:' When I delete the 3rd todos # features/step_definitions/todos_steps.rb:5 Then I should see the following todos: # features/step_definitions/todos_steps.rb:12 | Todo | | todo 1 | | todo 2 | | todo 4 | Failing Scenarios: cucumber features/manage_todos.feature:12 # Scenario: Delete todos 2 scenarios (1 failed, 1 passed) 7 steps (1 failed, 2 skipped, 4 passed) 0m0.441s rake aborted! Command failed with status (1): [/usr/local/bin/ruby -I "/usr/local/lib/rub...] (See full trace by running task with --trace) 半分通るようになった。 次。 uninitialized constant Todos (NameError)
features/manage_todos.feature:13:in `Given the following todos:' って言ってるのでTodoにしてやる(ればいいのだと思う) $ view features/step_definitions/todos_steps.rb Given /^the following todos:$/ do |todos| Todos.create!(todos.hashes) end When /^I delete the (\d+)(?:st|nd|rd|th) todos$/ do |pos| visit todos_url within("table > tr:nth-child(#{pos.to_i+1})") do click_link "Destroy" end end Then /^I should see the following todos:$/ do |expected_todos_table| expected_todos_table.diff!(table_at('table').to_a) end $ vi features/step_definitions/todos_steps.rb Given /^the following todos:$/ do |todos| Todo.create!(todos.hashes) end When /^I delete the (\d+)(?:st|nd|rd|th) todos$/ do |pos| visit todos_url within("table > tr:nth-child(#{pos.to_i+1})") do click_link "Destroy" end end Then /^I should see the following todos:$/ do |expected_todos_table| expected_todos_table.diff!(table_at('table').to_a) end もう一度 rake features $ rake features (in /home/sane/railsapp/todokata1) /usr/local/bin/ruby -I "/usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/lib:lib" "/usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/cucumber" --color --tags ~@wip --strict --format pretty features/manage_todos.feature Feature: Manage todos In order to [goal] [stakeholder] wants [behaviour] Scenario: Register new todos # features/manage_todos.feature:6 Given I am on the new todos page # features/step_definitions/webrat_steps.rb:6 When I fill in "Todo" with "todo 1" # features/step_definitions/webrat_steps.rb:26 And I press "Create" # features/step_definitions/webrat_steps.rb:14 Then I should see "todo 1" # features/step_definitions/webrat_steps.rb:118 Scenario: Delete todos # features/manage_todos.feature:12 Given the following todos: # features/step_definitions/todos_steps.rb:1 | todo | | todo 1 | | todo 2 | | todo 3 | | todo 4 | When I delete the 3rd todos # features/step_definitions/todos_steps.rb:5 Then I should see the following todos: # features/step_definitions/todos_steps.rb:12 | Todo | | todo 1 | | todo 2 | | todo 4 | 2 scenarios (2 passed) 7 steps (7 passed) 0m0.456s *** The 'features' task is deprecated. See rake -T cucumber *** 全部グリーン! ただdeprecatedだって言われてるので $ rake -T cucumber (in /home/sane/railsapp/todokata1) rake cucumber # Alias for cucumber:ok rake cucumber:all # Run all features rake cucumber:ok # Run features that should pass rake cucumber:wip # Run features that are being worked on $ rake cucumber (in /home/sane/railsapp/todokata1) /usr/local/bin/ruby -I "/usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/lib:lib" "/usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/cucumber" --color --tags ~@wip --strict --format pretty features/manage_todos.feature Feature: Manage todos In order to [goal] [stakeholder] wants [behaviour] Scenario: Register new todos # features/manage_todos.feature:6 Given I am on the new todos page # features/step_definitions/webrat_steps.rb:6 When I fill in "Todo" with "todo 1" # features/step_definitions/webrat_steps.rb:26 And I press "Create" # features/step_definitions/webrat_steps.rb:14 Then I should see "todo 1" # features/step_definitions/webrat_steps.rb:118 Scenario: Delete todos # features/manage_todos.feature:12 Given the following todos: # features/step_definitions/todos_steps.rb:1 | todo | | todo 1 | | todo 2 | | todo 3 | | todo 4 | When I delete the 3rd todos # features/step_definitions/todos_steps.rb:5 Then I should see the following todos: # features/step_definitions/todos_steps.rb:12 | Todo | | todo 1 | | todo 2 | | todo 4 | 2 scenarios (2 passed) 7 steps (7 passed) 0m0.340s やたっ! あと、どこかのタイミングでdatabase.ymlがちょっと違う見たことないのが書いてある
# SQLite version 3.x # gem install sqlite3-ruby (not necessary on OS X Leopard) development: adapter: sqlite3 database: db/development.sqlite3 pool: 5 timeout: 5000 # Warning: The database defined as "test" will be erased and # re-generated from your development database when you run "rake". # Do not set this db to the same as development or production. test: &TEST adapter: sqlite3 database: db/test.sqlite3 pool: 5 timeout: 5000 production: adapter: sqlite3 database: db/production.sqlite3 pool: 5 timeout: 5000 cucumber: <<: *TEST はじめから? kata2で確認しよう。このDSLは何も見ずには書けないだろこれ 日本語でシナリオを書く次に日本語 アプリのルートにcucumber.ymlを作る $ vi cucumber.yml default: --language ja $ rake cucumber (in /home/sane/railsapp/todokata1) /usr/local/bin/ruby -I "/usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/lib:lib" "/usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/cucumber" --color --tags ~@wip --strict --format pretty features/manage_todos.feature Using the default profile... Feature: Manage todos In order to [goal] [stakeholder] wants [behaviour] Scenario: Register new todos Given I am on the new todos page When I fill in "Todo" with "todo 1" And I press "Create" Then I should see "todo 1" Scenario: Delete todos Given the following todos: |todo| |todo 1| |todo 2| |todo 3| |todo 4| When I delete the 3rd todos Then I should see the following todos: |Todo| |todo 1| |todo 2| |todo 4| 0 scenarios 0 steps 0m0.003s 何も反応しなくなる。いいのかなこの挙動で。 $ view /usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/lib/cucumber/languages.yml 略 "ja": name: Japanese native: 日本語 encoding: UTF-8 feature: フィーチャ|機能 background: 背景 scenario: シナリオ scenario_outline: シナリオアウトライン|シナリオテンプレート|テンプレ|シナリオテンプレ examples: 例|サンプル given: 前提 when: もし then: ならば and: かつ but: しかし|但し space_after_keyword: false 略 languages.ymlを見ながら日本語に置き換えていく $ vi features/manage_todos.feature 機能: Manage todos In order to [goal] [stakeholder] wants [behaviour] シナリオ: Register new todos 前提 I am on the new todos page もし I fill in "Todo" with "todo 1" かつ I press "Create" ならば I should see "todo 1" Scenario: Delete todos Given the following todos: |todo| |todo 1| |todo 2| |todo 3| |todo 4| When I delete the 3rd todos Then I should see the following todos: |Todo| |todo 1| |todo 2| |todo 4| おそるおそる $ rake cucumber (in /home/sane/railsapp/todokata1) /usr/local/bin/ruby -I "/usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/lib:lib" "/usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/cucumber" --color --tags ~@wip --strict --format pretty features/manage_todos.feature Using the default profile... features/manage_todos.feature:12:3: Parse error, expected one of "|", "\"\"\"", "\n", "\r", "#", "前提", "もし", "ならば", "かつ", "しかし", "但し", "@", "シナリオ", "シナリオアウ トライン", "シナリオテンプレート", "テンプレ", "シナリオテンプレ". (Cucumber::Parser::SyntaxError) /usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/../lib/cucumber/parser/treetop_ext.rb:30:in `parse_or_fail' /usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/../lib/cucumber/parser/natural_language.rb:43:in `parse' /usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/../lib/cucumber/feature_file.rb:27:in `parse' /usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/../lib/cucumber/step_mother.rb:69:in `load_plain_text_features' /usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/../lib/cucumber/step_mother.rb:67:in `each' /usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/../lib/cucumber/step_mother.rb:67:in `load_plain_text_features' /usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/../lib/cucumber/cli/main.rb:48:in `execute!' /usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/../lib/cucumber/cli/main.rb:24:in `execute' /usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/cucumber:9 rake aborted! Command failed with status (1): [/usr/local/bin/ruby -I "/usr/local/lib/rub...] (See full trace by running task with --trace) 半端に日本語になってるとrakeが失敗する。やだなこれ $ vi features/manage_todos.feature 機能: Manage todos In order to [goal] [stakeholder] wants [behaviour] シナリオ: Register new todos 前提 I am on the new todos page もし I fill in "Todo" with "todo 1" かつ I press "Create" ならば I should see "todo 1" シナリオ: Delete todos 前提 the following todos: |todo| |todo 1| |todo 2| |todo 3| |todo 4| もし I delete the 3rd todos ならば I should see the following todos: |Todo| |todo 1| |todo 2| |todo 4| 全部日本語にするとオールグリーン! $ rake cucumber (in /home/sane/railsapp/todokata1) /usr/local/bin/ruby -I "/usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/lib:lib" "/usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/cucumber" --color --tags ~@wip --strict --format pretty features/manage_todos.feature Using the default profile... 機能: Manage todos In order to [goal] [stakeholder] wants [behaviour] シナリオ: Register new todos # features/manage_todos.feature:6 前提 I am on the new todos page # features/step_definitions/webrat_steps.rb:6 もし I fill in "Todo" with "todo 1" # features/step_definitions/webrat_steps.rb:26 かつ I press "Create" # features/step_definitions/webrat_steps.rb:14 ならば I should see "todo 1" # features/step_definitions/webrat_steps.rb:118 シナリオ: Delete todos # features/manage_todos.feature:12 前提 the following todos: # features/step_definitions/todos_steps.rb:1 | todo | | todo 1 | | todo 2 | | todo 3 | | todo 4 | もし I delete the 3rd todos # features/step_definitions/todos_steps.rb:5 ならば I should see the following todos: # features/step_definitions/todos_steps.rb:12 | Todo | | todo 1 | | todo 2 | | todo 4 | 2 scenarios (2 passed) 7 steps (7 passed) 0m0.704s 次にキーワード以外のものを日本語に置き換える $ view features/step_definitions/webrat_ja_steps.rb と照らし合わせて。 $ vi features/manage_todos.feature 機能: Manage todos In order to [goal] [stakeholder] wants [behaviour] シナリオ: todoを登録する 前提 I am on the new todos page もし "Todo"に"todo 1"と入力する かつ I press "Create" ならば I should see "todo 1" シナリオ: Delete todos 前提 the following todos: |todo| |todo 1| |todo 2| |todo 3| |todo 4| もし I delete the 3rd todos ならば I should see the following todos: |Todo| |todo 1| |todo 2| |todo 4| 前提に対応しそうなI am on ペケペケがないぞ 自分で書くのかな $ rake cucumber (in /home/sane/railsapp/todokata1) /usr/local/bin/ruby -I "/usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/lib:lib" "/usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/cucumber" --color --tags ~@wip --strict --format pretty features/manage_todos.feature Using the default profile... 機能: Manage todos In order to [goal] [stakeholder] wants [behaviour] シナリオ: todoを登録する # features/manage_todos.feature:6 前提 I am on the new todos page # features/step_definitions/webrat_steps.rb:6 もし "Todo"に"todo 1"と入力する # features/step_definitions/webrat_ja_steps.rb:19 かつ I press "Create" # features/step_definitions/webrat_steps.rb:14 ならば I should see "todo 1" # features/step_definitions/webrat_steps.rb:118 シナリオ: Delete todos # features/manage_todos.feature:12 前提 the following todos: # features/step_definitions/todos_steps.rb:1 | todo | | todo 1 | | todo 2 | | todo 3 | | todo 4 | もし I delete the 3rd todos # features/step_definitions/todos_steps.rb:5 ならば I should see the following todos: # features/step_definitions/todos_steps.rb:12 | Todo | | todo 1 | | todo 2 | | todo 4 | 2 scenarios (2 passed) 7 steps (7 passed) 0m0.652s $ vi features/manage_todos.feature 機能: Manage todos In order to [goal] [stakeholder] wants [behaviour] シナリオ: todoを登録する 前提 I am on the new todos page もし "Todo"に"todo 1"と入力する かつ "Create"ボタンをクリックする ならば "todo 1"と表示されていること シナリオ: Delete todos 前提 the following todos: |todo| |todo 1| |todo 2| |todo 3| |todo 4| もし I delete the 3rd todos ならば I should see the following todos: |Todo| |todo 1| |todo 2| |todo 4| $ rake cucumber (in /home/sane/railsapp/todokata1) /usr/local/bin/ruby -I "/usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/lib:lib" "/usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/cucumber" --color --tags ~@wip --strict --format pretty features/manage_todos.feature Using the default profile... 機能: Manage todos In order to [goal] [stakeholder] wants [behaviour] シナリオ: todoを登録する # features/manage_todos.feature:6 前提 I am on the new todos page # features/step_definitions/webrat_steps.rb:6 もし "Todo"に"todo 1"と入力する # features/step_definitions/webrat_ja_steps.rb:19 かつ "Create"ボタンをクリックする # features/step_definitions/webrat_ja_steps.rb:11 ならば "todo 1"と表示されていること # features/step_definitions/webrat_ja_steps.rb:93 シナリオ: Delete todos # features/manage_todos.feature:12 前提 the following todos: # features/step_definitions/todos_steps.rb:1 | todo | | todo 1 | | todo 2 | | todo 3 | | todo 4 | もし I delete the 3rd todos # features/step_definitions/todos_steps.rb:5 ならば I should see the following todos: # features/step_definitions/todos_steps.rb:12 | Todo | | todo 1 | | todo 2 | | todo 4 | 2 scenarios (2 passed) 7 steps (7 passed) 0m0.382s 前提あった $ rake cucumber (in /home/sane/railsapp/todokata1) /usr/local/bin/ruby -I "/usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/lib:lib" "/usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/cucumber" --color --tags ~@wip --strict --format pretty features/manage_todos.feature Using the default profile... 機能: Manage todos In order to [goal] [stakeholder] wants [behaviour] シナリオ: todoを登録する # features/manage_todos.feature:6 前提 "the new todos page"ページを表示している # features/step_definitions/webrat_ja_steps.rb:6 もし "Todo"に"todo 1"と入力する # features/step_definitions/webrat_ja_steps.rb:19 かつ "Create"ボタンをクリックする # features/step_definitions/webrat_ja_steps.rb:11 ならば "todo 1"と表示されていること # features/step_definitions/webrat_ja_steps.rb:93 シナリオ: Delete todos # features/manage_todos.feature:12 前提 the following todos: # features/step_definitions/todos_steps.rb:1 | todo | | todo 1 | | todo 2 | | todo 3 | | todo 4 | もし I delete the 3rd todos # features/step_definitions/todos_steps.rb:5 ならば I should see the following todos: # features/step_definitions/todos_steps.rb:12 | Todo | | todo 1 | | todo 2 | | todo 4 | 2 scenarios (2 passed) 7 steps (7 passed) 0m0.385s $ vi features/manage_todos.feature 機能: todoを管理する In order to [goal] [stakeholder] wants [behaviour] シナリオ: todoを登録する 前提 "the new todos page"ページを表示している もし "Todo"に"todo 1"と入力する かつ "Create"ボタンをクリックする ならば "todo 1"と表示されていること シナリオ: todoを削除する 前提 the following todos: |todo| |todo 1| |todo 2| |todo 3| |todo 4| もし I delete the 3rd todos ならば I should see the following todos: |Todo| |todo 1| |todo 2| |todo 4| $ rake cucumber (in /home/sane/railsapp/todokata1) /usr/local/bin/ruby -I "/usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/lib:lib" "/usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/cucumber" --color --tags ~@wip --strict --format pretty features/manage_todos.feature Using the default profile... 機能: todoを管理する In order to [goal] [stakeholder] wants [behaviour] シナリオ: todoを登録する # features/manage_todos.feature:6 前提 "the new todos page"ページを表示している # features/step_definitions/webrat_ja_steps.rb:6 もし "Todo"に"todo 1"と入力する # features/step_definitions/webrat_ja_steps.rb:19 かつ "Create"ボタンをクリックする # features/step_definitions/webrat_ja_steps.rb:11 ならば "todo 1"と表示されていること # features/step_definitions/webrat_ja_steps.rb:93 シナリオ: todoを削除する # features/manage_todos.feature:12 前提 the following todos: # features/step_definitions/todos_steps.rb:1 | todo | | todo 1 | | todo 2 | | todo 3 | | todo 4 | もし I delete the 3rd todos # features/step_definitions/todos_steps.rb:5 ならば I should see the following todos: # features/step_definitions/todos_steps.rb:12 | Todo | | todo 1 | | todo 2 | | todo 4 | 2 scenarios (2 passed) 7 steps (7 passed) 0m0.372s うおこれ以上サンプルに当てはまるものがないぞ このDSLはどうすれば… つづくつづく反省命名規則を間違っててはまったっぽい最後中途半端に終わった 再開(2009-10-17)moro-misoがgemcutterで最新版0.0.5になってるけど0.0.4のままで気にせず進む 俺共通step-definitionsをどこに書くのか確認するところからやる features/step_definitions/webrat_ja_steps.rb に直接書いたらmoro-misoのバージョンアップで涙目になると思う moro-misoのupdate前言撤回してmoro-misoを0.0.5にupdateしてみた。理由はgemcutter使ってみたかったから。 $ sudo gem update moro-miso --source http://gemcutter.org destroyしてからもう一度generateかな?とおもったけどgenerateのみで上書きした $ script/generate miso exists features/step_definitions overwrite features/step_definitions/webrat_ja_steps.rb? (enter "h" for help) [Ynaqdh] Y force features/step_definitions/webrat_ja_steps.rb identical features/step_definitions/web_extra_ja_steps.rb 個別のstepを書くthe following todos: features/step_definitions/todos_steps.rb にあった まさかのベタ全文正規表現 Given /^the following todos:$/ do |todos| Todo.create!(todos.hashes) end When /^I delete the (\d+)(?:st|nd|rd|th) todos$/ do |pos| visit todos_url within("table > tr:nth-child(#{pos.to_i+1})") do click_link "Destroy" end end Then /^I should see the following todos:$/ do |expected_todos_table| expected_todos_table.diff!(table_at('table').to_a) end 読み込む順番とかどうなってるんだろうとぐぐったけど分からないので勘で進める $ cp -a features/step_definitions/todos_steps.rb features/step_definitions/todos_ja_steps.rb webrat_ja_steps.rbがこういう命名だからそれにのっかる $ vi features/step_definitions/todos_ja_steps.rb Given /^todoに以下の項目がある:$/ do |todos| Todo.create!(todos.hashes) end When /^I delete the (\d+)(?:st|nd|rd|th) todos$/ do |pos| visit todos_url within("table > tr:nth-child(#{pos.to_i+1})") do click_link "Destroy" end end Then /^I should see the following todos:$/ do |expected_todos_table| expected_todos_table.diff!(table_at('table').to_a) end 一個書き換えてrake cucumber $ rake cucumber (in /home/sane/railsapp/todokata1) /usr/local/bin/ruby -I "/usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/lib:lib" "/usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/cucumber" --color --tags ~@wip --strict --format pretty features/manage_todos.feature Using the default profile... Multiple step definitions have the same Regexp: features/step_definitions/todos_steps.rb:5:in `/^I delete the (\d+)(?:st|nd|rd|th) todos$/' features/step_definitions/todos_ja_steps.rb:5:in `/^I delete the (\d+)(?:st|nd|rd|th) todos$/' (Cucumber::Redundant) /usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/../lib/cucumber/step_mother.rb:252:in `register_step_definition' /usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/../lib/cucumber/step_mother.rb:251:in `each' /usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/../lib/cucumber/step_mother.rb:251:in `register_step_definition' /usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/../lib/cucumber/step_mother.rb:98:in `register_step_definitions' /usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/../lib/cucumber/step_mother.rb:98:in `each' /usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/../lib/cucumber/step_mother.rb:98:in `register_step_definitions' /usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/../lib/cucumber/step_mother.rb:91:in `load_code_file' /usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/../lib/cucumber/step_mother.rb:82:in `load_code_files' /usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/../lib/cucumber/step_mother.rb:81:in `each' /usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/../lib/cucumber/step_mother.rb:81:in `load_code_files' /usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/../lib/cucumber/cli/main.rb:49:in `execute!' /usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/../lib/cucumber/cli/main.rb:24:in `execute' /usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/cucumber:9 rake aborted! Command failed with status (1): [/usr/local/bin/ruby -I "/usr/local/lib/rub...] (See full trace by running task with --trace) 同じ正規表現が二個あるとダメらしい とりあえずあとの二個をコメントアウト $ vi features/step_definitions/todos_ja_steps.rb Given /^todoに以下の項目がある:$/ do |todos| Todo.create!(todos.hashes) end #When /^I delete the (\d+)(?:st|nd|rd|th) todos$/ do |pos| # visit todos_url # within("table > tr:nth-child(#{pos.to_i+1})") do # click_link "Destroy" # end #end # #Then /^I should see the following todos:$/ do |expected_todos_table| # expected_todos_table.diff!(table_at('table').to_a) #end $ rake cucumber (in /home/sane/railsapp/todokata1) /usr/local/bin/ruby -I "/usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/lib:lib" "/usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/cucumber" --color --tags ~@wip --strict --format pretty features/manage_todos.feature Using the default profile... 機能: todoを管理する In order to [goal] [stakeholder] wants [behaviour] シナリオ: todoを登録する # features/manage_todos.feature:6 前提 "the new todos page"ページを表示している # features/step_definitions/webrat_ja_steps.rb:6 もし "Todo"に"todo 1"と入力する # features/step_definitions/webrat_ja_steps.rb:24 かつ "Create"ボタンをクリックする # features/step_definitions/webrat_ja_steps.rb:11 ならば "todo 1"と表示されていること # features/step_definitions/webrat_ja_steps.rb:113 シナリオ: todoを削除する # features/manage_todos.feature:12 前提 the following todos: # features/step_definitions/todos_steps.rb:1 | todo | | todo 1 | | todo 2 | | todo 3 | | todo 4 | もし I delete the 3rd todos # features/step_definitions/todos_steps.rb:5 ならば I should see the following todos: # features/step_definitions/todos_steps.rb:12 | Todo | | todo 1 | | todo 2 | | todo 4 | 2 scenarios (2 passed) 7 steps (7 passed) 0m0.415s グリーン! featuresをちょっとずつ日本語にする $ vi features/manage_todos.feature 機能: todoを管理する In order to [goal] [stakeholder] wants [behaviour] シナリオ: todoを登録する 前提 "the new todos page"ページを表示している もし "Todo"に"todo 1"と入力する かつ "Create"ボタンをクリックする ならば "todo 1"と表示されていること シナリオ: todoを削除する 前提 todoに以下の項目がある: |todo| |todo 1| |todo 2| |todo 3| |todo 4| もし I delete the 3rd todos ならば I should see the following todos: |Todo| |todo 1| |todo 2| |todo 4| $ rake cucumber (in /home/sane/railsapp/todokata1) /usr/local/bin/ruby -I "/usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/lib:lib" "/usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/cucumber" --color --tags ~@wip --strict --format pretty features/manage_todos.feature Using the default profile... 機能: todoを管理する In order to [goal] [stakeholder] wants [behaviour] シナリオ: todoを登録する # features/manage_todos.feature:6 前提 "the new todos page"ページを表示している # features/step_definitions/webrat_ja_steps.rb:6 もし "Todo"に"todo 1"と入力する # features/step_definitions/webrat_ja_steps.rb:24 かつ "Create"ボタンをクリックする # features/step_definitions/webrat_ja_steps.rb:11 ならば "todo 1"と表示されていること # features/step_definitions/webrat_ja_steps.rb:113 シナリオ: todoを削除する # features/manage_todos.feature:12 前提 todoに以下の項目がある: # features/step_definitions/todos_ja_steps.rb:1 | todo | | todo 1 | | todo 2 | | todo 3 | | todo 4 | もし I delete the 3rd todos # features/step_definitions/todos_steps.rb:5 ならば I should see the following todos: # features/step_definitions/todos_steps.rb:12 | Todo | | todo 1 | | todo 2 | | todo 4 | 2 scenarios (2 passed) 7 steps (7 passed) 0m0.239s グリーン! 日本語に $ vi features/step_definitions/todos_ja_steps.rb Given /^todoに以下の項目がある:$/ do |todos| Todo.create!(todos.hashes) end When /^(\d+)(?:番|個)目のtodoを削除する$/ do |pos| visit todos_url within("table > tr:nth-child(#{pos.to_i+1})") do click_link "Destroy" end end # #Then /^I should see the following todos:$/ do |expected_todos_table| # expected_todos_table.diff!(table_at('table').to_a) #end まだfeatureは変わってないのでrake cucubmerはグリーン $ rake cucumber (in /home/sane/railsapp/todokata1) /usr/local/bin/ruby -I "/usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/lib:lib" "/usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/cucumber" --color --tags ~@wip --strict --format pretty features/manage_todos.feature Using the default profile... 機能: todoを管理する In order to [goal] [stakeholder] wants [behaviour] シナリオ: todoを登録する # features/manage_todos.feature:6 前提 "the new todos page"ページを表示している # features/step_definitions/webrat_ja_steps.rb:6 もし "Todo"に"todo 1"と入力する # features/step_definitions/webrat_ja_steps.rb:24 かつ "Create"ボタンをクリックする # features/step_definitions/webrat_ja_steps.rb:11 ならば "todo 1"と表示されていること # features/step_definitions/webrat_ja_steps.rb:113 シナリオ: todoを削除する # features/manage_todos.feature:12 前提 todoに以下の項目がある: # features/step_definitions/todos_ja_steps.rb:1 | todo | | todo 1 | | todo 2 | | todo 3 | | todo 4 | もし I delete the 3rd todos # features/step_definitions/todos_steps.rb:5 ならば I should see the following todos: # features/step_definitions/todos_steps.rb:12 | Todo | | todo 1 | | todo 2 | | todo 4 | 2 scenarios (2 passed) 7 steps (7 passed) 0m0.254s featureを日本語にする $ vi features/manage_todos.feature 機能: todoを管理する In order to [goal] [stakeholder] wants [behaviour] シナリオ: todoを登録する 前提 "the new todos page"ページを表示している もし "Todo"に"todo 1"と入力する かつ "Create"ボタンをクリックする ならば "todo 1"と表示されていること シナリオ: todoを削除する 前提 todoに以下の項目がある: |todo| |todo 1| |todo 2| |todo 3| |todo 4| もし 3番目のtodoを削除する ならば I should see the following todos: |Todo| |todo 1| |todo 2| |todo 4| $ rake cucumber (in /home/sane/railsapp/todokata1) /usr/local/bin/ruby -I "/usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/lib:lib" "/usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/cucumber" --color --tags ~@wip --strict --format pretty features/manage_todos.feature Using the default profile... 機能: todoを管理する In order to [goal] [stakeholder] wants [behaviour] シナリオ: todoを登録する # features/manage_todos.feature:6 前提 "the new todos page"ページを表示している # features/step_definitions/webrat_ja_steps.rb:6 もし "Todo"に"todo 1"と入力する # features/step_definitions/webrat_ja_steps.rb:24 かつ "Create"ボタンをクリックする # features/step_definitions/webrat_ja_steps.rb:11 ならば "todo 1"と表示されていること # features/step_definitions/webrat_ja_steps.rb:113 シナリオ: todoを削除する # features/manage_todos.feature:12 前提 todoに以下の項目がある: # features/step_definitions/todos_ja_steps.rb:1 | todo | | todo 1 | | todo 2 | | todo 3 | | todo 4 | もし 3番目のtodoを削除する # features/step_definitions/todos_ja_steps.rb:5 ならば I should see the following todos: # features/step_definitions/todos_steps.rb:12 | Todo | | todo 1 | | todo 2 | | todo 4 | 2 scenarios (2 passed) 7 steps (7 passed) 0m0.285s グリーン! 日本語の文法を足す $ vi features/step_definitions/todos_ja_steps.rb Given /^todoに以下の項目がある:$/ do |todos| Todo.create!(todos.hashes) end When /^(\d+)(?:番|個)目のtodoを削除する$/ do |pos| visit todos_url within("table > tr:nth-child(#{pos.to_i+1})") do click_link "Destroy" end end Then /^todoに以下の項目が表示されていること:$/ do |expected_todos_table| expected_todos_table.diff!(table_at('table').to_a) end 脱線するけどこんなの書けないな というか、想像だけどこれ「表示されていること」でいいのかちょっと不明 expected_todos_table.diff!(table_at('table').to_a)
(in /home/sane/railsapp/todokata1) /usr/local/bin/ruby -I "/usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/lib:lib" "/usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/cucumber" --color --tags ~@wip --strict --format pretty features/manage_todos.feature Using the default profile... 機能: todoを管理する In order to [goal] [stakeholder] wants [behaviour] シナリオ: todoを登録する # features/manage_todos.feature:6 前提 "the new todos page"ページを表示している # features/step_definitions/webrat_ja_steps.rb:6 もし "Todo"に"todo 1"と入力する # features/step_definitions/webrat_ja_steps.rb:24 かつ "Create"ボタンをクリックする # features/step_definitions/webrat_ja_steps.rb:11 ならば "todo 1"と表示されていること # features/step_definitions/webrat_ja_steps.rb:113 シナリオ: todoを削除する # features/manage_todos.feature:12 前提 todoに以下の項目がある: # features/step_definitions/todos_ja_steps.rb:1 | todo | | todo 1 | | todo 2 | | todo 3 | | todo 4 | もし 3番目のtodoを削除する # features/step_definitions/todos_ja_steps.rb:5 ならば I should see the following todos: # features/step_definitions/todos_steps.rb:12 | Todo | | todo 1 | | todo 2 | | todo 4 | 2 scenarios (2 passed) 7 steps (7 passed) 0m0.242s featureを日本語に $ vi features/manage_todos.feature 機能: todoを管理する In order to [goal] [stakeholder] wants [behaviour] シナリオ: todoを登録する 前提 "the new todos page"ページを表示している もし "Todo"に"todo 1"と入力する かつ "Create"ボタンをクリックする ならば "todo 1"と表示されていること シナリオ: todoを削除する 前提 todoに以下の項目がある: |todo| |todo 1| |todo 2| |todo 3| |todo 4| もし 3番目のtodoを削除する ならば todoに以下の項目が表示されていること: |Todo| |todo 1| |todo 2| |todo 4| いざrake cucumber $ rake cucumber (in /home/sane/railsapp/todokata1) /usr/local/bin/ruby -I "/usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/lib:lib" "/usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/cucumber" --color --tags ~@wip --strict --format pretty features/manage_todos.feature Using the default profile... 機能: todoを管理する In order to [goal] [stakeholder] wants [behaviour] シナリオ: todoを登録する # features/manage_todos.feature:6 前提 "the new todos page"ページを表示している # features/step_definitions/webrat_ja_steps.rb:6 もし "Todo"に"todo 1"と入力する # features/step_definitions/webrat_ja_steps.rb:24 かつ "Create"ボタンをクリックする # features/step_definitions/webrat_ja_steps.rb:11 ならば "todo 1"と表示されていること # features/step_definitions/webrat_ja_steps.rb:113 シナリオ: todoを削除する # features/manage_todos.feature:12 前提 todoに以下の項目がある: # features/step_definitions/todos_ja_steps.rb:1 | todo | | todo 1 | | todo 2 | | todo 3 | | todo 4 | もし 3番目のtodoを削除する # features/step_definitions/todos_ja_steps.rb:5 ならば todoに以下の項目が表示されていること: # features/step_definitions/todos_ja_steps.rb:12 | Todo | | todo 1 | | todo 2 | | todo 4 | 2 scenarios (2 passed) 7 steps (7 passed) 0m0.253s グリーン! the new todos pageも日本語にしよう $ vi features/support/paths.rb module NavigationHelpers # Maps a name to a path. Used by the # # When /^I go to (.+)$/ do |page_name| # # step definition in webrat_steps.rb # def path_to(page_name) case page_name when /the homepage/ '/' when /the new todos page/ new_todo_path when /新しいtodo/ new_todo_path # Add more mappings here. # Here is a more fancy example: # # when /^(.*)'s profile page$/i # user_profile_path(User.find_by_login($1)) else raise "Can't find mapping from \"#{page_name}\" to a path.\n" + "Now, go and add a mapping in #{__FILE__}" end end end World(NavigationHelpers) rake cucumberでグリーンを確認 $ rake cucumber (in /home/sane/railsapp/todokata1) /usr/local/bin/ruby -I "/usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/lib:lib" "/usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/cucumber" --color --tags ~@wip --strict --format pretty features/manage_todos.feature Using the default profile... 機能: todoを管理する In order to [goal] [stakeholder] wants [behaviour] シナリオ: todoを登録する # features/manage_todos.feature:6 前提 "the new todos page"ページを表示している # features/step_definitions/webrat_ja_steps.rb:6 もし "Todo"に"todo 1"と入力する # features/step_definitions/webrat_ja_steps.rb:24 かつ "Create"ボタンをクリックする # features/step_definitions/webrat_ja_steps.rb:11 ならば "todo 1"と表示されていること # features/step_definitions/webrat_ja_steps.rb:113 シナリオ: todoを削除する # features/manage_todos.feature:12 前提 todoに以下の項目がある: # features/step_definitions/todos_ja_steps.rb:1 | todo | | todo 1 | | todo 2 | | todo 3 | | todo 4 | もし 3番目のtodoを削除する # features/step_definitions/todos_ja_steps.rb:5 ならば todoに以下の項目が表示されていること: # features/step_definitions/todos_ja_steps.rb:12 | Todo | | todo 1 | | todo 2 | | todo 4 | 2 scenarios (2 passed) 7 steps (7 passed) 0m0.289s featureを書き換える $ vi features/manage_todos.feature 機能: todoを管理する In order to [goal] [stakeholder] wants [behaviour] シナリオ: todoを登録する 前提 "新しいtodo"ページを表示している もし "Todo"に"todo 1"と入力する かつ "Create"ボタンをクリックする ならば "todo 1"と表示されていること シナリオ: todoを削除する 前提 todoに以下の項目がある: |todo| |todo 1| |todo 2| |todo 3| |todo 4| もし 3番目のtodoを削除する ならば todoに以下の項目が表示されていること: |Todo| |todo 1| |todo 2| |todo 4| rake cucumber $ rake cucumber (in /home/sane/railsapp/todokata1) /usr/local/bin/ruby -I "/usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/lib:lib" "/usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/cucumber" --color --tags ~@wip --strict --format pretty features/manage_todos.feature Using the default profile... 機能: todoを管理する In order to [goal] [stakeholder] wants [behaviour] シナリオ: todoを登録する # features/manage_todos.feature:6 前提 "新しいtodotodo"ページを表示している # features/step_definitions/webrat_ja_steps.rb:6 もし "Todo"に"todo 1"と入力する # features/step_definitions/webrat_ja_steps.rb:24 かつ "Create"ボタンをクリックする # features/step_definitions/webrat_ja_steps.rb:11 ならば "todo 1"と表示されていること # features/step_definitions/webrat_ja_steps.rb:113 シナリオ: todoを削除する # features/manage_todos.feature:12 前提 todoに以下の項目がある: # features/step_definitions/todos_ja_steps.rb:1 | todo | | todo 1 | | todo 2 | | todo 3 | | todo 4 | もし 3番目のtodoを削除する # features/step_definitions/todos_ja_steps.rb:5 ならば todoに以下の項目が表示されていること: # features/step_definitions/todos_ja_steps.rb:12 | Todo | | todo 1 | | todo 2 | | todo 4 | 2 scenarios (2 passed) 7 steps (7 passed) 0m0.267s グリーン! 前提 "新しいtodotodo"ページを表示している # features/step_definitions/webrat_ja_steps.rb:6 Createはやめて新規作成にする $ vi features/manage_todos.feature 機能: todoを管理する In order to [goal] [stakeholder] wants [behaviour] シナリオ: todoを登録する 前提 "新しいtodo"ページを表示している もし "Todo"に"todo 1"と入力する かつ "新規作成"ボタンをクリックする ならば "todo 1"と表示されていること シナリオ: todoを削除する 前提 todoに以下の項目がある: |todo| |todo 1| |todo 2| |todo 3| |todo 4| もし 3番目のtodoを削除する ならば todoに以下の項目が表示されていること: |Todo| |todo 1| |todo 2| |todo 4| rake cucumber $ rake cucumber (in /home/sane/railsapp/todokata1) /usr/local/bin/ruby -I "/usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/lib:lib" "/usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/cucumber" --color --tags ~@wip --strict --format pretty features/manage_todos.feature Using the default profile... 機能: todoを管理する In order to [goal] [stakeholder] wants [behaviour] シナリオ: todoを登録する # features/manage_todos.feature:6 前提 "新しいtodotodo"ページを表示している # features/step_definitions/webrat_ja_steps.rb:6 もし "Todo"に"todo 1"と入力する # features/step_definitions/webrat_ja_steps.rb:24 かつ "新規作成ヲ菴"ボタンをクリックする # features/step_definitions/webrat_ja_steps.rb:11 Could not find button "新規作成" (Webrat::NotFoundError) (eval):2:in `/^I press "([^\"]*)"$/' features/manage_todos.feature:9:in `かつ "新規作成"ボタンをクリックする' ならば "todo 1"と表示されていること # features/step_definitions/webrat_ja_steps.rb:113 シナリオ: todoを削除する # features/manage_todos.feature:12 前提 todoに以下の項目がある: # features/step_definitions/todos_ja_steps.rb:1 | todo | | todo 1 | | todo 2 | | todo 3 | | todo 4 | もし 3番目のtodoを削除する # features/step_definitions/todos_ja_steps.rb:5 ならば todoに以下の項目が表示されていること: # features/step_definitions/todos_ja_steps.rb:12 | Todo | | todo 1 | | todo 2 | | todo 4 | Failing Scenarios: cucumber features/manage_todos.feature:6 # Scenario: todoを登録する 2 scenarios (1 failed, 1 passed) 7 steps (1 failed, 1 skipped, 5 passed) 0m0.178s rake aborted! Command failed with status (1): [/usr/local/bin/ruby -I "/usr/local/lib/rub...] (See full trace by running task with --trace) レッド! それ以外に表示もおかしいけどそっち側はとりあえず保留 viewのボタン名称を直接日本語に書き換えてしまう $ vi app/views/todos/new.html.erb <h1>New todo</h1> <% form_for(@todo) do |f| %> <%= f.error_messages %> <p> <%= f.label :todo %><br /> <%= f.text_area :todo %> </p> <p> <%= f.submit '新規作成' %> </p> <% end %> <%= link_to 'Back', todos_path %> rake cucumber $ rake cucumber (in /home/sane/railsapp/todokata1) /usr/local/bin/ruby -I "/usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/lib:lib" "/usr/local/lib/ruby/gems/1.8/gems/cucumber-0.3.103/bin/cucumber" --color --tags ~@wip --strict --format pretty features/manage_todos.feature Using the default profile... 機能: todoを管理する In order to [goal] [stakeholder] wants [behaviour] シナリオ: todoを登録する # features/manage_todos.feature:6 前提 "新しいtodotodo"ページを表示している # features/step_definitions/webrat_ja_steps.rb:6 もし "Todo"に"todo 1"と入力する # features/step_definitions/webrat_ja_steps.rb:24 かつ "新規作成ヲ菴"ボタンをクリックする # features/step_definitions/webrat_ja_steps.rb:11 ならば "todo 1"と表示されていること # features/step_definitions/webrat_ja_steps.rb:113 シナリオ: todoを削除する # features/manage_todos.feature:12 前提 todoに以下の項目がある: # features/step_definitions/todos_ja_steps.rb:1 | todo | | todo 1 | | todo 2 | | todo 3 | | todo 4 | もし 3番目のtodoを削除する # features/step_definitions/todos_ja_steps.rb:5 ならば todoに以下の項目が表示されていること: # features/step_definitions/todos_ja_steps.rb:12 | Todo | | todo 1 | | todo 2 | | todo 4 | 2 scenarios (2 passed) 7 steps (7 passed) 0m0.242s グリーン! 出来た!完成! 感想知っている人に教えてもらうと早い…たぶん参考リンクcucumberに関して今(2009-10-18)ブラウザで開いてたタブにあったページなので直接関係あるものもないものもあるCucumber にふれてみた - yuum3のお仕事日記 CucumberとWebratの組み合わせが素晴らしすぎる - (゚∀゚)o彡 sasata299's blog Ruby Freaks Lounge:第22回 Railsアプリの受け入れテストをCucumberで書こう|gihyo.jp … 技術評論社 [Cucumber] stepsの作成ガイドライン - satoko's blog - s21g UK STUDIO - Cucumber+email_specでActionMailerのテストをする Cucumberがアツい - moroの日記 Cucumberでブログシステムの統合テストをする - koumiyaの日記 |
todo >