[rspec-devel] [ rspec-Feature Requests-6807 ] port assert_select

noreply at rubyforge.org noreply at rubyforge.org
Mon Jan 29 22:20:36 EST 2007


Feature Requests item #6807, was opened at 2006-11-21 19:27
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3152&aid=6807&group_id=797

Category: rails plugin
Group: None
>Status: Closed
Priority: 3
Submitted By: David Chelimsky (dchelimsky)
Assigned to: David Chelimsky (dchelimsky)
Summary: port assert_select

Initial Comment:
Add an rspec implementation of assert_select. Need to decide whether to just duplicate existing API (using repsonse.should_have?????) or actually devise a more integrated API like this:

repsonse.should_include(:form).with(:action => "blah")

or

response.should_include(:form).with do |form|
  form.should_include(:input).with(:name => 'age', :type => 'text')
end

or some such.

----------------------------------------------------------------------

>Comment By: David Chelimsky (dchelimsky)
Date: 2007-01-30 03:20

Message:
This was finished a few revs back (currently at 1442) - there is now support for:

response.should have_tag
response.should be_rjs
response.should be_feed
response.should send_email

See rdocs for Spec::Rails::Matchers for more information.



----------------------------------------------------------------------

Comment By: David Chelimsky (dchelimsky)
Date: 2007-01-19 13:00

Message:
We can't use it as/is because it's all bound to test/unit.

Right now there are 2 different implementations in the trunk. Over the next few days I'll clean this all up, doc it, and all will be right w/ the world.

----------------------------------------------------------------------

Comment By: Aslak Hellesøy (aslak_hellesoy)
Date: 2007-01-19 10:15

Message:
AFAICT assert_select is part of Rails core now. Can't we just use that? It seems like a lot of work to maintain our own.

What's really missing now is doco on how to use this.

----------------------------------------------------------------------

Comment By: David Chelimsky (dchelimsky)
Date: 2006-12-13 10:43

Message:
This is working w/ 1.2.0 and edge(5717) as of rspec rev 1286.

----------------------------------------------------------------------

Comment By: David Chelimsky (dchelimsky)
Date: 2006-12-08 22:00

Message:
I checked in a preliminary port (rev 1276). It only works w/ 1.1.6 right now, but it works just like assert_select for everything except rjs:

response.should_have (for tags w/ x-path like syntax)
response.should_have_encoded
response.should_have_email
response.should_have_feed

Remaining TODO:
Get it to work w/ 1.2.0 and edge
Figure out what to do about rjs (need a name other than should_have_rjs)
Clean up the docs

----------------------------------------------------------------------

Comment By: David Chelimsky (dchelimsky)
Date: 2006-11-22 13:00

Message:
Josh - a plugin would be great. Could you use should_have instead of should_select (which doesn't really mean anything in this context):

response.should_have "form>input[name=age][type=text]"

I'm assuming you've got this implemented on ResponseBody, so there should be no conflict w/ Should#have.

----------------------------------------------------------------------

Comment By: Josh Chisholm (joshchisholm)
Date: 2006-11-22 09:48

Message:
I implemented a basic response.should_select by mixing in scrAPI. Haven't brought it up to date with rspec 0.72 yet, but I will if someone advises the best way to do so (assuming we don't want a scrAPI dependency in rspec core? - a plugin??).

> The third seems to promote really detailed expectations about the HTML, and I think that way lies madness.

If I understand correcly the second example implies the form has a child (somewhere unspecified) with certain specified attributes. I don't find this too detailed and if I remember correctly this can be done with a single selector:

response.should_select "form>input[name=age][type=text]"

This syntax is all I have needed so far.

----------------------------------------------------------------------

Comment By: Wilson Bilkovich (wilson)
Date: 2006-11-21 22:43

Message:
I like the:
repsonse.should_include(:form).with(:action => "blah")
version, myself.
The third seems to promote really detailed expectations about the HTML, and I think that way lies madness.

If someone writes the specs for it, I will code it.



----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3152&aid=6807&group_id=797


More information about the rspec-devel mailing list