title: How to test this code with RSpec?
body: <p>I have the following simple class and HTTParty method:</p>
  
  <pre><code>class Token
    require 'httparty'
  
    include HTTParty
    base_uri 'https://&lt;some url&gt;'
    headers 'auth_user' =&gt; 'user'
    headers 'auth_pass' =&gt; 'password'
    headers 'auth_appkey' =&gt; 'app_key'
  
    def self.getToken
      response = get('/auth/token')
      @token = response['auth']['token']
    end
  end
  </code></pre>
  
  <p><em>I know it works</em> because I can call the method in the Rails console and successfully get a token back.</p>
  
  <p><strong>How can I test the above code in RSpec?</strong></p>
  
  <p>My initial stab at it doesn't work:</p>
  
  <pre><code>describe Token do
    before do
      HTTParty.base_uri 'https://&lt;some url&gt;'
      HTTParty.headers 'auth_user' =&gt; 'user'
      HTTParty.headers 'auth_pass' =&gt; 'password'
      HTTParty.headers 'auth_appkey' =&gt; 'app_key'
    end
  
    it "gets a token" do
      HTTParty.get('auth/authenticate')
      response['auth']['token'].should_not be_nil
    end
  end
  </code></pre>
  
  <p>It says: <code>NoMethodError: undefined method 'base_uri' for HTTParty:Module</code>...</p>
  
  <p>Thanks!</p>