OSDN Git Service

refactor features
authorokimoto <okimoto@good-day.co.jp>
Mon, 15 Mar 2010 09:06:19 +0000 (18:06 +0900)
committerokimoto <okimoto@good-day.co.jp>
Mon, 15 Mar 2010 09:06:19 +0000 (18:06 +0900)
features/manage_unit.feature
features/step_definitions/common_steps.rb
features/step_definitions/unit_steps.rb [deleted file]
features/support/paths.rb

index c848b95..d07d223 100644 (file)
@@ -7,11 +7,8 @@
   シナリオ: ユニットを新規作成する
     前提   言語は"ja"
     かつ   "admin"としてログインしている
-    もし   "ホーム"ページを表示している
-    かつ   "admin"リンクをクリックする
-    かつ   "ユニット"リンクをクリックする
-    かつ   "New"リンクをクリックする
-    かつ   以下の項目を入力する:
+    かつ   "新規ユニット"ページを表示している
+    もし   以下の項目を入力する:
            | unit_name   | name   |
            | unit_symbol | symbol |
     かつ   "Save changes"ボタンをクリックする
@@ -19,7 +16,7 @@
 
   シナリオ: ユニットを削除する
     前提   言語は"ja"
-    かつ   以下のユニットを用意する:
+    かつ   以下の"units"を用意する:
            | name  | symbol   |
            | name1 | symbol_a |
            | name2 | symbol_b |
@@ -27,8 +24,9 @@
            | name4 | symbol_d |
            | name5 | symbol_e |
     かつ   "admin"としてログインしている
-    もし   "3"番目のユニットを削除する
-    ならば 以下のテーブルが"table#units tr"に表示されていること:
+    かつ   "ユニット一覧"ページを表示している
+    もし   "3"番目のレコードを削除する
+    ならば 以下のテーブルが"table.list tr"に表示されていること:
            | 表示名 | シンボル |
            | name1 | symbol_a |
            | name2 | symbol_b |
index 6663f74..20c90ef 100644 (file)
@@ -15,3 +15,21 @@ end
 Then /^以下のテーブルが"(.+?)"に表示されていること:$/ do |selector, expected|
   expected.diff!(tableish(selector, "th,td").to_a)
 end
+
+Given /^the following (.+?):$/ do |table_name, attributes|
+  table_name.classify.constantize.create!(attributes.hashes)
+end
+
+Given /^以下の"(.+?)"を用意する:$/ do |table_name, attributes|
+  Given %{the following #{table_name}:}, attributes
+end
+
+When /^I delete the (\d+)(?:st|nd|rd|th) records$/ do |pos|
+  within("table.list tbody tr:nth-child(#{pos.to_i})") do
+    click_link "Destroy"
+  end
+end
+
+When /^"(\d+)"番目のレコードを削除する$/ do |pos|
+  When %{I delete the #{pos}st records}
+end
diff --git a/features/step_definitions/unit_steps.rb b/features/step_definitions/unit_steps.rb
deleted file mode 100644 (file)
index 091f9fb..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-# -*- coding: utf-8 -*-
-Given /^the following units:$/ do |units|
-  Unit.create!(units.hashes)
-end
-
-Given /^以下のユニットを用意する:$/ do |units|
-  Given %{the following units:}, units
-end
-
-When /^I delete the (\d+)(?:st|nd|rd|th) units$/ do |pos|
-  visit admin_units_url
-  within("table#units tbody tr:nth-child(#{pos.to_i})") do
-    click_link "Destroy"
-  end
-end
-
-When /^"(\d+)"番目のユニットを削除する$/ do |pos|
-  When %{I delete the #{pos}st units}
-end
-
-Then /^I should see the following units:$/ do |expected_units_table|
-  expected_units_table.diff!(tableish('table tr', 'td,th'))
-end
index 74ce8e4..9756f07 100644 (file)
@@ -11,6 +11,9 @@ module NavigationHelpers
     
     when /the home\s?page/, /ホーム/
       '/'
+    when /the new affiliation page/, /新規所属/
+      new_admin_affiliation_path
+
     when /the new user page/
       new_admin_user_path
 
@@ -26,6 +29,10 @@ module NavigationHelpers
       url_for(:controller => '/auth')
     when /the admin page/, /管理/
       url_for(:controller => '/admin')
+    when /the units index page/, /ユニット一覧/
+      admin_units_path
+    when /the affiliations index page/, /所属一覧/
+      admin_affiliations_path
     else
       raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
         "Now, go and add a mapping in #{__FILE__}"