Skip to content
Browse files

Test a sinatra response.

  • Loading branch information...
1 parent cab237b commit 648095391ae9e047e0ce8ce029d0002ad5280bb6 @benburkert committed Feb 7, 2012
Showing with 32 additions and 1 deletion.
  1. +1 −0 rack-singleshot.gemspec
  2. +30 −1 spec/singleshot_spec.rb
  3. +1 −0 spec/spec_helper.rb
View
1 rack-singleshot.gemspec
@@ -20,6 +20,7 @@ SUMMARY
s.add_development_dependency 'rspec'
s.add_development_dependency 'rake'
+ s.add_development_dependency 'sinatra'
s.files = Dir["#{dir}/lib/**/*.rb"]
s.require_paths = ["lib"]
View
31 spec/singleshot_spec.rb
@@ -1,7 +1,7 @@
require 'spec_helper'
describe Rack::Handler::SingleShot do
- before(:all) do
+ before(:each) do
@stdin, @in = IO.pipe
@out, @stdout = IO.pipe
@@ -24,4 +24,33 @@
RESPONSE
end
+
+ describe "Sinatra App" do
+
+ class App < Sinatra::Base
+ get '/' do
+ 'response body'
+ end
+ end
+
+ before(:each) do
+ @stdin, @in = IO.pipe
+ @out, @stdout = IO.pipe
+
+ @app = Rack::Lint.new(App.new)
+ @server = Rack::Handler::SingleShot.new(@app, @stdin, @stdout)
+ end
+
+ it 'can handle a sinatra request' do
+ @in << <<-REQUEST.gsub("\n", "\r\n")
+GET / HTTP/1.1
+Server-Name: localhost
+
+REQUEST
+
+ @server.run
+
+ @out.read.should =~ /response body\Z/
+ end
+ end
end
View
1 spec/spec_helper.rb
@@ -1,6 +1,7 @@
$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'rack/singleshot'
+require 'sinatra'
RSpec.configure do |config|
config.color_enabled = true

0 comments on commit 6480953

Please sign in to comment.
Something went wrong with that request. Please try again.