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.
1) Error:
test_001_crud_views_as_a_string(MyTests):
ArgumentError: wrong number of arguments (1 for 0)
TestGMC.rb:12:in `crud_views_as_a_string'
TestGMC.rb:12:in `test_001_crud_views_as_a_string'
1 tests, 0 assertions, 0 failures, 1 errors
>Exit code: 1
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.