Permalink
Browse files

Adding rack/test support to riot support

  • Loading branch information...
1 parent 8a25565 commit 59fe791a313471209c4b27fd226c5dde5c4e1c9d @gus gus committed Dec 15, 2009
Showing with 37 additions and 19 deletions.
  1. +0 −5 Rakefile
  2. +1 −0 VERSION
  3. +36 −1 lib/chicago/riot.rb
  4. +0 −13 test/riot_tests/test_helper.rb
View
@@ -22,11 +22,6 @@ Rake::TestTask.new("test:shoulda") do |t|
t.verbose = true
end
-# task :test => [:set_test_env] do
-# $:.concat ['./lib', './test/shoulda_tests']
-# Dir.glob("./test/shoulda_tests/*_test.rb").each { |test| require test }
-# end
-
desc "Open an irb session preloaded with this library"
task :console do
exec "irb -rubygems"
View
@@ -0,0 +1 @@
+0.3.6
View
@@ -1 +1,36 @@
-require 'chicago/riot/macros'
+require 'chicago/riot/macros'
+require 'rack/test'
+
+class Riot::Situation
+ include Rack::Test::Methods
+
+ # Allows Rack test methods to work in your Riot tests. Simply do this in your setup or test method:
+ #
+ # context "MyApp" do
+ # setup { @app = MyApp }
+ #
+ # context "get /foo" do
+ # setup { get "/foo" }
+ # # ... tests ...
+ # end
+ # end
+ def app
+ @app
+ end
+
+ # Sets up a Sinatra::Base subclass defined with the block given. Used in setup or individual test methods
+ # to define an application
+ #
+ # context "get /foo" do
+ # setup do
+ # mock_app {
+ # get("/foo") { stuff; status 200; }
+ # }
+ # get "/foo"
+ # end
+ # asserts_response_status 200
+ # end
+ def mock_app(base=Sinatra::Base, &block)
+ @app = Sinatra.new(base, &block)
+ end
+end
@@ -3,20 +3,7 @@
end
class Riot::Situation
- include Rack::Test::Methods
-
- # Sets up a Sinatra::Base subclass defined with the block
- # given. Used in setup or individual spec methods to establish
- # the application.
- def mock_app(base=Sinatra::Base, &block)
- @app = Sinatra.new(base, &block)
- end
-
def extend_mock_app(&block)
@app.instance_eval(&block)
end
-
- def app
- @app
- end
end

0 comments on commit 59fe791

Please sign in to comment.