求使用cucumber的feature文件中有sub table的读取方法

银古烟 2009-08-14 10:13:23
在feature文件中有子table

例如:
Scenario Outline: Religious menus
Given I am "<Religion>"
When I ask to see a menu
Then I should be presented a menu with meats entrees
<Meats>
And I should be presented a menu with hamburger types
<Hamburgers>

Examples:
| Religion | Meats | Hamburgers |
| * | Pork | Lamb | Veal | Hamburger | Cheeseburger |
| Christian | Y | Y | Y | Y | Y |
| Jewish | N | Y | Y | Y | N |
| Muslim | N | Y | Y | Y | Y |
| Hindu | N | Y | N | N | N |

现在如何读取这样的一个table?


http://gist.github.com/99424
这个没看明白,请高人指点..
...全文
177 点赞 收藏 2
写回复
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
tonyzhangcn 2012-05-10
这种写法应该连语法的过不去的。个数对不上.试试下面的这个,应该是可以用的
Scenario Outline: Religious menus
Given I am "<Religion>"
When I ask to see a menu
Then I should be presented a menu with meats entrees
| Pork | Lamb | Veal |
| <Pork> | <Lamb> | <Veal> |
And I should be presented a menu with hamburger types
| Hamburger | Cheeseburger |
| <Hamburger> | <Cheeseburger> |

Examples:
| Religion | Pork | Lamb | Veal | Hamburger | Cheeseburger |
| Christian | Y | Y | Y | Y | Y |
| Jewish | N | Y | Y | Y | N |
| Muslim | N | Y | Y | Y | Y |
| Hindu | N | Y | N | N | N |
回复
weiyanwei_victor 2012-04-17
Given /I am "(.+)"/ do |regligion|endThen /I should be presented a menu with meat entrees/ do |meat_hash| # 1: {'Pork'=>'Y', 'Lamb'=>'Y', 'Veal'=>'Y'} # 2: {'Pork'=>'N', 'Lamb'=>'Y', 'Veal'=>'Y'} # 3: {'Pork'=>'N', 'Lamb'=>'Y', 'Veal'=>'Y'} # 4: {'Pork'=>'N', 'Lamb'=>'Y', 'Veal'=>'N'}endThen /I should be presented a menu with hamburger types/ do |hamburger_hash| # 1: {'Hamburger'=>'Y', 'Cheeseburger'=>'Y'} # 2: {'Hamburger'=>'Y', 'Cheeseburger'=>'N'} # 3: {'Hamburger'=>'Y', 'Cheeseburger'=>'Y'} # 4: {'Hamburger'=>'N', 'Cheeseburger'=>'N'}end
这是hash的格式
回复
发动态
发帖子
Ruby/Rails
创建于2007-09-28

2745

社区成员

Web 开发 Ruby/Rails
申请成为版主
社区公告
暂无公告