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

  • Home
  • SEARCH
  • 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 5952571
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:42:02+00:00 2026-05-22T17:42:02+00:00

How do you call a before_filter directly to test it’s implementation? Let’s say I

  • 0
  1. How do you call a before_filter directly to test it’s implementation? Let’s say I want to write a spec for ApplicationController that contains a few before filters. What is the standard way to test them? Note, I don’t want to test that they’ve been called – I actually just want to test their implementation once in a single spec.

  2. I like having “render_views” at the top of my controller specs, but when I use stubs, I get all sorts of strange errors as it tries to get the id or other attributes on the stub object. How do you deal with this so that you can make sure your views are correct while using stubs?

I use RSpec.

  • 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-22T17:42:03+00:00Added an answer on May 22, 2026 at 5:42 pm

    Ad 1) Are the proper helpers? Then test them as helpers. If the are methods in you controller then they are private you can test them with the help of send.

    require 'spec_helper' 
    describe PostsController do
      it "private #scope should be Post.all" do
        @controller.send(:scope).should == Post.all
      end
    end
    

    Ad 2)
    I have render_views as well, saves me some time on testing the views. I don’t use stubs but real objects from FactoryGirl or the like. The whole mocking of objects sucks when your objects change and it’s a lot of extra work. Factories aren’t. Of course, your tests will get slower, but you’ll be testing deeper and wider.

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

Sidebar

Related Questions

I have a method in my ApplicationController that is part of a before_filter. How
I'm using Devise's built in before_filter :authenticate_user! . I want to call my own
Call me a 'n00b', but I am new to creating Script Controls. I want
I am trying to create a bad word filter method that I can call
After customizing the devise redirects to call and i want to perform an action
What is the best way of handling redirects in an AJAX call that require
Is it required to call TemplateControl.ResolveUrl() before passing it to TemplateControl.LoadControl() ? Which way
When I attach functionality to an element do I need to call .widgetName('destroy') before
i'am working on an autogrowing listview. Everytime before i call mAdapter.notifyDataSetChanged(); i toggle the
Before calling AddDocument() on IndexWriter , is it okay if I call IndexReader.IsLocked(myDirectory) and

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.