I believe you should be able to test that defining the constant in the test and
in the file (untested):
# c.rb
class C; end
# my_test.rb
class C; end
... store in cache ...
Object.instance_eval { remove_const(:C) }
... load from cache ...
Something like that.
Sent from my iPad
On 12 Nov 2012, at 21:30, Uriel Katz <uriel.katz@gmail.com> wrote:
> Hi,
>
> I am trying to fix #8167 and as part of that fix I need to write tests to
check if my code auto loads classes when reading entries from cache.
> Now I need to write to the cache before I can load so when writing to the
cache I do something like SomeClass.new and that loads SomeClass.
>
> now I want to read from the cache but without having SomeClass loaded
(remember I need to check that when loading from cache SomeClass is loaded).
>
> I already tried the following options:
> 1.Using load/require and removing constant + removing from $LOADED_FEATURES
> 2.Using ActiveSupport::Testing::Isolation.run_in_isolation to (try) running
the dump part in another process (NO_FORK=1 fails and without it
doesn''t do anything)
>
> I tried looking into autoload tests but it didn''t help.
>
> Thanks,
> Uriel
>
>
> $LOADED_FEATURES
> --
> You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Core" group.
> To view this discussion on the web visit
https://groups.google.com/d/msg/rubyonrails-core/-/fcYC_fVCFmUJ.
> To post to this group, send email to rubyonrails-core@googlegroups.com.
> To unsubscribe from this group, send email to
rubyonrails-core+unsubscribe@googlegroups.com.
> For more options, visit this group at
http://groups.google.com/group/rubyonrails-core?hl=en.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Core" group.
To post to this group, send email to rubyonrails-core@googlegroups.com.
To unsubscribe from this group, send email to
rubyonrails-core+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-core?hl=en.