From 94060c3142ef3f77e20dbfb5b4dcda7b23c6db54 Mon Sep 17 00:00:00 2001 From: Blake Mizerany Date: Fri, 26 Oct 2007 19:03:22 -0700 Subject: [PATCH] Updating rdoc --- README | 21 ++++++++++++++++++++- RakeFile | 2 +- lib/sinatra/test/methods.rb | 5 ++++- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/README b/README index 76a3846..50be282 100644 --- a/README +++ b/README @@ -35,7 +35,7 @@ I'm going to move quick. I'll let you drool at your own pace. * Refresh (no need to restart Sinatra): http://localhost:4567 -* Modify again (then refresh): +* Modify again (then refresh) -- And yes, this presentation logic can be quickly extracted to a template.. see below. get '/' do <<-HTML
@@ -49,6 +49,25 @@ I'm going to move quick. I'll let you drool at your own pace. "Hello #{params[:name] || 'World'}!" end +* Test (lyrics_test.rb) -- We should be doing this first... for the purposes of this tutorial, we're doing it here + + require 'sinatra/test/spec' + require 'lyrics' + + context "My app" do + specify "should have a form" do + get_it '/' + response.should.be.ok + body.scan('form').size.should.equal 1 + + post_it '/', :name => 'Sinatra' + response.should.be.ok + body.should.equal 'Hello Sinatra!' + end + end + +For more test helpers see: Sinatra::Test::Methods and http://rack.rubyforge.org/doc/classes/Rack/Response/Helpers.html + * Now you try: Use the Sinatra::Erb::EventContext or Sinatra::Haml::EventContext to do the same. Do them inline and as template files. diff --git a/RakeFile b/RakeFile index 0d9030e..a6fd419 100644 --- a/RakeFile +++ b/RakeFile @@ -19,7 +19,7 @@ begin p.email = "blake.mizerany@gmail.com" p.test_pattern = 'test/**/*_test.rb' p.include_rakefile = true - p.rdoc_pattern = ['README', 'LICENSE'] + Dir.glob('lib/**/*.rb') + Dir.glob('vendor/**/*.rb') + p.rdoc_pattern = ['README', 'LICENSE'] + Dir.glob('lib/**/*.rb') + Dir.glob('vendor/**/*.rb') + Dir.glob('lib/sinatra/test/*.rb') p.docs_host = "bmizerany@rubyforge.org:/var/www/gforge-projects/" end diff --git a/lib/sinatra/test/methods.rb b/lib/sinatra/test/methods.rb index 9050282..eb1cce9 100644 --- a/lib/sinatra/test/methods.rb +++ b/lib/sinatra/test/methods.rb @@ -3,7 +3,6 @@ require 'uri' module Sinatra # These methods are for integration testing without an internet connection. They are available in Test::Unit::TestCase and when in Irb. - module Test module Methods @@ -27,14 +26,17 @@ module Sinatra end_eval end + # The response returned by the Event def response @response || Rack::MockResponse.new(404, {}, '') end + # The status returned by the event def status response.status end + # The text returned by the event def text response.body end @@ -42,6 +44,7 @@ module Sinatra alias :html :text alias :body :text + # The headers returned by the event def headers response.headers end -- 2.11.4.GIT