Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Move a few specs out of base_test and into more appropriate tests

  • Loading branch information...
commit 6fd8aaadd12c3542b7f03848c205c7770bb6168b 1 parent a9e9f00
Ryan Tomayko rtomayko authored
Showing with 35 additions and 36 deletions.
  1. +0 −36 test/base_test.rb
  2. +14 −0 test/helpers_test.rb
  3. +21 −0 test/routing_test.rb
36 test/base_test.rb
View
@@ -42,40 +42,4 @@
assert response.ok?
assert_equal 'Goodbye World', response.body
end
-
- it 'can take multiple definitions of a route' do
- app = mock_app {
- user_agent(/Foo/)
- get '/foo' do
- 'foo'
- end
-
- get '/foo' do
- 'not foo'
- end
- }
-
- request = Rack::MockRequest.new(app)
- response = request.get('/foo', 'HTTP_USER_AGENT' => 'Foo')
- assert response.ok?
- assert_equal 'foo', response.body
-
- request = Rack::MockRequest.new(app)
- response = request.get('/foo')
- assert response.ok?
- assert_equal 'not foo', response.body
- end
-
- it "makes redirecting back pretty" do
- app = mock_app {
- get '/foo' do
- redirect back
- end
- }
-
- request = Rack::MockRequest.new(app)
- response = request.get('/foo', 'HTTP_REFERER' => 'http://github.com')
- assert response.redirect?
- assert_equal "http://github.com", response.location
- end
end
14 test/helpers_test.rb
View
@@ -394,6 +394,20 @@ def send_file_app(opts={})
end
end
+describe 'Helpers#back' do
+ it "makes redirecting back pretty" do
+ mock_app {
+ get '/foo' do
+ redirect back
+ end
+ }
+
+ get '/foo', {}, 'HTTP_REFERER' => 'http://github.com'
+ assert redirect?
+ assert_equal "http://github.com", response.location
+ end
+end
+
module HelperOne; def one; '1'; end; end
module HelperTwo; def two; '2'; end; end
21 test/routing_test.rb
View
@@ -44,6 +44,27 @@ def route_def(pattern)
assert_equal 404, status
end
+ it 'takes multiple definitions of a route' do
+ mock_app {
+ user_agent(/Foo/)
+ get '/foo' do
+ 'foo'
+ end
+
+ get '/foo' do
+ 'not foo'
+ end
+ }
+
+ get '/foo', {}, 'HTTP_USER_AGENT' => 'Foo'
+ assert ok?
+ assert_equal 'foo', body
+
+ get '/foo'
+ assert ok?
+ assert_equal 'not foo', body
+ end
+
it "exposes params with indifferent hash" do
mock_app {
get '/:foo' do
Please sign in to comment.
Something went wrong with that request. Please try again.