Skip to content

Commit

Permalink
Add some missing tests
Browse files Browse the repository at this point in the history
darcs-hash:20070303095652-4fc50-7a15fec375f8b2a4ac86b3cf957f8fb3ad1008f9.gz
  • Loading branch information
leahneukirchen committed Mar 3, 2007
1 parent b29366b commit 7ade69b
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/rack/lobster.rb
@@ -1,5 +1,8 @@
require 'zlib'

require 'rack/request'
require 'rack/response'

module Rack
# Paste has a Pony, Rack has a Lobster!
class Lobster
Expand Down
45 changes: 45 additions & 0 deletions test/spec_rack_lobster.rb
@@ -0,0 +1,45 @@
require 'test/spec'

require 'rack/lobster'
require 'rack/mock'

context "Rack::Lobster::LambdaLobster" do
specify "should be a single lambda" do
Rack::Lobster::LambdaLobster.should.be.kind_of Proc
end

specify "should look like a lobster" do
res = Rack::MockRequest.new(Rack::Lobster::LambdaLobster).get("/")
res.should.be.ok
res.body.should.include "(,(,,(,,,("
res.body.should.include "?flip"
end

specify "should be flippable" do
res = Rack::MockRequest.new(Rack::Lobster::LambdaLobster).get("/?flip")
res.should.be.ok
res.body.should.include "(,,,(,,(,("
end
end

context "Rack::Lobster" do
specify "should look like a lobster" do
res = Rack::MockRequest.new(Rack::Lobster.new).get("/")
res.should.be.ok
res.body.should.include "(,(,,(,,,("
res.body.should.include "?flip"
res.body.should.include "crash"
end

specify "should be flippable" do
res = Rack::MockRequest.new(Rack::Lobster.new).get("/?flip=left")
res.should.be.ok
res.body.should.include "(,,,(,,(,("
end

specify "should provide crashing for testing purposes" do
lambda {
Rack::MockRequest.new(Rack::Lobster.new).get("/?flip=crash")
}.should.raise
end
end
5 changes: 5 additions & 0 deletions test/spec_rack_response.rb
Expand Up @@ -101,5 +101,10 @@
str = ""; body.each { |part| str << part }
str.should.be.empty
header["Content-Type"].should.equal nil

lambda {
Rack::Response.new(Object.new)
}.should.raise(TypeError).
message.should =~ /String or iterable required/
end
end

0 comments on commit 7ade69b

Please sign in to comment.