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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:50:40+00:00 2026-05-23T09:50:40+00:00

Completely stumped by this. I swear, this looks like it should work but it

  • 0

Completely stumped by this. I swear, this looks like it should work but it doesnt. The testing database has been updated (rake db:migrate – rake:db:test:clone). I’m hoping I’m doing something silly.

Full disclosure, I’m running the 3.1 RC4.

Model

class ExerciseSet < ActiveRecord::Base

  TYPES = %w[time rep]

  validates :type,
            :presence => true,
            :inclusion => { :in => TYPES }

end

Spec File

require 'spec_helper'

describe ExerciseSet do

  before(:each) do
    @attr = { :value => 12, 
              :value_max => 15,
              :type => "timed",
              :target => "range"
    }            
  end


  describe "type" do
    it "must be either 'time' or 'rep'" do
      values = %w[time rep]
      values.each do |value|
        exercise_instance = ExerciseSet.new(@attr.merge(:type  => value))
        exercise_instance.should be_valid
      end
    end
  end

end

Output

Failures:

  1) ExerciseSet type must be either 'time' or 'rep'
     Failure/Error: exercise_instance.should be_valid
       expected valid? to return true, got false
     # ./spec/models/exercise_set_spec.rb:19:in `block (4 levels) in <top (required)>'
     # ./spec/models/exercise_set_spec.rb:17:in `each'
     # ./spec/models/exercise_set_spec.rb:17:in `block (3 levels) in <top (required)>'
  • 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-23T09:50:40+00:00Added an answer on May 23, 2026 at 9:50 am

    First things first – why isn’t the instance valid? I’d be adding some debugging to the spec:

    describe "type" do
      it "must be either 'time' or 'rep'" do
        values = %w[time rep]
        values.each do |value|
          exercise_instance = ExerciseSet.new(@attr.merge(:type  => value))
          exercise_instance.valid? # force errors
          puts exercise_instance.errors.full_messages.join("\n")
          exercise_instance.should be_valid
        end
      end
    end
    

    Yes, this should probably be a comment, but then I couldn’t offer the spec rewrite so easily.

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

Sidebar

Related Questions

Ok, so this has me completely stumped just like the guy here with the
I'm working on a school assignment and I've been completely stumped with this step.
I've been staring at this one for a while and I'm completely stumped. You'll
I'm sure this is something really simple, like a misplaced quote, but I'm completely
Regex is absolutely my weak point and this one has me completely stumped. I
Okay, so I've been completely stumped by this compiler error for hours, and the
This has got me completely stumped: print_r($json); echo json_encode($json); output: Array ( [query] =>
I have to admit I am COMPLETELY stumped on this one. I've been scouring
I'm completely stumped on this one, being trying for hours but with no success,
This is more then likely a very simple question but I am completely stumped

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.