Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9047373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T11:53:39+00:00 2026-06-16T11:53:39+00:00

I really hope you could help me refactor this: context a deactivated resource do

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T11:53:40+00:00Added an answer on June 16, 2026 at 11:53 am

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am really new to this website. I hope someone could help me out
This is my first post here and I really hope, that someone could help
hope to get some help here because this is something that really makes me
I really REALLY hope that someone could help me. I have to pass almost
I really hope someone can help on this because I'm learning cocoa and have
I would be really grateful if somebody could help me out with this.. I
I am lost and really hope someone could help me out here, I am
I hope that someone could help me with the following problem because I'm really
I really hope someone will be able to help me out with this. I
Guys, I opened this question (I hope could help some others) but reading stackoverflow

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.