Getting uninitialized constant error when trying to run tests

后端 未结 12 2224
礼貌的吻别
礼貌的吻别 2020-12-10 13:29

I just updated all my gems and I\'m finding that I\'m getting errors when trying to run Test::Unit tests. I\'m getting the error copied below. That comes from creating new,

12条回答
  •  [愿得一人]
    2020-12-10 13:32

    This can happen if modules are declared in a single statement when the parent module they are nested inside has not yet been loaded. I haven't looked at the code in those gems, but my hunch is that's what is happening. Chuck's solution would suggest that. calling gem 'test-unit' first will load the parent module, so the setup of zen test ends up working ok.

    e.g.

    module Foo::Bar
      def do_stuff
        # insert awesomeness here...
      end
    end
    

    Will result in an error if the parent Foo module hasn't already been defined (e.g. by another gem)

    A safer way to declare this is

    module Foo
      module Bar
        def do_stuff
          # insert awesomeness here...
        end
      end
    end
    

    May be a bug in Zentest that needs patching.

提交回复
热议问题