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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:48:49+00:00 2026-05-28T05:48:49+00:00

I’m writing an integration test for a rails application using Capybara within Rspec. After

  • 0

I’m writing an integration test for a rails application using Capybara within Rspec. After filling out a form, the user presses submit.

If I run the test I get:

expected there to be content “Welcome to course builder” in “You are
being redirected.”

I am trying to test the resulted page content, here is the test:

describe PagesController do

  describe "Quiz testing in chapter" do

    def page_view
       Capybara::Node::Simple.new(@response.body)
    end

    render_views
    login_student

    it "should fail if user chosen wrong answer" do
      page= create_quiz_page_with_two_choices_first_correct
      post :answer_quiz, :page_id=>page.id, :submitted_single_answer=>'2'
      page_view.should have_content("Welcome to course builder")

    end
  end
end

in the PagesController

def answer_quiz
 ...
 respond_to do |format|
   format.html { redirect_to page }
   format.json { head :ok }
 end
end

I just started using Capybara, so am I missing something obvious here? Why am I stuck with the redirect response?

Thanks!

hopewise

  • 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-05-28T05:48:50+00:00Added an answer on May 28, 2026 at 5:48 am

    login_student needs to go in a before block:

    before(:each) do
      login_student
    end
    

    However even that probably won’t fix the problem. When using Capybara it is recommended to actually login by visiting the login page for each example, so:

    before(:each) do
      visit login_path # log in test user
    end
    
    it "should do something awesome" do
      visit "/awesome"
      page.should have_content("You rock!")
    end
    

    It’s also helpful to write a special case to handle logins in the test environment, so you can avoid having to create a user for test logins.

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

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
We are using XSLT to translate a RIXML file to XML. Our RIXML contains

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.