[rspec-users] Why is this view spec failing?

Chris Olsen lists at ruby-forum.com
Tue Nov 6 13:56:58 EST 2007


I can't figure out why I am getting a failure.  It renders out fine in
the browser.

<h1>New member</h1>

<%= error_messages_for :member %>

<% form_for(:member, :url => members_path) do |f| %>

  <fieldset>
    <legend>Member Info</legend>
    <p><label for="member[first_name]">First Name:</label>  <%=
f.text_field :first_name %></p>
    <p><label for="member[last_name]">Last Name:</label>  <%=
f.text_field :last_name %></p>
  </fieldset>

  <p>
    <%= submit_tag "Create" %>
  </p>
<% end %>
<%= link_to 'Back', members_path %>

*************
ActionView::TemplateError in '/members/new.rhtml should render new form'
Mock 'Member_1002' received unexpected message :first_name with (no
args)
On line #9 of app/views/members/new.rhtml

    6:
    7:   <fieldset>
    8:     <legend>Member Info</legend>
    9:     <p><label for="member[first_name]">First Name:</label>    <%=
f.text_field :first_name %></p>
    10:     <p><label for="member[last_name]">Last Name:</label>  <%=
f.text_field :last_name %></p>
    11:   </fieldset>
    12:

    #{RAILS_ROOT}/vendor/plugins/rspec/lib/spec/mocks/error_generator.rb:52:in
`__raise'
    #{RAILS_ROOT}/vendor/plugins/rspec/lib/spec/mocks/error_generator.rb:16:in
`raise_unexpected_message_error'
    #{RAILS_ROOT}/vendor/plugins/rspec/lib/spec/mocks/proxy.rb:83:in
`raise_unexpected_message_error'
    #{RAILS_ROOT}/vendor/plugins/rspec/lib/spec/mocks/mock.rb:20:in
`method_missing'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_view/helpers/form_helper.rb:356:in
`send'
    /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8/gems/actionpack-1.13.3/lib/action_view/helpers/form_helper.rb:356:in
`value_before_type_cast'

***************
This is using the auto-created test

it "should render new form" do
    render "/members/new.rhtml"

    response.should have_tag("form[action=?][method=post]",
members_path) do
    end
  end

Thanks for the help
-- 
Posted via http://www.ruby-forum.com/.


More information about the rspec-users mailing list