Anthony Burns
2009-Jun-22 21:36 UTC
[rspec-users] Expected output matches rendered output but still getting error in view spec
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hello all,
I''ve just gotten started using BDD with RSpec/Cucumber/Webrat and
Rails and I''ve run into some frustration trying to get my view spec to
pass.
First of all, I am running Ruby 1.9.1p129 with Rails 2.3.2, RSpec and
RSpec-Rails 1.2.6, Cucumber 0.3.11, and Webrat 0.4.4.
Here is the code relevant to my question
config/routes.rb:
map.b_posts ''backend/posts'',
:controller => ''backend/
posts'',
:action =>
''backend_index'',
:conditions => { :method
=> :get }
map.connect ''backend/posts'',
:controller => ''backend/
posts'',
:action =>
''create'',
:conditions => { :method
=> :post }
views/backend/posts/create.html.erb:
<% form_tag do %>
<% end %>
*spec/views/backend/posts/create.html.erb_spec.rb:*
describe "backend/posts/create.html.erb" do
it "should render a form to create a post" do
render "backend/posts/create.html.erb"
response.should have_selector("form", :method =>
''post'', :action => b_posts_path) do |form|
# Nothing here yet.
end
end
end
Here is the relevant part of the output when I run script/spec:
''backend/posts/create.html.erb should render a form to create a
post''
FAILED
expected following output to contain a <form method=''post''
action=''/
backend/posts''/> tag:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://
www.w3.org/TR/REC-html40/loose.dtd">
<html><body><form action="/backend/posts"
method="post">
</form></body></html>
It would appear to me that what have_selector is looking for is
exactly what the template generates, yet the example still fails. I am
very much looking forward to seeing my error (because I have a feeling
it is my error). Any help is much appreciated!
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAko/+XMACgkQaSfff6Oi7PgTrACfdLx7gDTgYZUT8vc+CVuzuSVg
JoUAnRuSVqaM2Ag4orIQAv3gAZpqrDB7
=G8v7
-----END PGP SIGNATURE-----
David Chelimsky
2009-Jun-26 14:08 UTC
[rspec-users] Expected output matches rendered output but still getting error in view spec
On Mon, Jun 22, 2009 at 4:36 PM, Anthony Burns<anthony.h.burns at gmail.com> wrote:> -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Hello all, > > I''ve just gotten started using BDD with RSpec/Cucumber/Webrat and > Rails and I''ve run into some frustration trying to get my view spec to > pass. > > First of all, I am running Ruby 1.9.1p129 with Rails 2.3.2, RSpec and > RSpec-Rails 1.2.6, Cucumber 0.3.11, and Webrat 0.4.4. > > Here is the code relevant to my question > > config/routes.rb: > > ? ?map.b_posts ? ? ? ? ? ? ? ? ?''backend/posts'', > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?:controller => ''backend/ > posts'', > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?:action => ''backend_index'', > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? :conditions => { :method > => :get } > > ? ?map.connect ? ? ? ? ? ? ? ? ?''backend/posts'', > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?:controller => ''backend/ > posts'', > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? :action => ''create'', > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? :conditions => { :method > => :post } > > views/backend/posts/create.html.erb: > > ? ?<% form_tag do %> > ? ?<% end %> > > *spec/views/backend/posts/create.html.erb_spec.rb:* > > ? ?describe "backend/posts/create.html.erb" do > ? ? ?it "should render a form to create a post" do > ? ? ? ?render "backend/posts/create.html.erb" > ? ? ? ?response.should have_selector("form", :method => > ''post'', :action => b_posts_path) do |form| > ? ? ? ? ?# Nothing here yet. > ? ? ? ?end > ? ? ?end > ? ?end > > Here is the relevant part of the output when I run script/spec: > > ''backend/posts/create.html.erb should render a form to create a post'' > FAILED > expected following output to contain a <form method=''post'' action=''/ > backend/posts''/> tag: > <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http:// > www.w3.org/TR/REC-html40/loose.dtd"> > <html><body><form action="/backend/posts" method="post"> > </form></body></html> > > It would appear to me that what have_selector is looking for is > exactly what the template generates, yet the example still fails. I am > very much looking forward to seeing my error (because I have a feeling > it is my error). Any help is much appreciated!That failure message is coming from webrat, and I''m not sure what''s really going wrong there. I''d recommend posting to the webrat group: http://groups.google.com/group/webrat/ Cheers, David