test/outpost/expectations/response_time_test.rb in outpost-0.1.0 vs test/outpost/expectations/response_time_test.rb in outpost-0.2.0
- old
+ new
@@ -14,42 +14,42 @@
extend Outpost::Expectations::ResponseTime
end
describe ".evaluate_response_time with less_than" do
it "should return true when it matches" do
- assert SubjectTime.evaluate_response_time(scout_mock, :less_than => 5000)
+ assert SubjectTime.evaluate_response_time(scout_stub, :less_than => 5000)
end
it "should return false when it doesn't" do
- refute SubjectTime.evaluate_response_time(scout_mock, :less_than => 1)
+ refute SubjectTime.evaluate_response_time(scout_stub, :less_than => 1)
end
end
describe ".evaluate_response_time with more_than" do
it "should return true when it matches" do
- assert SubjectTime.evaluate_response_time(scout_mock, :more_than => 1)
+ assert SubjectTime.evaluate_response_time(scout_stub, :more_than => 1)
end
it "should return false when it doesn't" do
- refute SubjectTime.evaluate_response_time(scout_mock, :more_than => 5000)
+ refute SubjectTime.evaluate_response_time(scout_stub, :more_than => 5000)
end
end
describe ".evaluate_response_time with multiple rules" do
it "should return true when all rules matches" do
rules = {:more_than => 200, :less_than => 5000}
- assert SubjectTime.evaluate_response_time(scout_mock, rules)
+ assert SubjectTime.evaluate_response_time(scout_stub, rules)
end
it "should return false when there are no matches" do
rules = {:more_than => 700, :less_than => 200}
- refute SubjectTime.evaluate_response_time(scout_mock, rules)
+ refute SubjectTime.evaluate_response_time(scout_stub, rules)
end
it "should return false when at least one rule doesn't match" do
rules = {:more_than => 100, :less_than => 200}
- refute SubjectTime.evaluate_response_time(scout_mock, rules)
+ refute SubjectTime.evaluate_response_time(scout_stub, rules)
end
end
it "should set expectation correctly" do
assert_equal :response_time, SubjectTime.expectation
@@ -59,12 +59,10 @@
assert_equal SubjectTime.method(:evaluate_response_time),
SubjectTime.evaluation_method
end
private
- def scout_mock
- @scout_mock ||= OpenStruct.new.tap do |scout_mock|
- scout_mock.response_time = 300
- end
+ def scout_stub
+ build_stub(:response_time => 300)
end
end