Sinatra: Rack Reloaded
Sinatra is light-weight web framework on top of Rack. It is easy to configure and supports a wide array of template languages. It also literally speaks to the developer - request handlers are defined in a very natural reading domain-specific language.
Suppose we want to design the 'Hello World!' application again, using Sinatra this time. The code is this:
[cc lang="ruby"] require 'sinatra' class HelloWorld < Sinatra::Base get '/' do content_type "text/plain" 'Hello World!' end end [/cc]Line 4 shows how different URLs inside the application are declared. The [cci lang="ruby"]get[/cci] defines a HTTP get method handler which returns the result of the supplied block. Line 5 sets the content type for this request, and Line 6 returns the String 'Hello World!'
Now we want to use this application with the known [cci lang="ruby"]Rack::Builder[/cci]. We don’t want to use a browser manually, but automate the test. So let’s introduce Ruby web application testing
Read more at http://blog.sebastianguenther.org/2010/03/28/combining-and-testing-a-joint-ruby-rack-and-sintra-application/