Sha256: fba67973c7a35984a474cef54813730f775f0a209defab7f4e9638ced3be0c0d
Contents?: true
Size: 1.65 KB
Versions: 2
Compression:
Stored size: 1.65 KB
Contents
require 'test_helper' require 'ostruct' describe Outpost::Expectations::ResponseCode do class SubjectCode class << self attr_reader :expectation, :evaluation_method def expect(expectation, evaluation_method) @expectation = expectation @evaluation_method = evaluation_method end end extend Outpost::Expectations::ResponseCode end it "should return true when response codes match" do assert SubjectCode.evaluate_response_code(scout_stub, 200) end it "should return false when response codes doesn't match" do refute SubjectCode.evaluate_response_code(scout_stub, 404) end it "should convert types accordinly" do assert SubjectCode.evaluate_response_code(scout_stub, "200") end it "should set expectation correctly" do assert_equal :response_code, SubjectCode.expectation end it "should set evaluation method correctly" do assert_equal SubjectCode.method(:evaluate_response_code), SubjectCode.evaluation_method end it "should return true when response code is included in the list" do assert SubjectCode.evaluate_response_code(scout_stub, [200, 301]) end it "should refute when response code is not included in the list" do 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) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
outpost-0.2.5 | test/outpost/expectations/response_code_test.rb |
outpost-0.2.4 | test/outpost/expectations/response_code_test.rb |