Skip to content
sr edited this page Sep 12, 2010 · 8 revisions

Classic style

App

require "sinatra"

get “/” do
“Hello World”
end

Test

require "webrat/sinatra" require "app"

class AppTest < Test::Unit::TestCase
include Webrat::Methods
include Webrat::Matchers

def test_it_works visit “/” assert_contain(“Hello World”) end

end

Modular style

App


class App < Sinatra::Default
  get "/" do
    "Hello World"
  end
end

Test


require "webrat/sinatra"
require "app"

class AppTest < Test::Unit::TestCase
  include Webrat::Methods
  include Webrat::Matchers

  def app
    App.tap { |app| app.set :environment, :test }
  end

  def test_it_works
     visit "/"
      assert_contain("Hello World")
   end
end

Clone this wiki locally