Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

  • Loading branch information...
commit 6fd8aaadd12c3542b7f03848c205c7770bb6168b 1 parent a9e9f00
Ryan Tomayko authored February 21, 2009
36  test/base_test.rb
@@ -42,40 +42,4 @@
42 42
     assert response.ok?
43 43
     assert_equal 'Goodbye World', response.body
44 44
   end
45  
-
46  
-  it 'can take multiple definitions of a route' do
47  
-    app = mock_app {
48  
-      user_agent(/Foo/)
49  
-      get '/foo' do
50  
-        'foo'
51  
-      end
52  
-
53  
-      get '/foo' do
54  
-        'not foo'
55  
-      end
56  
-    }
57  
-
58  
-    request = Rack::MockRequest.new(app)
59  
-    response = request.get('/foo', 'HTTP_USER_AGENT' => 'Foo')
60  
-    assert response.ok?
61  
-    assert_equal 'foo', response.body
62  
-
63  
-    request = Rack::MockRequest.new(app)
64  
-    response = request.get('/foo')
65  
-    assert response.ok?
66  
-    assert_equal 'not foo', response.body
67  
-  end
68  
-
69  
-  it "makes redirecting back pretty" do
70  
-    app = mock_app {
71  
-      get '/foo' do
72  
-        redirect back
73  
-      end
74  
-    }
75  
-
76  
-    request  = Rack::MockRequest.new(app)
77  
-    response = request.get('/foo', 'HTTP_REFERER' => 'http://github.com')
78  
-    assert response.redirect?
79  
-    assert_equal "http://github.com", response.location
80  
-  end
81 45
 end
14  test/helpers_test.rb
@@ -394,6 +394,20 @@ def send_file_app(opts={})
394 394
   end
395 395
 end
396 396
 
  397
+describe 'Helpers#back' do
  398
+  it "makes redirecting back pretty" do
  399
+    mock_app {
  400
+      get '/foo' do
  401
+        redirect back
  402
+      end
  403
+    }
  404
+
  405
+    get '/foo', {}, 'HTTP_REFERER' => 'http://github.com'
  406
+    assert redirect?
  407
+    assert_equal "http://github.com", response.location
  408
+  end
  409
+end
  410
+
397 411
 module HelperOne; def one; '1'; end; end
398 412
 module HelperTwo; def two; '2'; end; end
399 413
 
21  test/routing_test.rb
@@ -44,6 +44,27 @@ def route_def(pattern)
44 44
     assert_equal 404, status
45 45
   end
46 46
 
  47
+  it 'takes multiple definitions of a route' do
  48
+    mock_app {
  49
+      user_agent(/Foo/)
  50
+      get '/foo' do
  51
+        'foo'
  52
+      end
  53
+
  54
+      get '/foo' do
  55
+        'not foo'
  56
+      end
  57
+    }
  58
+
  59
+    get '/foo', {}, 'HTTP_USER_AGENT' => 'Foo'
  60
+    assert ok?
  61
+    assert_equal 'foo', body
  62
+
  63
+    get '/foo'
  64
+    assert ok?
  65
+    assert_equal 'not foo', body
  66
+  end
  67
+
47 68
   it "exposes params with indifferent hash" do
48 69
     mock_app {
49 70
       get '/:foo' do

0 notes on commit 6fd8aaa

Please sign in to comment.
Something went wrong with that request. Please try again.