avdi (owner)

Forks

Revisions

  • 3ea692 avdi Tue May 12 21:49:48 -0700 2009
gist: 110881 Download_button fork
public
Public Clone URL: git://gist.github.com/110881.git
sinatra-tests-baked-in.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env ruby
require 'rubygems'
gem 'rack', '=0.9.1'
gem 'thin', '=1.0.0'
require 'sinatra'
 
get '/' do
  content_type 'text/plain'
  "Hello, world"
end
 
# Run me with 'spec' executable to run my specs!
if $0 =~ /spec$/
  set :environment, :test
  set :run, false # Don't autostart server
 
  require 'spec/interop/test'
  require 'sinatra/test'
 
  describe "Example App" do
    include Sinatra::Test
 
    it "should serve a greeting" do
      get '/'
      response.should be_ok
      response.body.should == "Hello, world"
    end
 
    it "should serve content as text/plain" do
      get '/'
      response.headers['Content-Type'].should == 'text/plain'
    end
 
  end
end