I really hope you could help me refactor this:
context "a deactivated resource" do
before(:each)
@resource = FactoryGirl.create(:deactivatedresource)
end
it "does not show in the search (as registred User)" do
as_user # does the log in
visit path_to_search_page
page.should_not have_content @resource.name
end
it "is visible to the resource owner" do
as_resource_owner(@resource)
visit path_to_search_page
page.should_have content @resource.name
end
it "as unregistred user" do
as_unregistred_user # checks for log out and logs out if necessary
visit path_to_search_page
page.should_not have_content @resource.name
end
I would really like to put the visitand should(not) have part in en extra after(:each) block, but this makes a nasty output.
How would you do this?
I do not see much point to refactoring. Nevertheless you can extract your path and content to instance variables in before filter (or let) to have control from one place. Also, i don`t like your descriptions of specs – make it more readable and write them in one style.