Skip to content

Commit

Permalink
Check that block given to Request#authenticate
Browse files Browse the repository at this point in the history
  • Loading branch information
mloughran committed Jun 21, 2012
1 parent f5ac2d4 commit 5df3f32
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/signature.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def authenticate_by_token(token, timestamp_grace = 600)
end

def authenticate(timestamp_grace = 600, &block)
raise ArgumentError, "Block required" unless block_given?
key = @auth_hash['auth_key']
raise AuthenticationError, "Authentication key required" unless key
token = yield key
Expand Down
7 changes: 7 additions & 0 deletions spec/signature_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,13 @@
request.authenticate { |key| nil }
}.should raise_error('Invalid authentication key')
end

it "should raise unless block given" do
request = Signature::Request.new('POST', '/some/path', @params)
lambda {
request.authenticate
}.should raise_error(ArgumentError, "Block required")
end
end
end
end

0 comments on commit 5df3f32

Please sign in to comment.