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 7842199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:15:55+00:00 2026-06-02T16:15:55+00:00

I am getting an empty page as response when running the following RSpec test:

  • 0

I am getting an empty page as response when running the following RSpec test:

require 'spec_helper'

describe FriendshipsController do
  include Devise::TestHelpers
  render_views

  before(:each) do
    @user = User.create!(:email => "max@mustermann.com", :password => "mustermann", :password_confirmation => "mustermann")
    @friend = User.create!(:email => "john@doe.com", :password => "password", :password_confirmation => "password")    
    sign_in @user
  end  

  describe "GET 'new'" do

    it "should be successful" do
      get 'new', :user_id => @user.id
      response.should be_success
    end

    it "should show all registered users on Friendslend, except the logged in user" do
      get 'new', :user_id => @user.id

      page.should have_select("Add new friend")
      page.should have_content("div.users")
      page.should have_selector("div.users li", :count => 1)
    end

    it "should not contain the logged in user" do
      get 'new', :user_id => @user.id
      response.should_not have_content(@user.email)
    end
  end
end

I only get a blank page when running the RSpec test.
With blank page I mean there is no other HTML content other than the DOCTYPE declaration.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">

Interestingly, RSpec tests for post ‘create’ work fine. Any hints?

I am using Rails 3.2 with spec-rails, cucumber and capybara (instead of webrat).

  • 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-02T16:15:56+00:00Added an answer on June 2, 2026 at 4:15 pm

    The problem is that you are mixing types of tests. Capybara, which provides the page object is used in request specs by calling visit path.

    In order to fix your problem, you need to be looking at the response object instead of the page object.

    If you want to test content with capybara, the way that you would build that test would look something like this:

    visit new_user_session_path
    fill_in "Email", :with => @user.email
    fill_in "Password", :with => @user.password
    click_button "Sign in"
    visit new_friendships_path(:user_id => @user.id)
    page.should have_content("Add new friend")
    

    That code should be placed in a request spec instead of a controller spec, by convention.

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

Sidebar

Related Questions

Hi I have this Query and I'm getting an empty result, Anyone see anything
I'm having trouble getting my dropdown menu to still work after I empty it's
I'm trying to use empty() in array mapping in php. I'm getting errors that
i keep getting this error, The current value 'String.Empty' type is not compatible with
I'm following this example: http://www.codinghorror.com/blog/2005/12/getting-started-with-indexing-service.html However, the conversion to dataset shows empty columns for
Getting the above error in following code. How to rectify it. Thanks. Please look
I am using the following code to get a page's source which is a
I'm struggling getting the JSON string that was sent from a web page to
I have the following script at the end of my page: <script type=text/javascript> jQuery.noConflict();
Summary: Keep getting null response despite public data and setting callback to enable cross

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.