title: How to integrate foreign servers/tables in rspec tests for a Rails application?
body: <p>I'm having trouble trying to test some models for foreign tables in my Rails application. I'm not sure what is the best approach to include this models in my tests.</p>
  
  <p>I created a foreign server and table in a migration like this:</p>
  
  <pre><code>def up
    execute %{
  CREATE SERVER myserver FOREIGN DATA WRAPPER postgres_fdw OPTIONS (host 'foo', dbname 'foodb', port '5432');
  CREATE FOREIGN TABLE users (name character varying(255)) SERVER myserver;
    }%
  end
  </code></pre>
  
  <p>The problem is that my testing environment uses exactly the same table (not a testing table), because the structure file has the development foreign server definition and as rspec loads structure file, it creates a foreign table in my test database that points to the original table in my foreign server. How can I create a foreign server/tables for testing to be loaded when I run my rspec tests?</p>
  
  <p>Thanks in advance!</p>