开发者

Newbie Cucumber scope question

开发者 https://www.devze.com 2023-02-13 23:23 出处:网络
I am trying to check for the \"style=\'width:60%\'\" bit in the html be开发者_运维问答low <div class=\'pers-ref-rate\'>

I am trying to check for the "style='width:60%'" bit in the html be开发者_运维问答low

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

I have got the line

And I should see a personal reliable rating of 60 

and the following in my steps

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

I am getting an error

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

I stole the steps from another project and adapted it slightly (it was using ids not classes).

What have I done wrong?

Thanks in advance for any help.

Mark


That's looking for a

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

within the scope of

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

To make it work, either add the rating class to that div, or remove the css search for .rating in it.

hth

0

精彩评论

暂无评论...
验证码 换一张
取 消