From: Armin Roehrl Date: 2001-11-04T06:34:58+09:00 Subject: [ruby-talk:24292] Re: Newbie wrong # of arguments(4 for 0) question Hi, what about adding initialize to Revision? -- class Revision attr_reader :revision, :date, :name, :log def initialize(revision,date,name,log) @revision,@date,@name,@log=revision,date,name,log end end --- Bye, Armin On Saturday 03 November 2001 22:17, you wrote: > Well I've finally found an excuse to write some ruby, and I haven't made it > far before > I've gotten myself stuck. I remember a joke about the arguments error from > Ruby Conf, > but can't remember the punch line :( > > I'm sure I am making some simple little mistake, but I have no pair so I am > at a loss. > If anyone can offer assistance I would be most appreciative. > > -- > Erik Meade emeade@objectmentor.com > Senior Consultant Object Mentor, Inc. > http://www.junit.org > > > > > Here is my test: > ========================= > require 'revision' > require 'runit/testcase' > require 'runit/assert' > require 'runit/cui/testrunner' > > class TestRevision < RUNIT::TestCase > > def setup > super > end > > def test_equals > aRevision = Revision.new("1.4", "2001/10/21 02:30:18", "kbeck", > "Enhanced TextRunnerTest to catch missing return values.") > bRevision = Revision.new("1.4", "2001/10/21 02:30:18", "kbeck", > "Enhanced TextRunnerTest to catch missing return values.") > assert_equals(aRevision, bRevision) > end > end > > RUNIT::CUI::TestRunner.run(TestRevision.suite) > ========================== > > And the file I'm testing: > > ========================== > class Revision > attr_reader :revision, :date, :name, :log > end > ========================== > > And of course, the error: > > ========================== > $ ruby test_revision.rb > > TestRevision#test_equals E. > Time: 0.0 > FAILURES!!! > Test Results: > Run: 1/1(0 asserts) Failures: 0 Errors: 1 > Errors: 1 > test_revision.rb:13:in `initialize'(TestRevision): wrong # of arguments(4 > for 0) > (ArgumentError) > from test_revision.rb:13:in `new' > from test_revision.rb:13:in `test_equals' > from test_revision.rb:19 > ========================== -- Armin. ----------------------------------------------- Armin Roehrl, http://www.approximity.com "The best way to predict the future is to invent it." --Alan Kay