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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:19:53+00:00 2026-06-07T12:19:53+00:00

I have an Active Record based model:- House It has various attributes, but no

  • 0

I have an Active Record based model:- House

It has various attributes, but no formal_name attribute.
However it does have a method for formal_name, i.e.

def formal_name
    "Formal #{self.other_model.name}"
end

How can I test that this method exists?

I have:

describe "check the name " do

    @report_set = FactoryGirl.create :report_set
    subject  { @report_set }
    its(:formal_name) { should == "this_should_fail"  }
end

But I get undefined method 'formal_name' for nil:NilClass

  • 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-07T12:19:56+00:00Added an answer on June 7, 2026 at 12:19 pm

    First you probably want to make sure your factory is doing a good job creating report_set — Maybe put factory_girl under both development and test group in your Gemfile, fire up irb to make sure that FactoryGirl.create :report_set does not return nil.

    Then try

    describe "#formal_name" do
      let(:report_set) { FactoryGirl.create :report_set }
    
      it 'responses to formal_name' do
        report_set.should respond_to(:formal_name)
      end
    
      it 'checks the name' do
        report_set.formal_name.should == 'whatever it should be'
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a model class that is not bound to Active record. class ProcessingStatus
I have read a few tutorials and in a book about using Active Record,
I'm using Active Record outside of rails and I have two AR classes similar
Is it possible to have a has and belongs to many relationship in active
I have a project which I have used Active Record and which I'd like
I'm porting our old Active-Record based API over to a new structure to make
I have some issues in Rails Active Record Inheritance, I need to create a
I have a Rails app with a user model that contains an admin attribute.
I have a model, Domain , which has a text field, names . >
I have a model called User with has many association to Address model. When

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.