@@ -66,13 +66,15 @@ def self.calls
66
66
end
67
67
68
68
describe "use_custom_ui" do
69
+ before do
70
+ app . use_custom_ui ( custom_ui )
71
+ get "/" , nil , { "HTTP_ACCEPT" => "text/html" }
72
+ end
73
+
69
74
context "when the UI returns a non 404 response" do
70
75
let ( :custom_ui ) { double ( 'ui' , call : [ 200 , { } , [ "hello" ] ] ) }
71
76
72
77
it "returns the given page" do
73
- app . use_custom_ui ( custom_ui )
74
-
75
- get "/" , nil , { "HTTP_ACCEPT" => "text/html" }
76
78
expect ( last_response . body ) . to eq "hello"
77
79
end
78
80
end
@@ -81,12 +83,34 @@ def self.calls
81
83
let ( :custom_ui ) { double ( 'ui' , call : [ 404 , { } , [ ] ] ) }
82
84
83
85
it "passes on the call to the rest of the app" do
84
- get "/" , nil , { "HTTP_ACCEPT" => "text/html" }
85
86
expect ( last_response . status ) . to eq 200
86
87
end
87
88
end
88
89
end
89
90
91
+ describe "use_custom_api" do
92
+ before do
93
+ app . use_custom_api ( custom_api )
94
+ get "/" , nil , { "HTTP_ACCEPT" => "application/hal+json" }
95
+ end
96
+
97
+ context "when the API returns a non 404 response" do
98
+ let ( :custom_api ) { double ( 'api' , call : [ 200 , { } , [ "hello" ] ] ) }
99
+
100
+ it "returns the given resource" do
101
+ expect ( last_response . body ) . to eq "hello"
102
+ end
103
+ end
104
+
105
+ context "when the custom API returns a 404 response" do
106
+ let ( :custom_api ) { double ( 'api' , call : [ 404 , { } , [ ] ] ) }
107
+
108
+ it "passes on the call to the rest of the app" do
109
+ expect ( last_response . body ) . to_not eq "hello"
110
+ end
111
+ end
112
+ end
113
+
90
114
describe "use_xxx_auth" do
91
115
class TestAuth
92
116
def initialize app , *args , &block
0 commit comments