Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Adding rack/test support to riot support

  • Loading branch information...
commit 59fe791a313471209c4b27fd226c5dde5c4e1c9d 1 parent 8a25565
@gus gus authored
View
5 Rakefile
@@ -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
1  VERSION
@@ -0,0 +1 @@
+0.3.6
View
37 lib/chicago/riot.rb
@@ -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
View
13 test/riot_tests/test_helper.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.