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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:30:19+00:00 2026-06-17T06:30:19+00:00

I am new to rspec and was wondering how could I write functional test

  • 0

I am new to rspec and was wondering how could I write functional test for following two action of controller

class FeedbackFormsController < ApplicationController

  before_filter :authenticate_user!

 def new
  @feedback_form = FeedbackForm.new
  session[:return_to] = request.referer
 end

 def create
  feedback_form = FeedbackForm.new(params[:feedback_form])
  FeedbackMailer.new(feedback_form).deliver
  flash[:notice] = "Your feedback was submitted successfully."
  redirect_to session[:return_to]
 end

end
  • 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-17T06:30:20+00:00Added an answer on June 17, 2026 at 6:30 am

    I think it’s probably a better learning experience for you to do it yourself, but I’ll get you started with some pseudo-ish code. I will be purposely lax with my syntax.

    require spec-helper
    
    describe FeedbackFormsController
    
      before each 
        controller should receive :authenticate_user! and return true
    
      describe new
        it should assign a new feedback form
          get new
          assigns feedback_form should be a new Feedbackform
    
        it should call for the referer
          request should receive referer
          get new
    
        it should set session value
          request stub referer and return nonsense
          expect
            get new
          to change session return_to to nonsense
    
      describe create
        it should create a new Feebackform
          Feebackform should receive new with nonsense
          post create nonsense
    
        it should create a new Feebackmailer
          mock = mock_model Feedbackform
          Feedbackform stub new and return mock
          Feedbackmailer should receive new with mock
          post create nonsense
    
        it should deliver a message
          mock = mock_model FeedbackMailer
          Feedbackform stub new
          FeedbackMailer stub new and return mock
          mock should receive deliver
          post create nonsense
    
        it should redirect
          Feedbackform stub new
          Feedbackmailer stub new
          post create nonsense
          response should redirect to session[return to]
    

    Hopefully that should get you started.

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

Sidebar

Related Questions

I am pretty new to rspec. How do I write functional test for following
I'm new to rails and I'm trying to test a controller with rspec. My
I'm new in rspec, write rspec-test for View and there's a problem: test fails
I'm new to both ruby and rspec and I'm wondering how to test a
I'm new to RSpec, and trying to write a simple test that shows Devise
I am fairly new to rspec and want to write test in rspec for
Still a bit new to rspec and can't get the following test to pass
I am new to RSpec and I have a test scenario in which I
Hi I and trying to rspec mock the following class: class Person def initialize(personid)
I'm new in cucumber and rspec, and I'm trying to test a button whose

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.