spec/warden/manager_spec.rb in hassox-warden-0.2.3 vs spec/warden/manager_spec.rb in hassox-warden-0.3.0

- old
+ new

@@ -21,11 +21,11 @@ @basic_app = lambda{|env| [200,{'Content-Type' => 'text/plain'},'OK']} @authd_app = lambda do |e| if e['warden'].authenticated? [200,{'Content-Type' => 'text/plain'},"OK"] else - [401,{'Content-Type' => 'text/plain'},"You Fail"] + [401,{'Content-Type' => 'text/plain'},"Fail From The App"] end end @env = Rack::MockRequest. env_for('/', 'HTTP_VERSION' => '1.1', 'REQUEST_METHOD' => 'GET') end # before(:each) @@ -123,10 +123,31 @@ result = @app.call(env) result[0].should == 401 result[2].should == ["You Fail!"] env['PATH_INFO'].should == "/unauthenticated" end + + it "should allow you to customize the response" do + app = lambda do |e| + e['warden'].custom_failure! + [401,{'Content-Type' => 'text/plain'},["Fail From The App"]] + end + env = env_with_params + result = setup_rack(app).call(env) + result[0].should == 401 + result[2].should == ["Fail From The App"] + end + + it "should render the failure application for a 401 if no custom_failure flag is set" do + app = lambda do |e| + [401,{'Content-Type' => 'text/plain'},["Fail From The App"]] + end + result = setup_rack(app).call(env_with_params) + result[0].should == 401 + result[2].should == ["You Fail!"] + end + end # failing describe "custom rack response" do it "should return a custom rack response" do RAS.add(:foobar) do @@ -153,6 +174,7 @@ result[0].should == 200 result[2].should == ["Foo Is A Winna"] end end end # integrated strategies + end