I have a bunch of unit test files in a Rails project. One of them has
stopped using the setup method before each test, or even if I invoke it
in the test itself.
After commenting out most of it, here is what is left:
require ‘test/test_helper’
class GlcTest < ActiveSupport::TestCase
def setup
p ‘###########################’
end
def test_setup
p ‘[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[’
setup
end
end
The file I am testing is glc.rb, and that does get loaded. If I run the
test file, it does work normally; this is a problem when running the
test through rake (either via my IDE or at the command line).
test_setup does get invoked, so the file is being processed. I am
guessing that somewhere there is another setup method that takes
priority, but where would it be, and why does it take priority over this
one? My IDE recognises that this setup overrides the one in
ActiveSupport::TestCase.
There is no setup method defined in glc.rb, and as the problem is
isolated to this one class, I am mystified as to where this other setup
might be.
test_setup does get invoked, so the file is being processed. I am
guessing that somewhere there is another setup method that takes
priority, but where would it be, and why does it take priority over this
one? My IDE recognises that this setup overrides the one in
ActiveSupport::TestCase.
is it possible that another of your test cases is also called
GlcTest ?
test_setup does get invoked, so the file is being processed. I am
guessing that somewhere there is another setup method that takes
priority, but where would it be, and why does it take priority over this
one? My IDE recognises that this setup overrides the one in
ActiveSupport::TestCase.
is it possible that another of your test cases is also called
GlcTest ?
Fred
That was it. I had copy-and-pasted from GlcTest to create a new test
class, and had forgotten to change the class name. Thanks for the help.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.