ruby on rails - RSpec: should have_content can't find text -
i have following page
<ul class="account_menu dropdown-menu"> <li class="divider"></li> <li class="current"><span>my account</span></li> <li class="account"><a href="#">account-1 (editor)</a></li> </ul>
testing cucumber using step
within(scope) page.should have_content(content) end
test passes when content = 'account-1' , fails content = 'my account'. scope both cases 'account_menu'
and should see "my account" within account menu expected find text "my account" in "my accountaccount-1 (editor)" (rspec::expectations::expectationnotmeterror)
- rails 3.2.17
- rspec-rails 2.14.1
- capybara 2.1.0
why can't find 'my account' text? thanks
have_content
ends concatenating content in unexpected ways. in case
<li class="current"><span>my account</span></li> <li class="account"><a href="#">account-1 (editor)</a></li>
becomes "my accountaccount-1 (editor)"
if try
expect("my accountaccount-1 (editor)").to have_content("my account")
it fail technically correct since "my account " not in string. alternative use match
matcher or test concatenated string (ugly).
Comments
Post a Comment