Preamble: I’ve been putting off getting into testing while I got my head
around everything else, because I am a BAD PERSON, and thought they
wouldn’t be fun. After the past couple of hours I know I was wrong to
put it off and right that they wouldn’t be fun (Didn’t help that took me
a while to realise the Agile Book is out of date on unit testing).
Anyway I have a small method in a controller that parses a release date
supplied by Amazon into a date field. Took a bit of thinking about the
best way of doing it but seems to work. however, thought this would be a
good time to start testing so i can throw all sorts of different inputs
at it, but the test is not recognizing the method. In the controller
I’ve got::
class ContributeController < ApplicationController
…
private
def parse_amazon_date(date)
…
end
end
and in my functional test I’ve got:
require File.dirname(FILE) + ‘/…/test_helper’
require ‘contribute_controller’
…
def test_amazon_date_parse
assert_equal Time.gm(2000, “oct”, 25), parse_amazon_date(“25
October, 2000”)
#other tests
end
end
All I keep getting when i try to run the test is:
NoMethodError: undefined method `parse_amazon_date’ for
#ContributeControllerTest:0x4096aea4
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.12.1/lib/action_controller/test_process.rb:432:in
method_missing' test/functional/contribute_controller_test.rb:25:in
test_amazon_date_parse’
Possible I’m being really dense due to a particularly shitty cold, but
if anyone could point me in he right direction, that’d be great.