README.rdoc in rtomayko-sinatra-0.8.9 vs README.rdoc in rtomayko-sinatra-0.8.10
- old
+ new
@@ -163,25 +163,31 @@
=== In-file Templates
Templates may be defined at the end of the source file:
+ require 'rubygems'
+ require 'sinatra'
+
get '/' do
haml :index
end
- use_in_file_templates!
-
__END__
@@ layout
%html
= yield
@@ index
%div.title Hello world!!!!!
+NOTE: Sinatra will automaticly load any in-file-templates in the
+source file that first required sinatra. If you have in-file-templates
+in another source file you will need to explicitly call
++use_in_file_templates! on main in that file.
+
It's also possible to define named templates using the top-level template
method:
template :layout do
"%html\n =yield\n"
@@ -378,84 +384,101 @@
many of of these components automatically based on configuration so you
typically don't have to +use+ them explicitly.
== Testing
-=== Test/Unit
+The Sinatra::Test module includes a variety of helper methods for testing
+your Sinatra app. Sinatra includes support for Test::Unit, test-spec, RSpec,
+and Bacon through separate source files.
- require 'rubygems'
+=== Test::Unit
+
require 'sinatra'
require 'sinatra/test/unit'
require 'my_sinatra_app'
class MyAppTest < Test::Unit::TestCase
-
def test_my_default
- get_it '/'
+ get '/'
assert_equal 'My Default Page!', @response.body
end
def test_with_agent
- get_it '/', :agent => 'Songbird'
+ get '/', :agent => 'Songbird'
assert_equal 'You're in Songbird!', @response.body
end
...
-
end
-=== Test/Spec
+=== Test::Spec
- require 'rubygems'
+Install the test-spec gem and require <tt>'sinatra/test/spec'</tt> before
+your app:
+
require 'sinatra'
require 'sinatra/test/spec'
require 'my_sinatra_app'
describe 'My app' do
-
it "should show a default page" do
- get_it '/'
+ get '/'
should.be.ok
body.should.equal 'My Default Page!'
end
...
-
end
=== RSpec
- require 'rubygems'
- require 'spec'
+Install the rspec gem and require <tt>'sinatra/test/rspec'</tt> before
+your app:
+
require 'sinatra'
require 'sinatra/test/rspec'
require 'my_sinatra_app'
describe 'My app' do
it 'should show a default page' do
- get_it '/'
+ get '/'
@response.should be_ok
@response.body.should == 'My Default Page!'
end
...
end
-See Sinatra::Test::Methods for more information on +get_it+, +post_it+,
-+put_it+, and friends.
+=== Bacon
+ require 'sinatra'
+ require 'sinatra/test/bacon'
+ require 'my_sinatra_app'
+
+ describe 'My app' do
+ it 'should be ok' do
+ get '/'
+ should.be.ok
+ body.should == 'Im OK'
+ end
+ end
+
+See Sinatra::Test for more information on +get+, +post+, +put+, and
+friends.
+
== Command line
Sinatra applications can be run directly:
- ruby myapp.rb [-h] [-x] [-p PORT] [-e ENVIRONMENT]
+ ruby myapp.rb [-h] [-x] [-e ENVIRONMENT] [-p PORT] [-s HANDLER]
Options are:
-h # help
-p # set the port (default is 4567)
-e # set the environment (default is development)
+ -s # specify rack server/handler (default is thin)
-x # turn on the mutex lock (default is off)
== Contributing
=== Tools