I have been messing with this all night, and can''t figure out
what''s going
wrong here. I have a test that renders the view, and then a shared
behavior checks "response" for the various tags from a rails layout.
The
problem is matching. If I run in the browser the page renders
fine. Is there a way to output what the response contains? Here are my
tests:
describe ''backoffice layout implementor'', :shared => true
do
it ''should render the backoffice stylesheet'' do
response.should have_tag(''link'', :attributes => {:rel
=> ''stylesheet'', :href =>
''/stylesheets/backoffice.css''})
end
it ''should display menu options'' do
response.should have_tag(''a'', :attributes => {:href
=> customers_path, :text => ''Customers''})
response.should have_tag(''a'', :attributes => {:href
=> products_path, :text => ''Products''})
response.should have_tag(''a'', :attributes => {:href
=> reservations_path, :text => ''Reservations''})
response.should have_tag(''a'', :attributes => {:href
=> reports_path, :text => ''Reports''})
response.should have_tag(''a'', :attributes => {:href
=> users_path, :text => ''Users''})
end
it ''should display a logout link'' do
response.should have_tag(''a'', :attributes => {:href
=> session_path, :text => ''Logout''})
end
end
describe ''/main/index GET'' do
before(:each) do
User.current = User.new
render ''main/index.html.haml''
end
it_should_behave_like ''backoffice layout implementor''
end
Here''s the spec:views output:
1)
''/main/index GET should render the backoffice stylesheet''
FAILED
Expected at least 1 element matching "link", found 0.
<false> is not true.
./spec/views/main/../view_common.rb:5:
2)
''/main/index GET should display menu options'' FAILED
Expected at least 1 element matching "a", found 0.
<false> is not true.
./spec/views/main/../view_common.rb:9:
3)
''/main/index GET should display a logout link'' FAILED
Expected at least 1 element matching "a", found 0.
<false> is not true.
./spec/views/main/../view_common.rb:17: