Forum: Ruby on Rails [ANN] assert2 presents assert_no_rjs_, and .should send_js_to

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Aafa8848c4b764f080b1b31a51eab73d?d=identicon&s=25 Phlip (Guest)
on 2009-04-11 19:25
(Received via mailing list)
assert_no_rjs_ now negates all the JavaScript assertions listed here:

http://groups.google.com/group/rubyonrails-talk/br...

And assert_rjs_ now works in RSpec:

     it 'should use Ajax to replace person 45' do
       xhr :get, :replace_person, :id => 45
       @response.body.should send_js_to(:replace_html, 'person_45') do
         strong 'person_45'
       end
     end

Once again, the do-end block calls Nokogiri::HTML::Builder to build a
sample of
HTML. The assertion then matches this to the HTML delivered in the
payload of
the JS Element.update() call.

The committee is unaware of any other RJS solution for RSpec...

(Sorry - no .should not_send_js_to yet..;)
Aafa8848c4b764f080b1b31a51eab73d?d=identicon&s=25 Phlip (Guest)
on 2009-04-12 18:33
(Received via mailing list)
> assert_no_rjs_ now negates all the JavaScript assertions listed here:
>
> http://groups.google.com/group/rubyonrails-talk/br...

> (Sorry - no .should not_send_js_to yet..;)

Version 0.5.1 fixes that: .should_not send_js_to

Next, assert_xhtml (and .should be_html_with) add the any! keyword:

     assert_xhtml do
       ul.kalika do
         any! 'Billings report'
       end
     end

It evaluates to the XPath * operator, so the above passes if any element
below
the <ul class='kalika'> contains any "Billings report".

This example fails if "Billings report" appears anywhere in the document
(assuming we _reeally_ don't like it!;):

     assert_xhtml do
       without!{ any! /Billings report/ }
     end

If anyone can think of new features to add to (or take out of) these
DSLs,
I'm all ears!

--
   Quark
F85bacbbd4814799d4526b3e35a431df?d=identicon&s=25 Brandon Olivares (Guest)
on 2009-04-12 18:51
(Received via mailing list)
Phlip,

Is there any plan to allow for negative assertions (e.g., should_not
be_html_with)? I use this in a custom matcher, and can't think of a way
to
support negative assertions unless be_html_with does.

I'm of course going by the output of negative_failure_message saying not
to
use it that way.

Brandon
Aafa8848c4b764f080b1b31a51eab73d?d=identicon&s=25 Phlip (Guest)
on 2009-04-12 18:55
(Received via mailing list)
Brandon Olivares wrote:

> Is there any plan to allow for negative assertions (e.g., should_not
> be_html_with)? I use this in a custom matcher, and can't think of a way to
> support negative assertions unless be_html_with does.

I can't think of a reason not to use .should be_html_with{ without!{
...} }

And it seems that .should_not be_html_with() would, in theory, pass if a
page
weren't HTML...
F85bacbbd4814799d4526b3e35a431df?d=identicon&s=25 Brandon Olivares (Guest)
on 2009-04-12 21:54
(Received via mailing list)
> ...} }
It could, if I could determine whether the matcher was being called with
.should or .should_not. I don't know of a way to do this?

Anyway I'm excited about this new release. Thanks.

Brandon
This topic is locked and can not be replied to.