title: Calling a Sinatra app instance method from TestCase
body: <p>I have an util method into a <em>Sinatra</em> application and I would like to tested from my <code>TestCase</code>.</p>
  
  <p>The problem is that I don't know how to invoke it, if I just use <code>app.util_method</code> I have the error <code>NameError: undefined local variable or method 'util_method' for #&lt;Sinatra::ExtendedRack:0x007fc0c43305b8&gt;</code></p>
  
  <h3>my_app.rb:</h3>
  
  <pre><code>class MyApp &lt; Sinatra::Base
    # [...] routes methods
  
    # utils methods
    def util_method
      return "hi"
    end
  end
  </code></pre>
  
  <h3>my_app_test.rb:</h3>
  
  <pre><code>require "my_app.rb"
  require "test/unit"
  require "rack/test"
  
  class MyAppTest &lt; Test::Unit::TestCase
    include Rack::Test::Methods
  
    def app
      MyApp.new
    end
  
    # [...] routes methods tests
  
    def test_util_method
      assert_equal( "hi", app.util_method )
    end
  end
  </code></pre>