Sharing Methods Across Fixtures

I’ve got a fixture where a couple methods are defined in the top of the
fixture that take an argument and return a date. Does anybody have any
idea where can I put these methods (test_helper.rb doesn’t seem to work)
that they will be available to all my fixtures?

Here’s a copy of the fixture file that demonstrates what I’m doing. I
want to move the start_date and end_date methods off to some appropriate
place that will be accessible to ALL of my fixtures

Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html

<%
def start_date(offset = 0)
#September first of this calendar year
sepone = Date.new(Time.now.year,9,1)

#Year of first day of school for ***offset school*** year
start_year = (sepone <= Date.today ? Time.now.year :

Time.now.year-1)+offset

#Start date of school for ***offset school*** year.
Date.new(start_year,9,1)

end

def end_date(offset = 0)
start_date(offset)+1.year-1.day
end
%>
past:
start_dt: <%= start_date(-2) %>
end_dt: <%= end_date(-2) %>
previous:
start_dt: <%= start_date(-1) %>
end_dt: <%= end_date(-1) %>
current:
start_dt: <%= start_date() %>
end_dt: <%= end_date() %>
next:
start_dt: <%= start_date(+1) %>
end_dt: <%= end_date(+1) %>
future:
start_dt: <%= start_date(+2) %>
end_dt: <%= end_date(+2) %>

http://www.5valleys.com/

http://www.workingwithrails.com/person/8078

Uhhh, nevermind. Putting the method in test_helper.rb, but not inside
any other classes, seems to do the trick.

Jon G. wrote:

<%
end
end_dt: <%= end_date(-1) %>

http://www.5valleys.com/

http://www.workingwithrails.com/person/8078