Created
January 28, 2009 17:17
-
-
Save jmgarnier/54070 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Monday is 26/01/2009, Sunday is 01/02/2009 | |
# I have to use a constand because RSpec can not access variables outside of "it" blocks ... | |
TWENTY_SIX_OF_JANUARY_20009 = "26/01/2009".to_date_with_european_date_format | |
describe "On going events" do | |
before :each do | |
@event = create_ongoing_event_for_barcelona( | |
:starts_at => TWENTY_SIX_OF_JANUARY_20009, | |
:ends_at => "01/02/2009".to_date_with_european_date_format) | |
@event.schedule_details.create(:monday => true, | |
:friday => true, :saturday => true, :sunday => true, | |
:starts_at => 5.pm, :ends_at => 9.pm, | |
:event => @event) | |
end | |
it "should have a start date" do | |
@event.starts_at.should_not be_nil | |
end | |
it "should not have a start time" do | |
@event.starts_time.should be_nil | |
end | |
it "should have an end date post to start date" do | |
@event.ends_at.should_not be_nil | |
end | |
it { @event.should be_ongoing } | |
it "should have 1 or more scheduling details" do | |
@event.should have(1).schedule_details | |
@event.schedule_details.first.should be_monday | |
@event.schedule_details.first.should_not be_programmed_on_tuesday # nicer ;-) | |
end | |
it "should display a pretty 'When' information" do | |
# @event.pretty_print_when_dates.should == "26/01/2009 - 01/02/2009" | |
@event.pretty_print_when_schedule_details.first.should == "Monday and Friday-Sunday (5pm-9pm)" | |
end | |
it "should not relate to a weekday used in another event schedule detail. Example: Wednesday (11am-4pm) is invalid if Tuesdays–Sundays (10am–5pm)) specified" do | |
pending("Validation rule that should be prevented by the GUI") | |
end | |
describe "finders. Given an event starting Mon 26/01/2009 and programmed on Monday and Friday-Sunday (5pm-9pm)" do | |
it "should find this event searching for ongoing events for Mon 26/02/2009" do | |
Event.find_ongoing_events(TWENTY_SIX_OF_JANUARY_20009).should == [@event] | |
end | |
# Tuesday -> Thursday | |
[(TWENTY_SIX_OF_JANUARY_20009 + 1.day), (TWENTY_SIX_OF_JANUARY_20009 + 3.day)].each { |this_date| | |
it "should NOT find this event searching for ongoing events for #{this_date}" do | |
Event.find_ongoing_events(this_date).should == [] | |
end | |
} | |
# Friday -> Sunday | |
[(TWENTY_SIX_OF_JANUARY_20009 + 4.day), (TWENTY_SIX_OF_JANUARY_20009 + 6.day)].each { |this_date| | |
it "should find this event searching for ongoing events for #{this_date}" do | |
Event.find_ongoing_events(this_date).should == [@event] | |
end | |
} | |
end | |
end # On going events |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment