So just for posterity, I found that one of the other developers had
included TestUnit in an underlying library. Since my script loaded the
Rails environment to run, it also included TestUnit, which lead to the
behaviour I described.
On Jun 9, 12:07 pm, DZ <goo...-jcml4Hf9Um/1P9xLtpHBDw@public.gmane.org>
wrote:> Greetings,
>
> I have a simple script that I want to run against my database. What is
> happening is that I found that it wanted to run a test suite
> automatically. I''ve tried to run down how that is happening, but I
> don''t follow how it is done. It seems to be set up in the
initializer
> somewhere, but I can''t seem to find it. Since I found that it
wanted
> to run tests, I put a small test class in there, and sure enough it
> runs it.
>
> Can somebody shed some light on how this magic is happening?
>
> Here is an example:
>
> ENV[''RAILS_ENV''] = ARGV.first ||
ENV[''RAILS_ENV''] || ''development''
> puts "Loading #{ENV[''RAILS_ENV'']} environment."
> require File.dirname(__FILE__) + ''/../config/environment''
>
> class MyClass
>
> def run
> puts "Running calculation"
> end
>
> end
>
> class MyClass; def rescue_action(e) raise e end; end
>
> class MyClassTest < Test::Unit::TestCase
> def setup
> puts "running setup"
> end
>
> def test_running_a_test
> puts "running a test "
> assert true
>
> end
> end
>
> if __FILE__ == $0
>
> mc = MyClass.new
> mc.run
> end
>
> and when I run it:
>
> ./myclass.rb
> Loading development environment.
> Running calculation
> Loaded suite ./myclass
> Started
> running setup
> running a test
> .
> Finished in 0.013593 seconds.
>
> 1 tests, 1 assertions, 0 failures, 0 errors
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---