【问题标题】:Check content of attributes using rspec+webrat使用 rspec+webrat 检查属性内容
【发布时间】:2012-02-27 02:19:24
【问题描述】:

使用 rspec+webrat 您可以检查各种属性,例如 :href:content:class 等,但我如何检查 html5 自定义属性的内容。似乎在抱怨属性名的第二部分。

如果属性是'data-random',我尝试使用have_selector('li', :data-random => 'string'),它会抱怨randomundefined local variable or method

【问题讨论】:

    标签: ruby-on-rails html rspec webrat


    【解决方案1】:

    我认为这更多地与 Ruby 符号的语法有关。它们不能包含连字符,除非它们被引用。试试这个:

    have_selector('li', :'data-random' => 'string')
    

    【讨论】:

    • 好像也不喜欢。
    • 糟糕!刚刚尝试再次使用它:'data-method' => "delete",它成功了。
    • 如何检查显示:rspec+webrat 中的块?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-04
    • 2010-11-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多