[TFUI] custom, nested HTML matchers in RSpec
2009-03-09 06:59:14 GMT
Zach Dennis wrote:
>> response.body.should be_xml_with do
>> form :action => '/users' do
>> fieldset do
>> legend "Personal Information"
>> label "First name"
>> input :type => 'text', :name => 'user[first_name]'
> I like this a lot.
it 'should have a form with a fieldset' do
form :action => '/users' do
legend 'Personal Information'
label 'First name'
input :type => 'text', :name => 'user[first_name]'
I think I never got around to writing that because I just always assumed someone
already had. I have to watch that about myself!
Only one feature is missing: At fault time, the matcher naturally prints out a
diagnostic containing two snips of HTML - the specification's reference, and
your page's sample. (Both, of course, are restricted to the fault's context -
not the whole page.) But...
The samples are not indented! The specification's reference is all run together,
and your page's sample is (unfortunately!) exactly the way your View system
generated it. I have a question out to Nokogiri about this...