On Thu, Feb 26, 2009 at 10:01 AM, Evgeny Bogdanov
<[email protected]> wrote:
> Could somebody please explain me what I am doing wrong.
> I am trying to spec create.rjs file, that is returned from my
> controller.
>
> render_template("create.rjs") works just fine,
>
> however have_rjs fails with the following error:
> 'CommentsController while posting a comment renders a create.rjs
> template when comment is successfully created in ajax request' FAILED
> No RJS statement that replaces or inserts HTML content.
>
> Thank you!
> Evgeny
>
> =====controller
> def create
> �[email protected]
>
> respond_to do |format|
> format.js
> end
> end
>
> =====create.rjs
> comment_id = "comment_"[email protected]_s
>
> page['add_comment'].hide
> page.insert_html :top, 'comments_list', :partial => "comments/
> comment", :locals => {:comment => @comment, :item => @item}
> page.visual_effect :highlight, comment_id, :duration => 1
>
> =====spec file
> it "renders a create.rjs template when comment is successfully
> created in ajax request" do
> request.env["HTTP_ACCEPT"] = "application/javascript"
> post :create, :item_id => 1, :item_type => "Space", :comment =>
> {:content => "text"}
>
> response.should render_template("create")
> response.should have_rjs
> end
Controller specs, by default, do not render templates. If you want to
specify the contents of a template from your controller spec, tell it
to integrate_views (hmmm - maybe we should change that to
render_views???)
describe MyController do
integrate_views
it "does something" do
...
end
end
HTH,
David
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users