Add title assertions to should_be_restful
Reported by Chris O'Sullivan | August 2nd, 2008 @ 04:15 AM
This patch adds title checking for the index, show, new & edit actions.
How this works is that when should_be_restful is created, you can set what titles each action should have using the following format:
resource.index.title = /index/ # Using regex
resource.show.title = "show" # Using a string
The defaults for the titles are (if the object is 'user'):
- show: /user/i
- new: /user/i
- edit: /user/i
- index: /users/i
This patch also adds a new macro
should_set_title_to
Comments and changes to this ticket
-
Chris O'Sullivan August 2nd, 2008 @ 04:22 AM
Hmm - I know there's a way to automatically grab a commit to github and connect it to lighthouse, but I must've messed it up.
Here's the url for the branch:
-
Tammer Saleh August 2nd, 2008 @ 08:25 AM
A couple of comments:
def should_set_title_to(title) should "set title to #{title.inspect}" do assert_select "title", title end endThat should really include a check for , just for completeness.
Also, it seems like this macro would be more useful if it allowed
checking for any metadata. Something like:
should_render_page_with_metadata :title => /foo/i, :description => / bar/iCheers,
Tammer
On Aug 2, 2008, at 4:22 AM, Lighthouse wrote:
-
Chris O'Sullivan August 29th, 2008 @ 06:16 AM
Hey Tammer,
I don't quite get what you mean by "That should really include a check for , just for completeness." - a check for nil?
Also, I guess why I'm so caught up about titles is that I think a good title is fundamental aspect of a good webpage, and it's something I find myself forgetting frequently. Having should_be_restful automatically bung in a title test for every page of the resource would be pretty handy.
-Chris
-
Tammer Saleh August 29th, 2008 @ 07:05 AM
Chris:
Lighthouse ate that part of the sentence. I was trying to say that the method should accept a regex as well as a string.
And I've got no problem adding title checks to should_be_restful, but I want to make sure that the macro that implements it is general purpose enough to be useful on its own (and the name "should_set_title_for" is just a bit vague).
Cheers, Tammer
-
Chris O'Sullivan November 18th, 2008 @ 06:06 PM
Heya Tammer,
I've changed the name of the method, and allowed the use of regex.
So now you've got a system like:
should_render_page_with_metadata :description => /Posts/, :title => /index/Whatcha reckon?
Find the branch here: http://github.com/thechrisoshow/...
Please Login or create a free account to add a new comment.
You can update this ticket by sending an email to from your email client. (help)
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
