Generated plugin test doesn't work


#1

Hi,

I’m on rails 2.2.2, and generate a new plugin:
./script/generate plugin mytest

and try to run the generated test but get an error:
cd vendor/plugins/mytest/
rake test --trace
(in /tmp/test/vendor/plugins/mytest)
** Invoke test (first_time)
** Execute test
/usr/bin/ruby1.8 -Ilib:lib:test
“/usr/lib/ruby/1.8/rake/rake_test_loader.rb” “test/mytest_test.rb”
./test/mytest_test.rb:5:in test': unknown command ?t (ArgumentError) from ./test/mytest_test.rb:5 from /usr/lib/ruby/1.8/rake/rake_test_loader.rb:5:inload’
from /usr/lib/ruby/1.8/rake/rake_test_loader.rb:5
from /usr/lib/ruby/1.8/rake/rake_test_loader.rb:5:in `each’
from /usr/lib/ruby/1.8/rake/rake_test_loader.rb:5
rake aborted!

The generated test is:
test “the truth” do
assert true
end

and in “unknown command ?t”, the ?t is the first letter of “the truth”
(I mean changing this label changes the error).

Any hint as to how I should correct this and get the test running fine?

Thanks

Raphaël

Here is the rest of the trace when running rake test --trace in the
plugin’s directory

Command failed with status (1): [/usr/bin/ruby1.8 -Ilib:lib:test
"/usr/lib/…]
/usr/lib/ruby/1.8/rake.rb:899:in sh' /usr/lib/ruby/1.8/rake.rb:906:incall’
/usr/lib/ruby/1.8/rake.rb:906:in sh' /usr/lib/ruby/1.8/rake.rb:985:insh’
/usr/lib/ruby/1.8/rake.rb:920:in ruby' /usr/lib/ruby/1.8/rake.rb:985:inruby’
/usr/lib/ruby/1.8/rake/testtask.rb:117:in define' /usr/lib/ruby/1.8/rake.rb:1003:inverbose’
/usr/lib/ruby/1.8/rake/testtask.rb:102:in define' /usr/lib/ruby/1.8/rake.rb:546:incall’
/usr/lib/ruby/1.8/rake.rb:546:in execute' /usr/lib/ruby/1.8/rake.rb:541:ineach’
/usr/lib/ruby/1.8/rake.rb:541:in execute' /usr/lib/ruby/1.8/rake.rb:508:ininvoke_with_call_chain’
/usr/lib/ruby/1.8/rake.rb:501:in synchronize' /usr/lib/ruby/1.8/rake.rb:501:ininvoke_with_call_chain’
/usr/lib/ruby/1.8/rake.rb:494:in invoke' /usr/lib/ruby/1.8/rake.rb:1931:ininvoke_task’
/usr/lib/ruby/1.8/rake.rb:1909:in top_level' /usr/lib/ruby/1.8/rake.rb:1909:ineach’
/usr/lib/ruby/1.8/rake.rb:1909:in top_level' /usr/lib/ruby/1.8/rake.rb:1948:instandard_exception_handling’
/usr/lib/ruby/1.8/rake.rb:1903:in top_level' /usr/lib/ruby/1.8/rake.rb:1881:inrun’
/usr/lib/ruby/1.8/rake.rb:1948:in standard_exception_handling' /usr/lib/ruby/1.8/rake.rb:1878:inrun’
/usr/bin/rake:28


Web database: http://www.myowndb.com
Free Software Developers Meeting: http://www.fosdem.org


#2

I had the same problem and fixed it by changing all tests such that

test “the truth” do
assert true
end

were instead written

def test_the_truth
assert true
end

I had generated the tests with Rails 2.2.x but then had downgraded
(check environment.rb) to 2.1.x which doesn’t use the same format.

Hope that helps you,
Justin