On Nov 26, 2011, at 2:38 PM, Cynthia Kiser wrote:
> I am working through the Rails Views chapter in the RSpec Book and
> noticed something odd when I created a spec for the edit view. I am
> getting the wrong value from the messages_path helper. I was kind of
> wondering if it would work or not - but had expected it to fail by not
> giving me an id, not by constructing the url incorrectly. With the
> code below I get the follwing error message. I get the same error
> when using "messages_path(message)" or "messages_path(message.id)".
>
> 1) messages/edit.html.erb renders in update form using the rails way
> of doing RESTFUL urls
> Failure/Error: rendered.should have_selector("form", :method =>
> "post", :action => messages_path(message))
> expected following output to contain a <form method='post'
> action='/messages.1001'/> tag:
>
> I can work around it by constructing the url myself with
> "/messages/#{message.id}" but I am curious where the period is coming
> from in the constructed url.
>
> require 'spec_helper'
>
> describe 'messages/edit.html.erb' do
> let(:message) do
> mock_model("Message", :title => "Existing title", :text => "Existing text")
> end
>
> before(:each) do
> assign(:message, message)
> end
>
> it "renders in update form using the rails way of doing RESTFUL urls" do
> render
> rendered.should have_selector("form", :method => "post",
> :action => messages_path(message))
> rendered.should have_selector("input", :type => "hidden",
> :name => "_method", :value => "put")
> end
> end
What versions of rspec and rails are you using?
_______________________________________________
rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users