Permalink
Browse files

Riot tests are passing. Weird shit with rack/test going on

  • Loading branch information...
1 parent d6f6564 commit 33322c50a2cd4c85a4e5de82eed6c57a83ae3571 @gus gus committed Nov 22, 2009
View
@@ -8,9 +8,10 @@ task :default => [:test]
task(:set_test_env) { ENV['RACK_ENV'] ||= 'test' }
desc "Run all tests"
-task :test => [:set_test_env] do
- $:.concat ['./lib', './test']
- Dir.glob("./test/*_test.rb").each { |test| require test }
+Rake::TestTask.new("test") do |t|
+ t.libs.concat ['./lib', './test']
+ t.test_files = FileList['test/*_test.rb']
+ t.verbose = true
end
task "test:shoulda" => [:set_test_env]
View
@@ -21,12 +21,15 @@ def asserts_location(expected_path)
end.matches(expected_path)
end
- def asserts_json_response(json, &block)
+ def asserts_json_response(json)
asserts_content_type 'application/json'
+
+ json = json.to_json unless json.instance_of?(String)
+ json
+
asserts("response body has JSON") do
- json = json.to_json unless json.instance_of?(String)
- json
- end.equals(situation.last_response.body)
+ last_response.body
+ end.equals(json)
# Calling situation is kind of yucky, but maybe not. The maybe not is because of how explicit it is
# to say "situation" (gus)
end
@@ -42,4 +45,4 @@ def asserts_redirected_to(expected_path)
end # Riot
end # Chicago
-Riot::Context.instance_eval { include Chicago::Riot::Macros }
+Riot::Context.instance_eval { include Chicago::Riot::Macros }
@@ -4,12 +4,12 @@
setup do
mock_app {
helpers Sinatra::Chicago::Responders
- get("/redirecter") { redirect '/foo/bar' }
+ get("/redirector") { redirect '/foo/bar' }
}
end
context "asserts redirected to" do
- setup { get('/redirecter') }
+ setup { get('/redirector') }
asserts_redirected_to('/foo/bar')
end # asserts redirected to
end
@@ -1,8 +1,8 @@
-%w[ rubygems test/unit shoulda haml sass chicago rack/test chicago/shoulda ].each do |lib|
+%w[ rubygems test/unit shoulda haml sass chicago sinatra/test chicago/shoulda ].each do |lib|
require lib
end
-module Rack::Test::Methods
+module Sinatra::Test
# Sets up a Sinatra::Base subclass defined with the block
# given. Used in setup or individual spec methods to establish
# the application.
@@ -11,11 +11,12 @@ def mock_app(base=Sinatra::Base, &block)
end
def extend_mock_app(&block)
- @_rack_test_session ||= Rack::Test::Session.new(app)
@app.instance_eval(&block)
end
end
class Test::Unit::TestCase
- include Rack::Test::Methods
+ include Sinatra::Test
+
+ alias_method :last_response, :response
end
View
@@ -1,8 +1,12 @@
-%w[ rubygems riot haml sass chicago rack/test chicago/riot ].each do |lib|
+%w[ rubygems riot haml sass chicago sinatra/test chicago/riot ].each do |lib|
require lib
end
-module Rack::Test::Methods
+class Riot::Situation
+ include Sinatra::Test
+
+ alias_method :last_response, :response
+
# Sets up a Sinatra::Base subclass defined with the block
# given. Used in setup or individual spec methods to establish
# the application.
@@ -11,15 +15,10 @@ def mock_app(base=Sinatra::Base, &block)
end
def extend_mock_app(&block)
- @_rack_test_session ||= Rack::Test::Session.new(app)
@app.instance_eval(&block)
end
def app
@app
end
end
-
-class Riot::Situation
- include Rack::Test::Methods
-end

0 comments on commit 33322c5

Please sign in to comment.