Skip to content
Browse files

Add support for ranges in response_code expectations

  • Loading branch information...
1 parent ca9263b commit a242d93fb74b7e1a4849cae5223cf33d1da8481e @brain-geek brain-geek committed Dec 17, 2011
Showing with 10 additions and 1 deletion.
  1. +1 −1 lib/outpost/expectations/response_code.rb
  2. +9 −0 test/outpost/expectations/response_code_test.rb
View
2 lib/outpost/expectations/response_code.rb
@@ -11,7 +11,7 @@ def self.extended(base)
# Method that will be used as an expectation to evaluate response code
def evaluate_response_code(scout, response_code)
- if response_code.is_a?(Array)
+ if response_code.is_a?(Array) || response_code.is_a?(Range)
response_code.include?(scout.response_code)
else
scout.response_code == response_code.to_i
View
9 test/outpost/expectations/response_code_test.rb
@@ -44,6 +44,15 @@ def expect(expectation, evaluation_method)
refute SubjectCode.evaluate_response_code(scout_stub, [500, 503])
end
+ it "should return true when response code is included in the range" do
+ assert SubjectCode.evaluate_response_code(scout_stub, 200...300)
+ end
+
+ it "should refute when response code is not included in the range" do
+ refute SubjectCode.evaluate_response_code(scout_stub, 500..503)
+ end
+
+
private
def scout_stub
build_stub(:response_code => 200)

0 comments on commit a242d93

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