title: How to reload fixtures in a test
body: <p>I'm trying to test an RSS feed by comparing a dynamically generated feed against a known output. To make this work, I need to load fixtures with the time frozen. The following works, but it seems overkill to reset the database by reloading the schema and the fixtures.</p>
  
  <pre><code># test/integration/feed_test.rb
  require 'test_helper'
  load 'Rakefile'
  
  class FeedTest &lt; ActionDispatch::IntegrationTest
    def setup
      # Normalize time in order to match fixture file
      travel_to Time.zone.parse('2015-03-01T12:00:00') do
        silence_stream(STDOUT) do
          # anything written to STDOUT here will be silenced
          Rake::Task['db:schema:load'].reenable
          Rake::Task['db:schema:load'].invoke
        end
        Rake::Task['db:fixtures:load'].reenable
        Rake::Task['db:fixtures:load'].invoke
      end
    end
  
    test 'feed matches fixture file' do
      get feed_path
      assert_equal contents('feed.atom'), response.body
    end
  end
  
  # test/test_helper.rb
  module ActiveSupport
    class TestCase
      fixtures :all
  
      def contents(file_name)
        IO.read "test/fixtures/files/#{file_name}"
      end
    end
  end
  </code></pre>
  
  <p>I can't figure out how to reload just the projects filter inside a <code>travel_to</code> block. I also can't get <code>travel_to</code> to work in <code>test_helper.rb</code>.</p>
  
  <p>But, the real problem with this approach is that reloading the <code>Rakefile</code> causes the following spurious warnings from the secure_headers gem:</p>
  
  <pre><code>$ rake test
  /Users/dan/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/secure_headers-3.3.1/lib/tasks/tasks.rake:1: warning: already initialized constant INLINE_SCRIPT_REGEX
  /Users/dan/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/secure_headers-3.3.1/lib/tasks/tasks.rake:1: warning: previous definition of INLINE_SCRIPT_REGEX was here
  /Users/dan/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/secure_headers-3.3.1/lib/tasks/tasks.rake:2: warning: already initialized constant INLINE_STYLE_REGEX
  /Users/dan/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/secure_headers-3.3.1/lib/tasks/tasks.rake:2: warning: previous definition of INLINE_STYLE_REGEX was here
  /Users/dan/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/secure_headers-3.3.1/lib/tasks/tasks.rake:3: warning: already initialized constant INLINE_HASH_SCRIPT_HELPER_REGEX
  /Users/dan/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/secure_headers-3.3.1/lib/tasks/tasks.rake:3: warning: previous definition of INLINE_HASH_SCRIPT_HELPER_REGEX was here
  /Users/dan/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/secure_headers-3.3.1/lib/tasks/tasks.rake:4: warning: already initialized constant INLINE_HASH_STYLE_HELPER_REGEX
  /Users/dan/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/secure_headers-3.3.1/lib/tasks/tasks.rake:4: warning: previous definition of INLINE_HASH_STYLE_HELPER_REGEX was here
  Run options: --seed 17868
  
  # Running:
  
  ........................................................................................................
  
  Finished in 17.397614s, 5.9778 runs/s, 191.3481 assertions/s.
  
  104 runs, 3329 assertions, 0 failures, 0 errors, 0 skips
  Coverage report generated for MiniTest to /Users/dan/Dropbox/Documents/dev/cii-best-practices-badge/coverage. 754 / 781 LOC (96.54%) covered.
  </code></pre>
  
  <p>It seems like I should be able to reload some of the fixtures without using rake at all, but I can't figure out how to do so.</p>