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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:22:35+00:00 2026-06-08T02:22:35+00:00

Hi i have this problem running the spec file. this is the reparator model:

  • 0

Hi i have this problem running the spec file.
this is the reparator model:

class Reparator < User
  include Mongoid::Document
  include Mongoid::Timestamps
  field :private_reparator, :type => Boolean, :default => true
  field :brand_name, :type => String
  field :year_of_experience, :type => Integer, :default => 1

  has_many :reparations
  has_many :skills

  validates_presence_of :skills, :year_of_experience
  validates :year_of_experience, :numericality => {:greater_than_or_equal_to => 0}
end

This is the skill model:

class Skill
  include Mongoid::Document

  field :name, :type => String

  belongs_to :reparator

  validates_presence_of :name
  validates_uniqueness_of :name

end

This is the controller:

class ReparatorsController < ApplicationController
  respond_to :json

  def index
    @reparators = Reparator.all
    respond_with @reparators
  end

  def show
    @reparator = Reparator.find(params[:id])
    respond_with @reparator
  end

  def create
    @reparator = Reparator.new(params[:reparator])
    @reparator.skills = params[:skills]
    if @reparator.save
      respond_with @reparator
    else
      respond_with @reparator.errors
    end
  end

  def update
    @reparator = Reparator.find(params[:id])

    if @reparator.update_attributes(params[:reparator])
      respond_with @reparator
    else
      respond_with @reparator.errors
    end
  end

  def destroy
    @reparator = Reparator.find(params[:id])
    @reparator.destroy
    respond_with "Correctly destroyed"
  end

end

And this is the spec file for this controller (i’ll just put the test that does’t pass):

it "Should create an reparator" do
      valid_skills = [FactoryGirl.create(:skill).id, FactoryGirl.create(:skill).id]
      valid_attributes = {:name => "Vianello",
                          :email => "maremma@gmail.com",
                          :address => "viale ciccio",
                          :private_reparator => true
                          }
      post :create, :reparator => valid_attributes, :skills => valid_skills
      assigns(:reparator).should be_a Reparator
      assigns(:reparator).should be_persisted
    end

And this is the skill Factory girl:

FactoryGirl.define do
  factory :skill do
    sequence(:name) {|n| "skill#{n}"}
  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-08T02:22:36+00:00Added an answer on June 8, 2026 at 2:22 am

    I think there is a typo in your spec. post :create, :reparator => valid_attributes, :skills => skills_ttributes should be post :create, :reparator => valid_attributes, :skills => skills_attributes instead.

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

Sidebar

Related Questions

I'm a beginner with jdbc ... I have a problem running this code :
I have this problem: I want to generate a new source code file from
I have this problem: $id is id for each user $img = 'http://www.somesite.com/pictures/'; $no_img
I have a problem running RoR project. I am getting this error while running
I have this problem where I have created a User Control which mimics a
I am using Xcode 4.2.1 and I have this problem running an existing application
I am running problems in implementing LIKE in PDO I have this query: $query
I have problems running a dynamic LIKE statement in my project: this query works
I have this problem since I'm beginning in OOP programming I want to close
I have this problem when I run SAS 9.2 on the command line on

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.