Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Loading/unloading classes/files in tests
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Xavier Noria  
View profile  
 More options Nov 13 2012, 3:01 am
From: Xavier Noria <f...@hashref.com>
Date: Tue, 13 Nov 2012 09:00:33 +0100
Local: Tues, Nov 13 2012 3:00 am
Subject: Re: [Rails-core] Loading/unloading classes/files in tests

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.k...@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 must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.