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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:06:02+00:00 2026-06-15T13:06:02+00:00

I have a model (event.rb) method, that retrieves a list of all recurrence dates

  • 0

I have a model (event.rb) method, that retrieves a list of all recurrence dates for the named period

  def self.dates_between(start_date, end_date)
     dates = (start_date..end_date).step(7).to_a
  end

than I specify the following in event_spec.rb

  before(:each) do
    @event = FactoryGirl.create(:event)
  end    
  subject { @event }

  ... other working tests ...

  describe '#dates_between' do
    context 'finds recurrences dates of a event' do
      start_date = "2012-12-01 18:25:25"
      end_date = "2012-12-15 18:25:25"
      output_dates = ["2012-12-01 18:25:25", "2012-12-08 18:25:25", "2012-12-15 18:25:25"]

      it 'should call Event with method dates_between' do
        @event.should_receive(:dates_between).with(start_date, end_date)
        @event.dates_between(start_date, end_date)
      end

      it 'should find and return the RIGHT recurrences dates' do
        @event.dates_between(start_date, end_date).should eq(output_dates)
      end
    end
  end

and get this failure:

1) Event#dates_between finds recurrences dates of a event should find and return the RIGHT recurrences dates
 Failure/Error: @event.dates_between(start_date, end_date).should eq(output_dates)
 NoMethodError:
   undefined method `dates_between' for #<Event:0xb99e9f8>
 # ./spec/models/event_spec.rb:52:in `block (4 levels) in <top (required)>'

when I change in the model from a class method to an instance method (removing “self.”) the console just prints out “wild data”:

22:93:55″, “2012-12-01 22:93:62”, “2012-12-01 22:93:69”, “2012-12-01
22:93:76”, “2012-12-01 22:93:83”, “2012-12-01 22:93:90”, “2012-12-01
22:93:97”, “2012-12-01 22:94:04”, “2012-12-01 22:94:11”, “2012-12-01
22:94:18”, “2012-12-01 22:94:25”, “2012-12-01 22:94:32”, …

any ideas?

  • 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-15T13:06:04+00:00Added an answer on June 15, 2026 at 1:06 pm

    So, I got it working, I made two faults:

    • First, I needed to call on a class method (Event.dates_between) and not on an instance method (Event.new.dates_between)

    • Second, I expected

      [“2012-12-01 18:25:25”, “2012-12-08 18:25:25”, “2012-12-15 18:25:25”]

    but should have expexted without time, which screwed up my console by iterating through every second – minute – hour for the three expected days

    ["2012-12-01", "2012-12-08", "2012-12-15"] 
    

    No I do following and the specs are green:

    describe Event do
    
      subject(:event) { FactoryGirl.create(:event) }
    
      describe '#dates_between' do
        context 'finds recurrences dates of a event' do
          start_date = "2012-12-01"
          end_date = "2012-12-15"
          output_dates = ["2012-12-01", "2012-12-08", "2012-12-15"]
    
          it 'should call dates_between with two arguments' do
            event.should_receive(:dates_between).with(start_date, end_date).and_return(output_dates)
            event.dates_between(start_date, end_date).should eq(output_dates)
          end
    
          it 'should find and return the RIGHT recurrences dates' do
            Event.dates_between(start_date, end_date).should eq(output_dates)
          end
        end
      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 called event that has a scope named upcoming wich returns
Does jquery/javascript have any event model that you can attach to your objects? Basically
I have a model that looks like this: Performance - Location - Event -
I have a model that looks like this: class Invite(models.Model): user = models.ForeignKey(User) event
I know that ASP.NET controls such as the button have the postback event model.
I have a Django model called Event that has a date field for the
I have a create method that calls a method in a model that pings
I have a model called Event and another called Product. An event has many
I have model: [XmlRoot(ElementName = event, IsNullable=true)] public class Event { public int id
I have a parent entity in my model Event. And two child entities: Birthday,

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.