class Webspicy::Tester::Result
Attributes
assertions[R]
client[R]
errors[R]
failures[R]
invocation[R]
scope[R]
service[R]
specification[R]
test_case[R]
tester[R]
Public Class Methods
from(tester)
click to toggle source
# File lib/webspicy/tester/result.rb, line 33 def self.from(tester) new(tester) end
new(tester)
click to toggle source
# File lib/webspicy/tester/result.rb, line 6 def initialize(tester) @tester = tester @scope = tester.scope @client = tester.client @specification = tester.specification @service = tester.service @test_case = tester.test_case @invocation = tester.invocation @assertions = [] @failures = [] @errors = [] if @invocation check! else @errors << [InvocationSuceeded.new(self), tester.invocation_error] reporter.check_error(*errors.first) end end
Public Instance Methods
assertions_count()
click to toggle source
# File lib/webspicy/tester/result.rb, line 49 def assertions_count assertions.size end
error?()
click to toggle source
# File lib/webspicy/tester/result.rb, line 45 def error? !errors.empty? end
errors_count()
click to toggle source
# File lib/webspicy/tester/result.rb, line 57 def errors_count errors.size end
failure?()
click to toggle source
# File lib/webspicy/tester/result.rb, line 41 def failure? errors.empty? && !failures.empty? end
failures_count()
click to toggle source
# File lib/webspicy/tester/result.rb, line 53 def failures_count failures.size end
success?()
click to toggle source
# File lib/webspicy/tester/result.rb, line 37 def success? failures.empty? && errors.empty? end
Private Instance Methods
check!()
click to toggle source
# File lib/webspicy/tester/result.rb, line 63 def check! check_response! check_output! if success? && test_case.example? check_error! if success? && test_case.counterexample? check_assertions! if success? check_postconditions! if success? && test_case.example? check_errconditions! if success? && test_case.counterexample? end
check_assertions!()
click to toggle source
# File lib/webspicy/tester/result.rb, line 92 def check_assertions! test_case.assert.each do |a| check_one! Result::AssertMet.new(self, a) end end
check_errconditions!()
click to toggle source
# File lib/webspicy/tester/result.rb, line 104 def check_errconditions! service.errconditions.each do |c| check_one! Result::ErrconditionMet.new(self, tester.bind_condition(c)) end end
check_error!()
click to toggle source
# File lib/webspicy/tester/result.rb, line 88 def check_error! check_one! Result::ErrorSchemaMet end
check_one!(check)
click to toggle source
# File lib/webspicy/tester/result.rb, line 110 def check_one!(check) if check.is_a?(Class) check_one!(check.new(self)) else return unless check.must? begin check.call reporter.check_success(check) rescue *PASSTHROUGH_EXCEPTIONS raise rescue Failure => e self.failures << [check, e] reporter.check_failure(check, e) rescue Exception => e self.errors << [check, e] reporter.check_error(check, e) ensure self.assertions << check end end end
check_output!()
click to toggle source
# File lib/webspicy/tester/result.rb, line 84 def check_output! check_one! Result::OutputSchemaMet end
check_postconditions!()
click to toggle source
# File lib/webspicy/tester/result.rb, line 98 def check_postconditions! service.postconditions.each do |c| check_one! Result::PostconditionMet.new(self, tester.bind_condition(c)) end end
check_response!()
click to toggle source
# File lib/webspicy/tester/result.rb, line 74 def check_response! check_one! Result::ResponseStatusMet if ect = test_case.expected_content_type check_one! Result::ResponseHeaderMet.new(self, "Content-Type", ect, :start_with) end test_case.expected_headers.each_pair do |k,v| check_one! Result::ResponseHeaderMet.new(self, k, v) end end