Permalink
Browse files

rack support

  • Loading branch information...
1 parent 2dbfa5f commit 221f1094f2866dc4674a04fb6526592ef116d87a @quackingduck quackingduck committed Jun 10, 2010
Showing with 46 additions and 0 deletions.
  1. +13 −0 README.md
  2. +11 −0 examples/rack.rb
  3. +22 −0 lib/exemplor/rack.rb
View
@@ -210,6 +210,19 @@ Running with `--list` or `-l` lists all examples:
- called with --l arg
- called with some other arg (always interpreted as a regex)
+Testing Rack Apps
+-----------------
+
+Exemplor has built-in support for rack-test. First make sure you have the rack-test gem installed. Then require `exemplor/rack`, then simply call `eg.app` and pass in your rack app:
+
+ hello_app = lambda { [200,{},'oh hai'] }
+
+ eg.app hello_app
+
+ eg "rack support works" do
+ get '/'
+ Assert(last_response.body == 'oh hai')
+ end
Thanks
------
View
@@ -0,0 +1,11 @@
+require 'exemplor'
+require 'exemplor/rack'
+
+simple_app = lambda { [200,{},'oh hai'] }
+
+eg.app simple_app
+
+eg "rack support works" do
+ get '/'
+ Assert(last_response.body == 'oh hai')
+end
View
@@ -0,0 +1,22 @@
+require 'rack/test'
+
+class Exemplor::Environment
+ include Rack::Test::Methods
+
+ # Public: Sets the target app for rack/test
+ #
+ # Examples
+ #
+ # # Sinatra
+ # eg.app(Sinatra::Application)
+ # # Rails
+ # eg.app(ActionController::Dispatcher.new)
+ #
+ def self.app(app)
+ @@app = app
+ end
+
+ def app
+ @@app
+ end
+end

2 comments on commit 221f109

@lachie
Contributor
lachie commented on 221f109 Jul 1, 2010

gorgeous!

@quackingduck
Contributor

thanks dude!

Please sign in to comment.