Phlip,
Well, now it's not failing if there is an error. This passes:
it "should have a subject dropdown box" do
response.body.should be_html_with {
form.contact! do
label 'Subject'
select!.subject!
end
}
end # it "should have a subject dropdown box"
As it should, but the following passes as well, which should not:
it "should have a name field" do
response.body.should be_html_with {
form.contact! do
label 'Name'
input.name!
end
}
end # it "should have a name field"
There is most definitely not a name field, nor its associated label.
Thanks,
Brandon
> -----Original Message-----
> From: [email protected] [mailto:rspec-users-
> [email protected]] On Behalf Of Phlip
> Sent: Saturday, April 04, 2009 8:40 AM
> To: [email protected]
> Subject: Re: [rspec-users] Phlip's be_html_with was RE: Problem with
> Custom matcher and Blocks
>
> Brandon Olivares wrote:
>
> > I just found a custom matcher created by Phlip at
> > http://gist.github.com/76136
>
> That's just a sketch. The real deal is at...
>
> gem install nokogiri assert2
>
> require 'assert2/xhtml'
>
> Report if that works better. You might find its inside source code is a
> little
> nicer, too.
>
> > So I added that to my project, and it mostly works great for what I'm
> trying
> > to do, and the syntax is pretty nice.
> >
> > But anytime I try to use select, I get an error. I wonder if it's
> > conflicting with another method somewhere else?
>
> http://groups.google.com/group/merb/browse_thread/thread/3588d3f75fa0e6
> 5c
>
> Use select!. That's a missing feature in Nokogiri::HTML::Builder, and
> its author
> might fix it. Until then, Nokogiri and I use bangs for three reasons:
>
> convert a misunderstanding into innocent HTML
> convert potential HTML into a new keyword (:xpath!, without!)
> convert an element.class shortcut into an element.id!
>
> > So I wondered if there is a way to get around this, since I'd like to
> test
> > that my select field is there.
>
> it "should have a subject dropdown box" do
> response.body.should be_html_with {
> form.contact! do
> label 'Subject'
> select! :id => 'subject'
> end
> }
> end # it "should have a subject dropdown box"
>
> Notice two things, folks - Brandon started his assertion with a unique
> container
> object. That's nearly the only way to get reasonable diagnostics. I
> gave up on
> trying to report the "closest match", and now I only report the "first
> extent of
> HTML that matches your first element".
>
> Also notice that all assertions should have a "diagostic message"
> facility -
> like the third argument to the lowly assert_equal(in, out, message =
> nil). But
> assert_xhtml does not have a message=nil yet.
>
> I'm too busy this weekend making it interpret Ajax, as a drop-in
> replacement for
> assert_rjs:
>
> assert_rjs :replace_html, :label_7 do
> input.Top_Ranking! :type => :checked, :value => :Y
> input.cross_sale_1, :type => :hidden, :value => 7
> end
>
> You write the RJS you need to match (like assert_rjs classic uses), and
> then you
> add an assert_xhtml block, and it works on the Element.update() payload
> itself.
>
> http://groups.google.com/group/ruby-talk-google/msg/b94d83ad2d5e6536
>
> --
> Phlip
> http://www.zeroplayer.com/
>
> _______________________________________________
> rspec-users mailing list
> [email protected]
> http://rubyforge.org/mailman/listinfo/rspec-users
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users