Here is a simple 5 line test helper you can use to spec partials.
http://gist.github.com/51568
After adding it to your spec_helpers.rb, you should be able to do
something like this
@partial_result = request_partial("articles/my_partial")
Then @partial_result will be the html of that partial. It might be
worth wrapping it in a fake @response as well so you can use
have_selector & stuff on it. It just proxies the method call directly
to the partial() call on the controller so all the normal proxy calls
apply.
Helper could use a bit of improvement as well. If anyone wants to fork
the gist and add some improvements to the api (maybe a name change),
I'll collect it all and release it as merb_spec_partial plugin.
I'll try to figure out some way to move all the instance variables
defined in your spec to the fake controller so that your partial will
have access to those variables. Also need to figure out how to allow
setting all the other stuff like params, cookies, sessions, etc. But
it should be pretty easy.
On Jan 24, 1:11 pm, Phlip <[email protected]> wrote:
> > assert_js_replace_html() works a lot like the ARTS assert_rjs() call, but
> > that
> > only uses JavaScript.
>
> ^W regular expressions.
>
> > I told my colleague to use the latter this week, and he
>
> > immediately discovered that a call like assert_rjs :replace_html,
> > 'skim_panel_cc', /\<select id=.ach_skim_selection/ could get fooled by an
> > 'ach_skim_selection' from the next Replace.element() call! Our Ajax is
> > delightfully complex, so we don't need this kind of noise at test time.
>
> Damaging typo!
>
> The point was assert_rjs() just builds a sloppy regexp out of its arguments
> and
> rips this, generally unaware of the JavaScript parsing rules. Unit tests can
> do
> better, _before_ the overhead of in-browser tests!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"merb" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/merb?hl=en
-~----------~----~----~----~------~----~------~--~---