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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:00:17+00:00 2026-05-25T10:00:17+00:00

Writing a rspec test to check the association is valid. My code follows Model

  • 0

Writing a rspec test to check the association is valid. My code follows

Model

class Comment < ActiveRecord::Base
  require 'carrierwave/orm/activerecord'
  mount_uploader :file, FileUploader
  belongs_to :contact
  belongs_to :company

end

Comment_spec

require 'spec_helper'

describe Comment do
  pending "add some examples to (or delete) #{__FILE__}"
end

   it "should relate to comapny" do 
     Comment.reflect_on_association(:company).should_not be_nil
   end 

I don’t have any validation, and don’t really need to test anything apart from the association. I get the following error:

 `<top (required)>': undefined method `it' for main:Object (NoMethodError)

I have an undefined method ‘it’ I don’t seem to understand how I can declare this?

  • 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-25T10:00:18+00:00Added an answer on May 25, 2026 at 10:00 am

    Your it block isn’t in a describe block. Try the following:

    require 'spec_helper'
    
    describe Comment do
      pending "add some examples to (or delete) #{__FILE__}"
    
    
       it "should relate to comapny" do 
         Comment.reflect_on_association(:company).should_not be_nil
       end 
    
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing rspec test for my Cars class, and have a question regarding
I'm writing a sinatra app and testing it with rspec and rack/test (as described
I'm writing an integration test for a rails application using Capybara within Rspec. After
I'm new to rspec and fairly new to rails. When writing test cases for
I'm trying to learn RSpec and writing test for CRUD actions. Here is my
I'm new to RSpec and as I was writing a spec test I came
I am writing some tests with RSpec (tests and not specs, the code was
So I'm fairly new to ruby in general, and I'm writing some rspec test
I am having problems with writing a test in rspec for will_paginate. The problem
Writing some test scripts in IronPython, I want to verify whether a window is

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.