新手黄瓜范围问题

时间:2011-03-01 15:09:55

标签: cucumber

我正在尝试检查下面的html中的“style ='width:60%'”位

<div class='pers-ref-rate'>
  <div class='rating-type'>
    Reliability
  </div>
  <div class='type-reliable rating'>
    <div style='width:60%'></div>
  </div>
</div>

我有线

And I should see a personal reliable rating of 60 

以及我的步骤

中的以下内容
Then /^I should see a personal (\w+) rating of (\d+)$/ do |rating_type, rating|
  with_scope("div.type-#{rating_type}") do
    page.should have_css('.rating', :style => "width:#{rating}")
  end
end

我收到错误

RSpec::Expectations::ExpectationNotMetError: expected #has_css?(".rating") to return true, got false

我偷了另一个项目中的步骤并略微调整它(它使用的是id而不是类)。

我做错了什么?

提前感谢您的帮助。

标记

1 个答案:

答案 0 :(得分:1)

那是在寻找

<div class="rating" style='width:60%'></div>

范围内的

<div class='type-reliable rating'></div>

要使其正常工作,请将评级类添加到该div,或者删除其中的.rating的css搜索。

HTH