Hi guys,
I have created a new resource, brands and here’s the spec for ‘new’
which is failing.
I do not know what’s going on despite checking it out for a few times
already
------ app/views/brands/new.html.erb - start -------------
New brand
<%= render ‘form’ %>
<%= link_to ‘Back’, brands_path %>
------ app/views/brands/new.html.erb - start -------------
New brand
<%= render ‘form’ %>
<%= link_to ‘Back’, brands_path %>
------ app/views/brands/new.html.erb - end -------------
------ app/views/brands/_form.html.erb - start -------------
<%= form_for(@brand) do |f| %>
<% if @brand.errors.any? %>
<%= pluralize(@brand.errors.count, “error”) %> prohibited
this brand from being saved:
<ul>
<% @brand.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<%= f.text_field :name %>
<%= f.text_field :description %>
------ app/views/brands/_form.html.erb - end -------------
--------spec/views/parts/new.html.erb_spec.rb - start --------
require ‘spec_helper’
describe “brands/new.html.erb” do
include Devise::TestHelpers
before(:each) do
@brand = assign( :brand,
stub_model( Brand,
:name => ‘Apple’,
:description => ‘OS X and Ipods’
)
)
end
it “renders new brand form” do
render
rendered.should have_selector( ‘form’,
:method => ‘post’,
:action => brands_path
) do |form|
form.should have_selector(“input”, :type => “submit”)
end
end
end
--------spec/views/parts/new.html.erb_spec.rb - end --------
My spec, spec/views/brands/new.html.erb_spec.rb fails with the
following error:
-------- Error message - start ------------------------
- brands/new.html.erb renders new brand form
Failure/Error: form.should have_selector(“input”, :type =>
“submit”)
expected following output to contain a
tag:./spec/views/brands/new.html.erb_spec.rb:21
./spec/views/brands/new.html.erb_spec.rb:17
-------- Error message - end ------------------------
When I do a view source on the page, I could very well see the submit
button in the form.
----------- html form extract - start ---------------------
----------- html form extract - end ---------------------
What am I missing?
thanks