Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Legit method not supported error with spec

  • Loading branch information...
commit e208c3116c65f8638780289b28e34a7bfb5dc4ea 1 parent 19119a6
@jnunemaker authored
View
7 lib/flipper/ui/middleware.rb
@@ -5,6 +5,8 @@
module Flipper
module UI
class Middleware
+ Error = Class.new(StandardError)
+
def initialize(app, flipper)
@app = app
@flipper = flipper
@@ -17,6 +19,9 @@ def titleize(str)
end
class Action
+ Error = Class.new(Middleware::Error)
+ MethodNotSupported = Class.new(Error)
+
include Helpers
def self.views_path
@@ -105,7 +110,7 @@ def call(env)
if action.respond_to?(method_name)
action.send method_name
else
- raise "#{request.request_method} not supported by #{action.class}"
+ raise Action::MethodNotSupported, "#{action.class} does not support #{method_name}"
end
else
@app.call(env)
View
8 spec/flipper-ui/middleware_spec.rb
@@ -62,4 +62,12 @@ def app
last_response.status.should be(200)
end
end
+
+ context "Request method unsupported by action" do
+ it "raises error" do
+ expect {
+ post '/flipper/images/logo.png'
+ }.to raise_error(Flipper::UI::Middleware::Action::MethodNotSupported)
+ end
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.