[rspec-users] spec a replace_html with a partial

Matthijs Langenberg mlangenberg at gmail.com
Fri May 11 05:30:52 EDT 2007


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

==== 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
>


More information about the rspec-users mailing list