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

Sid W. lists at ruby-forum.com
Thu Dec 9 10:08:42 EST 2010


Sid W. wrote in post #967432:
> gem 'rspec-rails', :git => 'git://github.com/rspec/rspec-rails'

Missing .git corrected but still no joy.

Sid W. wrote in post #967432:
> It appears that the fix you mention is in master not 2-2-maintenance.
> Due to RSpec 2.3 dependancies I've added the following to my Gemfile
>
> gem 'rspec', :git => 'git://github.com/rspec/rspec.git'
> gem 'rspec-expectations', :git =>
> 'git://github.com/rspec/rspec-expectations.git'
> gem 'rspec-core', :git => 'git://github.com/rspec/rspec-core.git'
> gem 'rspec-mocks', :git => 'git://github.com/rspec/rspec-mocks.git'
> gem 'rspec-rails', :git => 'git://github.com/rspec/rspec-rails'
>
> Unfortunately, the same error persists. :(

So my previous code example works with the master branch gems except it
breaks with the addition of another test block. The following code
breaks with a similar error.

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

  it "renders a text field for the first billing street address line" do
    payment.stub(:billing_street1 => "Flat 123")
    render
    rendered.should have_selector("form") do |form|
      form.should have_selector("input",
        :type => 'text',
        :name => 'payment[billing_address1]',
        :value => 'Flat 123'
      )
    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='Flat 123' name='payment[billing_address1]'/> 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:0x103035800&gt;"><input
id="payment_submit" name="commit" type="submit" value="Save">
     </form>
======================

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


More information about the rspec-users mailing list