[TFUI] custom, nested HTML matchers in RSpec
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]'
>> end
>> end
>> end
> I like this a lot.
Boom: http://gist.github.com/76136
it 'should have a form with a fieldset' do
render '/users/new'
response.body.should be_html_with{
form :action => '/users' do
fieldset do
legend 'Personal Information'
label 'First name'
input :type => 'text', :name => 'user[first_name]'
end
end
}
end
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...
--
Phlip
http://www.zeroplayer.com/
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch format to Traditional
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe
RSS Feed