Skip to content
Browse files

Fail gracefully if the response_time is nil

  • Loading branch information...
1 parent 9e5817c commit 6692b5aa7303dcdd6f81cc410d149701d8130c84 @vinibaggio vinibaggio committed Nov 9, 2011
Showing with 7 additions and 1 deletion.
  1. +1 −1 lib/outpost/expectations/response_time.rb
  2. +6 −0 test/outpost/expectations/response_time_test.rb
View
2 lib/outpost/expectations/response_time.rb
@@ -21,7 +21,7 @@ def self.extended(base)
# Method that will be used as an expectation to evaluate response time
def evaluate_response_time(scout, rules)
rules.all? do |rule, comparison|
- scout.response_time.send(RESPONSE_TIME_MAPPING[rule], comparison)
+ comparison && scout.response_time.send(RESPONSE_TIME_MAPPING[rule], comparison)
end
end
end
View
6 test/outpost/expectations/response_time_test.rb
@@ -14,6 +14,12 @@ def expect(expectation, evaluation_method)
extend Outpost::Expectations::ResponseTime
end
+ describe ".evaluation_response_time with nil" do
+ it "should fail gracefully" do
+ refute SubjectTime.evaluate_response_time(scout_stub, :less_than => nil)
+ end
+ end
+
describe ".evaluate_response_time with less_than" do
it "should return true when it matches" do
assert SubjectTime.evaluate_response_time(scout_stub, :less_than => 5000)

0 comments on commit 6692b5a

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