2009/6/13 Colin Law <[email protected]>:
> 2009/6/13 Marnen Laibow-Koser <[email protected]>:
>>
>> Colin Law wrote:
>> [...]
>>>> The right point for the break is after 'some text' and before 'some more
>>>> text'
>>
>> How about assert_select "p", /some text.*<br[^>]*>some more text/m ?
>>
>
> No that doesn't work. The br tag does not appear in the text for the
> p tag. This can be seen from the fact that
> assert_select "p", "some textsome more text"
> passes.
> I tried it just to check and it said
> /some text.*<br[^>]*>some more text/m expected but was
> some textsome more text
>
For anyone coming to this thread without the history I am trying to
use assert_select to verify the html
<p>some text<br>some more text</p>
I found a solution to this by adding span tags round my text
fragments, so that the html is now
<p><span>some text</span><br><span>some more text</span></p>
Then I can test it with
assert_select "p>span:first-of-type", "some text"
assert_select "p>span:first-of-type+br", 1
assert_select "p>span:nth-of-type(2)", "some more text"
This works but feel there must be a better solution than adding extra
tags to the html just so that it can be tested.
Colin
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---