```ruby
# This is a global array of route extensions. Alaveteli modules may add to it.
# It is used by our config/routes.rb to decide which route extension files to load.
$alaveteli_route_extensions = []

if ENV["RAILS_ENV"] != "test" # Don't let the themes interfere with Alaveteli specs
    for url in AlaveteliConfiguration::theme_urls.reverse
        theme_name = url.sub(/.*\/(.*).git/, "\\1")
        theme_main_include = File.expand_path "../../../vendor/plugins/#{theme_name}/lib/alavetelitheme.rb", __FILE__
        if File.exists? theme_main_include
            require theme_main_include
        end
    end
end
```

Add a simple hook to allow theme tests to load the theme code in the context of Alaveteli.
user
```ruby
# This is a global array of route extensions. Alaveteli modules may add to it.
# It is used by our config/routes.rb to decide which route extension files to load.
$alaveteli_route_extensions = []

def require_theme(theme_name)
    theme_main_include = File.expand_path "../../../vendor/plugins/#{theme_name}/lib/alavetelitheme.rb", __FILE__
    if File.exists? theme_main_include
        require theme_main_include
    end
end

if Rails.env == "test"
    # By setting this ALAVETELI_TEST_THEME to a theme name, theme tests can run in the Rails
    # context with the theme loaded. Otherwise the themes from the config aren't loaded in testing
    # so they don't interfere with core Alaveteli tests
    if defined? ALAVETELI_TEST_THEME
        require_theme(ALAVETELI_TEST_THEME)
    end
else
    for url in AlaveteliConfiguration::theme_urls.reverse
        theme_name = url.sub(/.*\/(.*).git/, "\\1")
        require_theme(theme_name)
    end
end
```
assistant