Hi All,
I got a set of tests for a Ruby app. The first fails unexpectedly
(“wrong number of args”). I added code to show that the app works as
I think it should. Any ideas?
The code is below:
I’m running:
Rails 2.3.5, Ruby 1.8.6, WinXP-Pro/SP3, Firefox 3.6.2, Firebug 1.5.3,
MySQL 5.0.37-community-nt, Mongrel, Apache HTTP Server 2.2.15
Thanks in advance,
Richard
GenModCRUD.rb <<<<<<<<<<<<< The Program >>>>>>>>>>>>>>>
module GMC_mod
The standard views (in app.views) in alphabetical order
for any DB table
:private
def crud_views(type)
case type
when :string
s = %w[edit index new show].join(", ")
when :symbols
s = [:editm, :index, :new ,:show]
puts s
else
raise ‘Invalid arg for crud_views: “%s”’ % type
end
s
end
:public
def crud_views_as_a_string
crud_views(:string)
end
def crud_views_as_a_symbols_array
crud_views(:symbols)
end
end
class InlineTest
include GMC_mod
end
t = InlineTest.new
puts t.crud_views_as_a_string.inspect # => “edit, index, new, show”
GenModCRUD.rb <<<<<<<<<<<<< The Test >>>>>>>>>>>>>>>
require ‘test/unit’
require ‘GenModCRUD’
class MyTests < Test::Unit::TestCase
include GMC_mod
def test_001_crud_views_as_a_string
assert_equal( “edit, index, new, show”,
crud_views_as_a_string(:string), “Surprise”)
end
end
<<<<<<<<<<<<< The Results >>>>>>>>>>>>>>>
edit, index, new, show"
Loaded suite TestGMC
Started
E
Finished in 0.0 seconds.
- Error:
test_001_crud_views_as_a_string(MyTests):
ArgumentError: wrong number of arguments (1 for 0)
TestGMC.rb:12:incrud_views_as_a_string' TestGMC.rb:12:in
test_001_crud_views_as_a_string’
1 tests, 0 assertions, 0 failures, 1 errors