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

noreply at rubyforge.org noreply at rubyforge.org
Wed Nov 22 08:00:39 EST 2006


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: Open
Priority: 3
Submitted By: David Chelimsky (dchelimsky)
Assigned to: Nobody (None)
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: 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