hi guys,

 In my index view specs for a given resource, I have successfully
written it for admin users.

For the given resource, when admin users are looking at the index
page, they should see
-a link to add a new resource object
-links to delete/edit/show for each resource object created

My index view specs does this perfectly and it reads:

------- file: begin -----------------------


192-168-1-4:categories anexiole$  cat index.html.erb_spec.rb
require 'spec_helper'

describe "categories/index.html.erb" do
  before(:each) do
        view.stub(:is_admin).and_return(true)

        assign( :categories, [
                        FactoryGirl.create(:category_intakes),
                        FactoryGirl.create(:category_audio),
                ]
        )
  end

  it "renders a list of categories" do
    render
    assert_select 'tr>td', :text => 'intakes and filters'.to_s, :count
=> 1
    assert_select 'tr>td', :text => 'audio'.to_s, :count => 1
  end

        it 'renders an interface with the new link' do
                render
                rendered.should contain ('New Category')
        end

end

------- file: end    -----------------------


Now, I would then like to put more specs in the index view spec.

When a non-admin user (ie someone who has not logged in) looks at the
index page, the user
should NOT see
-a link to add a new resource object
-links to delete/edit/show for each resource object created

1) How can I best write this?
2) Would using ":let" before each different spec (admin and non-admin)
be a good way to do it?

thank you :)
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to