View spec response has no content?

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:

‘/main/index GET should render the backoffice stylesheet’ FAILED
Expected at least 1 element matching “link”, found 0.
is not true.
./spec/views/main/…/view_common.rb:5:

‘/main/index GET should display menu options’ FAILED
Expected at least 1 element matching “a”, found 0.
is not true.
./spec/views/main/…/view_common.rb:9:

‘/main/index GET should display a logout link’ FAILED
Expected at least 1 element matching “a”, found 0.
is not true.
./spec/views/main/…/view_common.rb:17:

On Mon, 22 Oct 2007 02:49:59 +0000, Steve wrote:

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:

Ahem, here’s a big duh for me. Rendering the view itself doesn’t
actually
render the layout since that’s done at the controller level. So many
levels of seperation(which is good). Gets confusing what is where and
called at which times occasionally.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs