[rspec-users] spec a replace_html with a partial

David Chelimsky dchelimsky at gmail.com
Fri May 11 07:35:30 EDT 2007


On 5/11/07, Matthijs Langenberg <mlangenberg at gmail.com> wrote:
> I've replaced the mock model with a real AR object, but the spec is
> still failing:
> ==== Changed spec:
> require File.dirname(__FILE__) + '/../../spec_helper'
>
> describe "/pos_orderlines/create.rjs" do
>
>   before(:each) do
>     @orderlines = [stub('orderlines', :to_param => "2", :item =>
> stub('item', :description => 'an item', :price => 10))]
>     @order = stub('order', :id => 1, :pos_orderlines => @orderlines,
> :total_price => 10, :payments => stub('payments', :empty? => true))
>
>     @the_order = PosOrder.create!
>     assigns[:order] = @the_order
>   end
>
>   it "should replace orderlines div" do
>     render "/pos_orderlines/create.rjs"
>     assert_rjs :replace_html, :orderlines, :partial =>
> 'pos_orders/orderlines', :locals => { :order => @the_order }
>   end
>
> end

Looking at http://glu.ttono.us/articles/2006/05/29/guide-test-driven-rjs-with-arts,
you need to do an xhr request, which isn't supported yet in view
specs.

Please try doing the same thing in a controller spec using
integrate_views and do the request using xhr and see if that works.

In the mean time I'll submit an RFE to support this directly in view specs.

>
> ==== failes with:
> Test::Unit::AssertionFailedError in '/pos_orderlines/create.rjs should
> replace orderlines div'
> No replace_html call found on div: 'orderlines' and content:
> {partial: "pos_orders/orderlines", locals: {order: {items: [],
> payments: [], errors: [], attributes: {id: 65, state: "open",
> created_at: {}}, new_record_before_save: true, new_record: false,
> pos_orderlines: []}}}
> in response:
> Element.update("orderlines", "<table
> id=\"orderlines\">\n\t<tr>\n\t\t<th>description</th>\n\t\t<th
> class=\"price\">price</th>\n\t\t<th></th>\n\t</tr>\n\t\n\t<tr>\n\t\t<td
> class=\"total\">Total</td>\n\t\t<td id=\"total-price\"
> class=\"price\">$0.00</td>\n\t\t<td></td>\n\t</tr>\n\n</table>");.
> <nil> is not true.
> ====
>
> Any ideas?
>
>
> On 5/11/07, Matthijs Langenberg <mlangenberg at gmail.com> wrote:
> > I wanted to use ARTS to add RJS in a behaviour driven way to my
> > application, but I'm having some trouble asserting a replace_html with
> > a partial.
> > I've created a pastie (http://pastie.caboo.se/60694) which contains
> > the RJS I want to spec, the spec which I already wrote and its failure
> > message.
> >
> > I'm currently using RSpec-0.9.2
> >
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list