On Nov 6, 2007 12:56 PM, Chris Olsen <lists at ruby-forum.com>
wrote:> 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)
This error is telling you exactly why it''s failing. The mock name
"Member_1002" that I''m assuming gets created in the spec
(please post
before(:each) in the future for clarity) is being sent :first_name by
the code invoked by t.text_field. Assuming (again) that it is called
@member:
@member.stub!(:first_name).and_return("Chris")
should solve the problem.
Cheers,
David
> 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/.
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>