[rspec-users] Failing View Spec, rspec-rails 2.2.1

Sid W. lists at ruby-forum.com
Thu Dec 9 07:55:45 EST 2010


Here is a simple example of the breaking code;

====== CODE ========
describe "payments/new.html.haml" do
  let(:payment) do
    mock_model("Payment").as_new_record.as_null_object
  end

  before do
    assign(:payment, payment)
  end

  it "renders a form to take payment details" do
    render
    rendered.should have_selector("form",
      :method => "post",
      :action => payments_path
    ) do |form|
      form.should have_selector("input", :type => "submit")
    end
  end

  it "renders a text field for the billing name" do
    payment.stub(:billing_name => "Mr. Test Pants")
    render
    rendered.should have_selector("form") do |form|
      form.should have_selector("input",
        :type => "text",
        :name => "payment[billing_name]",
        :value => "Mr. Test Pants"
      )
    end
  end

end
===================

Here is the error;

====== ERROR ========
Failure/Error: form.should have_selector("input",
     expected following output to contain a <input type='text'
value='Mr. Test Pants' name='payment[billing_name]'/> tag:
     <form accept-charset="UTF-8" action="/payments" class="new_payment"
id="new_payment" method="post">
     <div style="margin:0;padding:0;display:inline"><input name="utf8"
type="hidden" value="&#10003;"></div>
     <input id="payment_billing_name" name="payment[billing_name]"
size="30" type="text"
value="Payment_#&lt;RSpec::Core::ExampleGroup::Nested_1:0x1031c4220&gt;"><input
id="payment_submit" name="commit" type="submit" value="Save">
     </form>
===================

Attachments:
http://www.ruby-forum.com/attachment/5528/example_spec.rb


-- 
Posted via http://www.ruby-forum.com/.


More information about the rspec-users mailing list