Thanks, both answers helped me getting the specs green!
Last questions, 

   - does the first "it-statement" make sense now? 
   - Will the "subject-statement" also executed before(:each) 
   describe-/it-statement?
   
Now I do:

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


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

-- 
You received this message because you are subscribed to the Google Groups 
"rspec" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msg/rspec/-/8Dqw17To1SQJ.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to