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

def start_date(offset = 0)
#September first of this calendar year
sepone =,9,1)

#Year of first day of school for ***offset school*** year
start_year = (sepone <= ? :

#Start date of school for ***offset school*** year.,9,1)


def end_date(offset = 0)
start_dt: <%= start_date(-2) %>
end_dt: <%= end_date(-2) %>
start_dt: <%= start_date(-1) %>
end_dt: <%= end_date(-1) %>
start_dt: <%= start_date() %>
end_dt: <%= end_date() %>
start_dt: <%= start_date(+1) %>
end_dt: <%= end_date(+1) %>
start_dt: <%= start_date(+2) %>
end_dt: <%= end_date(+2) %>

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

Jon G. wrote:

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs